Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2009, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioPolicyService" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <stdint.h> |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <binder/Parcel.h> |
| 25 | |
| 26 | #include <media/IAudioPolicyService.h> |
| 27 | |
Dima Zavin | 6476024 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 28 | #include <system/audio.h> |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 29 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 30 | namespace android { |
| 31 | |
| 32 | enum { |
| 33 | SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, |
| 34 | GET_DEVICE_CONNECTION_STATE, |
| 35 | SET_PHONE_STATE, |
Glenn Kasten | 0b07b80 | 2012-01-18 14:56:06 -0800 | [diff] [blame] | 36 | SET_RINGER_MODE, // reserved, no longer used |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 37 | SET_FORCE_USE, |
| 38 | GET_FORCE_USE, |
| 39 | GET_OUTPUT, |
| 40 | START_OUTPUT, |
| 41 | STOP_OUTPUT, |
| 42 | RELEASE_OUTPUT, |
| 43 | GET_INPUT, |
| 44 | START_INPUT, |
| 45 | STOP_INPUT, |
| 46 | RELEASE_INPUT, |
| 47 | INIT_STREAM_VOLUME, |
| 48 | SET_STREAM_VOLUME, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 49 | GET_STREAM_VOLUME, |
| 50 | GET_STRATEGY_FOR_STREAM, |
| 51 | GET_OUTPUT_FOR_EFFECT, |
| 52 | REGISTER_EFFECT, |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 53 | UNREGISTER_EFFECT, |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 54 | IS_STREAM_ACTIVE, |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 55 | IS_SOURCE_ACTIVE, |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 56 | GET_DEVICES_FOR_STREAM, |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 57 | QUERY_DEFAULT_PRE_PROCESSING, |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 58 | SET_EFFECT_ENABLED, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 59 | IS_STREAM_ACTIVE_REMOTELY, |
| 60 | IS_OFFLOAD_SUPPORTED |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | class BpAudioPolicyService : public BpInterface<IAudioPolicyService> |
| 64 | { |
| 65 | public: |
| 66 | BpAudioPolicyService(const sp<IBinder>& impl) |
| 67 | : BpInterface<IAudioPolicyService>(impl) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | virtual status_t setDeviceConnectionState( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 72 | audio_devices_t device, |
| 73 | audio_policy_dev_state_t state, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 74 | const char *device_address) |
| 75 | { |
| 76 | Parcel data, reply; |
| 77 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 78 | data.writeInt32(static_cast <uint32_t>(device)); |
| 79 | data.writeInt32(static_cast <uint32_t>(state)); |
| 80 | data.writeCString(device_address); |
| 81 | remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); |
| 82 | return static_cast <status_t> (reply.readInt32()); |
| 83 | } |
| 84 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 85 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 86 | audio_devices_t device, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 87 | const char *device_address) |
| 88 | { |
| 89 | Parcel data, reply; |
| 90 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 91 | data.writeInt32(static_cast <uint32_t>(device)); |
| 92 | data.writeCString(device_address); |
| 93 | remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 94 | return static_cast <audio_policy_dev_state_t>(reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 97 | virtual status_t setPhoneState(audio_mode_t state) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 98 | { |
| 99 | Parcel data, reply; |
| 100 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 101 | data.writeInt32(state); |
| 102 | remote()->transact(SET_PHONE_STATE, data, &reply); |
| 103 | return static_cast <status_t> (reply.readInt32()); |
| 104 | } |
| 105 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 106 | virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 107 | { |
| 108 | Parcel data, reply; |
| 109 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 110 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 111 | data.writeInt32(static_cast <uint32_t>(config)); |
| 112 | remote()->transact(SET_FORCE_USE, data, &reply); |
| 113 | return static_cast <status_t> (reply.readInt32()); |
| 114 | } |
| 115 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 116 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 117 | { |
| 118 | Parcel data, reply; |
| 119 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 120 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 121 | remote()->transact(GET_FORCE_USE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 122 | return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | virtual audio_io_handle_t getOutput( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 126 | audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 127 | uint32_t samplingRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 128 | audio_format_t format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 129 | audio_channel_mask_t channelMask, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 130 | audio_output_flags_t flags, |
| 131 | const audio_offload_info_t *offloadInfo) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 132 | { |
| 133 | Parcel data, reply; |
| 134 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 135 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 136 | data.writeInt32(samplingRate); |
| 137 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 138 | data.writeInt32(channelMask); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 139 | data.writeInt32(static_cast <uint32_t>(flags)); |
Glenn Kasten | 2301acc | 2014-01-17 10:21:00 -0800 | [diff] [blame] | 140 | // hasOffloadInfo |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 141 | if (offloadInfo == NULL) { |
| 142 | data.writeInt32(0); |
| 143 | } else { |
| 144 | data.writeInt32(1); |
| 145 | data.write(offloadInfo, sizeof(audio_offload_info_t)); |
| 146 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 147 | remote()->transact(GET_OUTPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 148 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 151 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 152 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 153 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 154 | { |
| 155 | Parcel data, reply; |
| 156 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 157 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 158 | data.writeInt32((int32_t) stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 159 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 160 | remote()->transact(START_OUTPUT, data, &reply); |
| 161 | return static_cast <status_t> (reply.readInt32()); |
| 162 | } |
| 163 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 164 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 165 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 166 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 167 | { |
| 168 | Parcel data, reply; |
| 169 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 170 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 171 | data.writeInt32((int32_t) stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 172 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 173 | remote()->transact(STOP_OUTPUT, data, &reply); |
| 174 | return static_cast <status_t> (reply.readInt32()); |
| 175 | } |
| 176 | |
| 177 | virtual void releaseOutput(audio_io_handle_t output) |
| 178 | { |
| 179 | Parcel data, reply; |
| 180 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 181 | data.writeInt32(output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 182 | remote()->transact(RELEASE_OUTPUT, data, &reply); |
| 183 | } |
| 184 | |
| 185 | virtual audio_io_handle_t getInput( |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 186 | audio_source_t inputSource, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 187 | uint32_t samplingRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 188 | audio_format_t format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 189 | audio_channel_mask_t channelMask, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 190 | int audioSession) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 191 | { |
| 192 | Parcel data, reply; |
| 193 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 194 | data.writeInt32((int32_t) inputSource); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 195 | data.writeInt32(samplingRate); |
| 196 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 197 | data.writeInt32(channelMask); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 198 | data.writeInt32(audioSession); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 199 | remote()->transact(GET_INPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 200 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | virtual status_t startInput(audio_io_handle_t input) |
| 204 | { |
| 205 | Parcel data, reply; |
| 206 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 207 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 208 | remote()->transact(START_INPUT, data, &reply); |
| 209 | return static_cast <status_t> (reply.readInt32()); |
| 210 | } |
| 211 | |
| 212 | virtual status_t stopInput(audio_io_handle_t input) |
| 213 | { |
| 214 | Parcel data, reply; |
| 215 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 216 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 217 | remote()->transact(STOP_INPUT, data, &reply); |
| 218 | return static_cast <status_t> (reply.readInt32()); |
| 219 | } |
| 220 | |
| 221 | virtual void releaseInput(audio_io_handle_t input) |
| 222 | { |
| 223 | Parcel data, reply; |
| 224 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 225 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 226 | remote()->transact(RELEASE_INPUT, data, &reply); |
| 227 | } |
| 228 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 229 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 230 | int indexMin, |
| 231 | int indexMax) |
| 232 | { |
| 233 | Parcel data, reply; |
| 234 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 235 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 236 | data.writeInt32(indexMin); |
| 237 | data.writeInt32(indexMax); |
| 238 | remote()->transact(INIT_STREAM_VOLUME, data, &reply); |
| 239 | return static_cast <status_t> (reply.readInt32()); |
| 240 | } |
| 241 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 242 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 243 | int index, |
| 244 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 245 | { |
| 246 | Parcel data, reply; |
| 247 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 248 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 249 | data.writeInt32(index); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 250 | data.writeInt32(static_cast <uint32_t>(device)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 251 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 252 | return static_cast <status_t> (reply.readInt32()); |
| 253 | } |
| 254 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 255 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 256 | int *index, |
| 257 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 258 | { |
| 259 | Parcel data, reply; |
| 260 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 261 | data.writeInt32(static_cast <uint32_t>(stream)); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 262 | data.writeInt32(static_cast <uint32_t>(device)); |
| 263 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 264 | remote()->transact(GET_STREAM_VOLUME, data, &reply); |
| 265 | int lIndex = reply.readInt32(); |
| 266 | if (index) *index = lIndex; |
| 267 | return static_cast <status_t> (reply.readInt32()); |
| 268 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 269 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 270 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 271 | { |
| 272 | Parcel data, reply; |
| 273 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 274 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 275 | remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); |
| 276 | return reply.readInt32(); |
| 277 | } |
| 278 | |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 279 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 280 | { |
| 281 | Parcel data, reply; |
| 282 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 283 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 284 | remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 285 | return (audio_devices_t) reply.readInt32(); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 286 | } |
| 287 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 288 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 289 | { |
| 290 | Parcel data, reply; |
| 291 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 292 | data.write(desc, sizeof(effect_descriptor_t)); |
| 293 | remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); |
| 294 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
| 295 | } |
| 296 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 297 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 298 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 299 | uint32_t strategy, |
| 300 | int session, |
| 301 | int id) |
| 302 | { |
| 303 | Parcel data, reply; |
| 304 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 305 | data.write(desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 306 | data.writeInt32(io); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 307 | data.writeInt32(strategy); |
| 308 | data.writeInt32(session); |
| 309 | data.writeInt32(id); |
| 310 | remote()->transact(REGISTER_EFFECT, data, &reply); |
| 311 | return static_cast <status_t> (reply.readInt32()); |
| 312 | } |
| 313 | |
| 314 | virtual status_t unregisterEffect(int id) |
| 315 | { |
| 316 | Parcel data, reply; |
| 317 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 318 | data.writeInt32(id); |
| 319 | remote()->transact(UNREGISTER_EFFECT, data, &reply); |
| 320 | return static_cast <status_t> (reply.readInt32()); |
| 321 | } |
| 322 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 323 | virtual status_t setEffectEnabled(int id, bool enabled) |
| 324 | { |
| 325 | Parcel data, reply; |
| 326 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 327 | data.writeInt32(id); |
| 328 | data.writeInt32(enabled); |
| 329 | remote()->transact(SET_EFFECT_ENABLED, data, &reply); |
| 330 | return static_cast <status_t> (reply.readInt32()); |
| 331 | } |
| 332 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 333 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 334 | { |
| 335 | Parcel data, reply; |
| 336 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 337 | data.writeInt32((int32_t) stream); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 338 | data.writeInt32(inPastMs); |
| 339 | remote()->transact(IS_STREAM_ACTIVE, data, &reply); |
| 340 | return reply.readInt32(); |
| 341 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 342 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 343 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const |
| 344 | { |
| 345 | Parcel data, reply; |
| 346 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 347 | data.writeInt32((int32_t) stream); |
| 348 | data.writeInt32(inPastMs); |
| 349 | remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); |
| 350 | return reply.readInt32(); |
| 351 | } |
| 352 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 353 | virtual bool isSourceActive(audio_source_t source) const |
| 354 | { |
| 355 | Parcel data, reply; |
| 356 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 357 | data.writeInt32((int32_t) source); |
| 358 | remote()->transact(IS_SOURCE_ACTIVE, data, &reply); |
| 359 | return reply.readInt32(); |
| 360 | } |
| 361 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 362 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 363 | effect_descriptor_t *descriptors, |
| 364 | uint32_t *count) |
| 365 | { |
| 366 | if (descriptors == NULL || count == NULL) { |
| 367 | return BAD_VALUE; |
| 368 | } |
| 369 | Parcel data, reply; |
| 370 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 371 | data.writeInt32(audioSession); |
| 372 | data.writeInt32(*count); |
| 373 | status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); |
| 374 | if (status != NO_ERROR) { |
| 375 | return status; |
| 376 | } |
| 377 | status = static_cast <status_t> (reply.readInt32()); |
| 378 | uint32_t retCount = reply.readInt32(); |
| 379 | if (retCount != 0) { |
| 380 | uint32_t numDesc = (retCount < *count) ? retCount : *count; |
| 381 | reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); |
| 382 | } |
| 383 | *count = retCount; |
| 384 | return status; |
| 385 | } |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 386 | |
| 387 | virtual bool isOffloadSupported(const audio_offload_info_t& info) |
| 388 | { |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 389 | Parcel data, reply; |
| 390 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 391 | data.write(&info, sizeof(audio_offload_info_t)); |
| 392 | remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); |
| 393 | return reply.readInt32(); } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); |
| 397 | |
| 398 | // ---------------------------------------------------------------------- |
| 399 | |
| 400 | |
| 401 | status_t BnAudioPolicyService::onTransact( |
| 402 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 403 | { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 404 | switch (code) { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 405 | case SET_DEVICE_CONNECTION_STATE: { |
| 406 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 407 | audio_devices_t device = |
| 408 | static_cast <audio_devices_t>(data.readInt32()); |
| 409 | audio_policy_dev_state_t state = |
| 410 | static_cast <audio_policy_dev_state_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 411 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 412 | reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, |
| 413 | state, |
| 414 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 415 | return NO_ERROR; |
| 416 | } break; |
| 417 | |
| 418 | case GET_DEVICE_CONNECTION_STATE: { |
| 419 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 420 | audio_devices_t device = |
| 421 | static_cast<audio_devices_t> (data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 422 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 423 | reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, |
| 424 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 425 | return NO_ERROR; |
| 426 | } break; |
| 427 | |
| 428 | case SET_PHONE_STATE: { |
| 429 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 430 | reply->writeInt32(static_cast <uint32_t>(setPhoneState( |
| 431 | (audio_mode_t) data.readInt32()))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 432 | return NO_ERROR; |
| 433 | } break; |
| 434 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 435 | case SET_FORCE_USE: { |
| 436 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 437 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 438 | data.readInt32()); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 439 | audio_policy_forced_cfg_t config = |
| 440 | static_cast <audio_policy_forced_cfg_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 441 | reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); |
| 442 | return NO_ERROR; |
| 443 | } break; |
| 444 | |
| 445 | case GET_FORCE_USE: { |
| 446 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 447 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 448 | data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 449 | reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); |
| 450 | return NO_ERROR; |
| 451 | } break; |
| 452 | |
| 453 | case GET_OUTPUT: { |
| 454 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 455 | audio_stream_type_t stream = |
| 456 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 457 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 458 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 459 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 460 | audio_output_flags_t flags = |
| 461 | static_cast <audio_output_flags_t>(data.readInt32()); |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 462 | bool hasOffloadInfo = data.readInt32() != 0; |
| 463 | audio_offload_info_t offloadInfo; |
| 464 | if (hasOffloadInfo) { |
| 465 | data.read(&offloadInfo, sizeof(audio_offload_info_t)); |
| 466 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 467 | audio_io_handle_t output = getOutput(stream, |
| 468 | samplingRate, |
| 469 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 470 | channelMask, |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 471 | flags, |
| 472 | hasOffloadInfo ? &offloadInfo : NULL); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 473 | reply->writeInt32(static_cast <int>(output)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 474 | return NO_ERROR; |
| 475 | } break; |
| 476 | |
| 477 | case START_OUTPUT: { |
| 478 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 479 | audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 480 | audio_stream_type_t stream = |
| 481 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 482 | int session = data.readInt32(); |
| 483 | reply->writeInt32(static_cast <uint32_t>(startOutput(output, |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 484 | stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 485 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 486 | return NO_ERROR; |
| 487 | } break; |
| 488 | |
| 489 | case STOP_OUTPUT: { |
| 490 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 491 | audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 492 | audio_stream_type_t stream = |
| 493 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 494 | int session = data.readInt32(); |
| 495 | reply->writeInt32(static_cast <uint32_t>(stopOutput(output, |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 496 | stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 497 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 498 | return NO_ERROR; |
| 499 | } break; |
| 500 | |
| 501 | case RELEASE_OUTPUT: { |
| 502 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 503 | audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 504 | releaseOutput(output); |
| 505 | return NO_ERROR; |
| 506 | } break; |
| 507 | |
| 508 | case GET_INPUT: { |
| 509 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 510 | audio_source_t inputSource = (audio_source_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 511 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 512 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 513 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 514 | int audioSession = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 515 | audio_io_handle_t input = getInput(inputSource, |
| 516 | samplingRate, |
| 517 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 518 | channelMask, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 519 | audioSession); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 520 | reply->writeInt32(static_cast <int>(input)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 521 | return NO_ERROR; |
| 522 | } break; |
| 523 | |
| 524 | case START_INPUT: { |
| 525 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 526 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 527 | reply->writeInt32(static_cast <uint32_t>(startInput(input))); |
| 528 | return NO_ERROR; |
| 529 | } break; |
| 530 | |
| 531 | case STOP_INPUT: { |
| 532 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 533 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 534 | reply->writeInt32(static_cast <uint32_t>(stopInput(input))); |
| 535 | return NO_ERROR; |
| 536 | } break; |
| 537 | |
| 538 | case RELEASE_INPUT: { |
| 539 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 540 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 541 | releaseInput(input); |
| 542 | return NO_ERROR; |
| 543 | } break; |
| 544 | |
| 545 | case INIT_STREAM_VOLUME: { |
| 546 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 547 | audio_stream_type_t stream = |
| 548 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 549 | int indexMin = data.readInt32(); |
| 550 | int indexMax = data.readInt32(); |
| 551 | reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); |
| 552 | return NO_ERROR; |
| 553 | } break; |
| 554 | |
| 555 | case SET_STREAM_VOLUME: { |
| 556 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 557 | audio_stream_type_t stream = |
| 558 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 559 | int index = data.readInt32(); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 560 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 561 | reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, |
| 562 | index, |
| 563 | device))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 564 | return NO_ERROR; |
| 565 | } break; |
| 566 | |
| 567 | case GET_STREAM_VOLUME: { |
| 568 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 569 | audio_stream_type_t stream = |
| 570 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 571 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 572 | int index; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 573 | status_t status = getStreamVolumeIndex(stream, &index, device); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 574 | reply->writeInt32(index); |
| 575 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 576 | return NO_ERROR; |
| 577 | } break; |
| 578 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 579 | case GET_STRATEGY_FOR_STREAM: { |
| 580 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 581 | audio_stream_type_t stream = |
| 582 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 583 | reply->writeInt32(getStrategyForStream(stream)); |
| 584 | return NO_ERROR; |
| 585 | } break; |
| 586 | |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 587 | case GET_DEVICES_FOR_STREAM: { |
| 588 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 589 | audio_stream_type_t stream = |
| 590 | static_cast <audio_stream_type_t>(data.readInt32()); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 591 | reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); |
| 592 | return NO_ERROR; |
| 593 | } break; |
| 594 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 595 | case GET_OUTPUT_FOR_EFFECT: { |
| 596 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 597 | effect_descriptor_t desc; |
| 598 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 599 | audio_io_handle_t output = getOutputForEffect(&desc); |
| 600 | reply->writeInt32(static_cast <int>(output)); |
| 601 | return NO_ERROR; |
| 602 | } break; |
| 603 | |
| 604 | case REGISTER_EFFECT: { |
| 605 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 606 | effect_descriptor_t desc; |
| 607 | data.read(&desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 608 | audio_io_handle_t io = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 609 | uint32_t strategy = data.readInt32(); |
| 610 | int session = data.readInt32(); |
| 611 | int id = data.readInt32(); |
| 612 | reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 613 | io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 614 | strategy, |
| 615 | session, |
| 616 | id))); |
| 617 | return NO_ERROR; |
| 618 | } break; |
| 619 | |
| 620 | case UNREGISTER_EFFECT: { |
| 621 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 622 | int id = data.readInt32(); |
| 623 | reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); |
| 624 | return NO_ERROR; |
| 625 | } break; |
| 626 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 627 | case SET_EFFECT_ENABLED: { |
| 628 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 629 | int id = data.readInt32(); |
| 630 | bool enabled = static_cast <bool>(data.readInt32()); |
| 631 | reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); |
| 632 | return NO_ERROR; |
| 633 | } break; |
| 634 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 635 | case IS_STREAM_ACTIVE: { |
| 636 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 637 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 638 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 639 | reply->writeInt32( isStreamActive(stream, inPastMs) ); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 640 | return NO_ERROR; |
| 641 | } break; |
| 642 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 643 | case IS_STREAM_ACTIVE_REMOTELY: { |
| 644 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 645 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 646 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 647 | reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 648 | return NO_ERROR; |
| 649 | } break; |
| 650 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 651 | case IS_SOURCE_ACTIVE: { |
| 652 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 653 | audio_source_t source = (audio_source_t) data.readInt32(); |
| 654 | reply->writeInt32( isSourceActive(source)); |
| 655 | return NO_ERROR; |
| 656 | } |
| 657 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 658 | case QUERY_DEFAULT_PRE_PROCESSING: { |
| 659 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 660 | int audioSession = data.readInt32(); |
| 661 | uint32_t count = data.readInt32(); |
| 662 | uint32_t retCount = count; |
| 663 | effect_descriptor_t *descriptors = |
| 664 | (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; |
| 665 | status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); |
| 666 | reply->writeInt32(status); |
| 667 | if (status != NO_ERROR && status != NO_MEMORY) { |
| 668 | retCount = 0; |
| 669 | } |
| 670 | reply->writeInt32(retCount); |
| 671 | if (retCount) { |
| 672 | if (retCount < count) { |
| 673 | count = retCount; |
| 674 | } |
| 675 | reply->write(descriptors, sizeof(effect_descriptor_t) * count); |
| 676 | } |
| 677 | delete[] descriptors; |
| 678 | return status; |
| 679 | } |
| 680 | |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 681 | case IS_OFFLOAD_SUPPORTED: { |
| 682 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 683 | audio_offload_info_t info; |
| 684 | data.read(&info, sizeof(audio_offload_info_t)); |
| 685 | bool isSupported = isOffloadSupported(info); |
| 686 | reply->writeInt32(isSupported); |
| 687 | return NO_ERROR; |
| 688 | } |
| 689 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 690 | default: |
| 691 | return BBinder::onTransact(code, data, reply, flags); |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | // ---------------------------------------------------------------------------- |
| 696 | |
| 697 | }; // namespace android |