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)); |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame^] | 140 | if (offloadInfo == NULL) { |
| 141 | data.writeInt32(0); |
| 142 | } else { |
| 143 | data.writeInt32(1); |
| 144 | data.write(offloadInfo, sizeof(audio_offload_info_t)); |
| 145 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 146 | remote()->transact(GET_OUTPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 147 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 150 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 151 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 152 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 153 | { |
| 154 | Parcel data, reply; |
| 155 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 156 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 157 | data.writeInt32((int32_t) stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 158 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 159 | remote()->transact(START_OUTPUT, data, &reply); |
| 160 | return static_cast <status_t> (reply.readInt32()); |
| 161 | } |
| 162 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 163 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 164 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 165 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 166 | { |
| 167 | Parcel data, reply; |
| 168 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 169 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 170 | data.writeInt32((int32_t) stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 171 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 172 | remote()->transact(STOP_OUTPUT, data, &reply); |
| 173 | return static_cast <status_t> (reply.readInt32()); |
| 174 | } |
| 175 | |
| 176 | virtual void releaseOutput(audio_io_handle_t output) |
| 177 | { |
| 178 | Parcel data, reply; |
| 179 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 180 | data.writeInt32(output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 181 | remote()->transact(RELEASE_OUTPUT, data, &reply); |
| 182 | } |
| 183 | |
| 184 | virtual audio_io_handle_t getInput( |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 185 | audio_source_t inputSource, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 186 | uint32_t samplingRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 187 | audio_format_t format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 188 | audio_channel_mask_t channelMask, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 189 | int audioSession) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 190 | { |
| 191 | Parcel data, reply; |
| 192 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 193 | data.writeInt32((int32_t) inputSource); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 194 | data.writeInt32(samplingRate); |
| 195 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 196 | data.writeInt32(channelMask); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 197 | data.writeInt32(audioSession); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 198 | remote()->transact(GET_INPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 199 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | virtual status_t startInput(audio_io_handle_t input) |
| 203 | { |
| 204 | Parcel data, reply; |
| 205 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 206 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 207 | remote()->transact(START_INPUT, data, &reply); |
| 208 | return static_cast <status_t> (reply.readInt32()); |
| 209 | } |
| 210 | |
| 211 | virtual status_t stopInput(audio_io_handle_t input) |
| 212 | { |
| 213 | Parcel data, reply; |
| 214 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 215 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 216 | remote()->transact(STOP_INPUT, data, &reply); |
| 217 | return static_cast <status_t> (reply.readInt32()); |
| 218 | } |
| 219 | |
| 220 | virtual void releaseInput(audio_io_handle_t input) |
| 221 | { |
| 222 | Parcel data, reply; |
| 223 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 224 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 225 | remote()->transact(RELEASE_INPUT, data, &reply); |
| 226 | } |
| 227 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 228 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 229 | int indexMin, |
| 230 | int indexMax) |
| 231 | { |
| 232 | Parcel data, reply; |
| 233 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 234 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 235 | data.writeInt32(indexMin); |
| 236 | data.writeInt32(indexMax); |
| 237 | remote()->transact(INIT_STREAM_VOLUME, data, &reply); |
| 238 | return static_cast <status_t> (reply.readInt32()); |
| 239 | } |
| 240 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 241 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 242 | int index, |
| 243 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 244 | { |
| 245 | Parcel data, reply; |
| 246 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 247 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 248 | data.writeInt32(index); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 249 | data.writeInt32(static_cast <uint32_t>(device)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 250 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 251 | return static_cast <status_t> (reply.readInt32()); |
| 252 | } |
| 253 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 254 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 255 | int *index, |
| 256 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 257 | { |
| 258 | Parcel data, reply; |
| 259 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 260 | data.writeInt32(static_cast <uint32_t>(stream)); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 261 | data.writeInt32(static_cast <uint32_t>(device)); |
| 262 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 263 | remote()->transact(GET_STREAM_VOLUME, data, &reply); |
| 264 | int lIndex = reply.readInt32(); |
| 265 | if (index) *index = lIndex; |
| 266 | return static_cast <status_t> (reply.readInt32()); |
| 267 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 268 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 269 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 270 | { |
| 271 | Parcel data, reply; |
| 272 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 273 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 274 | remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); |
| 275 | return reply.readInt32(); |
| 276 | } |
| 277 | |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 278 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 279 | { |
| 280 | Parcel data, reply; |
| 281 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 282 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 283 | remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 284 | return (audio_devices_t) reply.readInt32(); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 287 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 288 | { |
| 289 | Parcel data, reply; |
| 290 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 291 | data.write(desc, sizeof(effect_descriptor_t)); |
| 292 | remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); |
| 293 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
| 294 | } |
| 295 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 296 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 297 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 298 | uint32_t strategy, |
| 299 | int session, |
| 300 | int id) |
| 301 | { |
| 302 | Parcel data, reply; |
| 303 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 304 | data.write(desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 305 | data.writeInt32(io); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 306 | data.writeInt32(strategy); |
| 307 | data.writeInt32(session); |
| 308 | data.writeInt32(id); |
| 309 | remote()->transact(REGISTER_EFFECT, data, &reply); |
| 310 | return static_cast <status_t> (reply.readInt32()); |
| 311 | } |
| 312 | |
| 313 | virtual status_t unregisterEffect(int id) |
| 314 | { |
| 315 | Parcel data, reply; |
| 316 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 317 | data.writeInt32(id); |
| 318 | remote()->transact(UNREGISTER_EFFECT, data, &reply); |
| 319 | return static_cast <status_t> (reply.readInt32()); |
| 320 | } |
| 321 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 322 | virtual status_t setEffectEnabled(int id, bool enabled) |
| 323 | { |
| 324 | Parcel data, reply; |
| 325 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 326 | data.writeInt32(id); |
| 327 | data.writeInt32(enabled); |
| 328 | remote()->transact(SET_EFFECT_ENABLED, data, &reply); |
| 329 | return static_cast <status_t> (reply.readInt32()); |
| 330 | } |
| 331 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 332 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 333 | { |
| 334 | Parcel data, reply; |
| 335 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 336 | data.writeInt32((int32_t) stream); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 337 | data.writeInt32(inPastMs); |
| 338 | remote()->transact(IS_STREAM_ACTIVE, data, &reply); |
| 339 | return reply.readInt32(); |
| 340 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 341 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 342 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const |
| 343 | { |
| 344 | Parcel data, reply; |
| 345 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 346 | data.writeInt32((int32_t) stream); |
| 347 | data.writeInt32(inPastMs); |
| 348 | remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); |
| 349 | return reply.readInt32(); |
| 350 | } |
| 351 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 352 | virtual bool isSourceActive(audio_source_t source) const |
| 353 | { |
| 354 | Parcel data, reply; |
| 355 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 356 | data.writeInt32((int32_t) source); |
| 357 | remote()->transact(IS_SOURCE_ACTIVE, data, &reply); |
| 358 | return reply.readInt32(); |
| 359 | } |
| 360 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 361 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 362 | effect_descriptor_t *descriptors, |
| 363 | uint32_t *count) |
| 364 | { |
| 365 | if (descriptors == NULL || count == NULL) { |
| 366 | return BAD_VALUE; |
| 367 | } |
| 368 | Parcel data, reply; |
| 369 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 370 | data.writeInt32(audioSession); |
| 371 | data.writeInt32(*count); |
| 372 | status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); |
| 373 | if (status != NO_ERROR) { |
| 374 | return status; |
| 375 | } |
| 376 | status = static_cast <status_t> (reply.readInt32()); |
| 377 | uint32_t retCount = reply.readInt32(); |
| 378 | if (retCount != 0) { |
| 379 | uint32_t numDesc = (retCount < *count) ? retCount : *count; |
| 380 | reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); |
| 381 | } |
| 382 | *count = retCount; |
| 383 | return status; |
| 384 | } |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 385 | |
| 386 | virtual bool isOffloadSupported(const audio_offload_info_t& info) |
| 387 | { |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame^] | 388 | Parcel data, reply; |
| 389 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 390 | data.write(&info, sizeof(audio_offload_info_t)); |
| 391 | remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); |
| 392 | return reply.readInt32(); } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 393 | }; |
| 394 | |
| 395 | IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); |
| 396 | |
| 397 | // ---------------------------------------------------------------------- |
| 398 | |
| 399 | |
| 400 | status_t BnAudioPolicyService::onTransact( |
| 401 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 402 | { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 403 | switch (code) { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 404 | case SET_DEVICE_CONNECTION_STATE: { |
| 405 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 406 | audio_devices_t device = |
| 407 | static_cast <audio_devices_t>(data.readInt32()); |
| 408 | audio_policy_dev_state_t state = |
| 409 | static_cast <audio_policy_dev_state_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 410 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 411 | reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, |
| 412 | state, |
| 413 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 414 | return NO_ERROR; |
| 415 | } break; |
| 416 | |
| 417 | case GET_DEVICE_CONNECTION_STATE: { |
| 418 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 419 | audio_devices_t device = |
| 420 | static_cast<audio_devices_t> (data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 421 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 422 | reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, |
| 423 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 424 | return NO_ERROR; |
| 425 | } break; |
| 426 | |
| 427 | case SET_PHONE_STATE: { |
| 428 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 429 | reply->writeInt32(static_cast <uint32_t>(setPhoneState( |
| 430 | (audio_mode_t) data.readInt32()))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 431 | return NO_ERROR; |
| 432 | } break; |
| 433 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 434 | case SET_FORCE_USE: { |
| 435 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 436 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 437 | data.readInt32()); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 438 | audio_policy_forced_cfg_t config = |
| 439 | static_cast <audio_policy_forced_cfg_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 440 | reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); |
| 441 | return NO_ERROR; |
| 442 | } break; |
| 443 | |
| 444 | case GET_FORCE_USE: { |
| 445 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 446 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 447 | data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 448 | reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); |
| 449 | return NO_ERROR; |
| 450 | } break; |
| 451 | |
| 452 | case GET_OUTPUT: { |
| 453 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 454 | audio_stream_type_t stream = |
| 455 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 456 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 457 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 458 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 459 | audio_output_flags_t flags = |
| 460 | static_cast <audio_output_flags_t>(data.readInt32()); |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame^] | 461 | bool hasOffloadInfo = data.readInt32() != 0; |
| 462 | audio_offload_info_t offloadInfo; |
| 463 | if (hasOffloadInfo) { |
| 464 | data.read(&offloadInfo, sizeof(audio_offload_info_t)); |
| 465 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 466 | audio_io_handle_t output = getOutput(stream, |
| 467 | samplingRate, |
| 468 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 469 | channelMask, |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame^] | 470 | flags, |
| 471 | hasOffloadInfo ? &offloadInfo : NULL); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 472 | reply->writeInt32(static_cast <int>(output)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 473 | return NO_ERROR; |
| 474 | } break; |
| 475 | |
| 476 | case START_OUTPUT: { |
| 477 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 478 | 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] | 479 | uint32_t stream = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 480 | int session = data.readInt32(); |
| 481 | reply->writeInt32(static_cast <uint32_t>(startOutput(output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 482 | (audio_stream_type_t)stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 483 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 484 | return NO_ERROR; |
| 485 | } break; |
| 486 | |
| 487 | case STOP_OUTPUT: { |
| 488 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 489 | 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] | 490 | uint32_t stream = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 491 | int session = data.readInt32(); |
| 492 | reply->writeInt32(static_cast <uint32_t>(stopOutput(output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 493 | (audio_stream_type_t)stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 494 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 495 | return NO_ERROR; |
| 496 | } break; |
| 497 | |
| 498 | case RELEASE_OUTPUT: { |
| 499 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 500 | 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] | 501 | releaseOutput(output); |
| 502 | return NO_ERROR; |
| 503 | } break; |
| 504 | |
| 505 | case GET_INPUT: { |
| 506 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 507 | audio_source_t inputSource = (audio_source_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 508 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 509 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 510 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 511 | int audioSession = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 512 | audio_io_handle_t input = getInput(inputSource, |
| 513 | samplingRate, |
| 514 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 515 | channelMask, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 516 | audioSession); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 517 | reply->writeInt32(static_cast <int>(input)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 518 | return NO_ERROR; |
| 519 | } break; |
| 520 | |
| 521 | case START_INPUT: { |
| 522 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 523 | 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] | 524 | reply->writeInt32(static_cast <uint32_t>(startInput(input))); |
| 525 | return NO_ERROR; |
| 526 | } break; |
| 527 | |
| 528 | case STOP_INPUT: { |
| 529 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 530 | 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] | 531 | reply->writeInt32(static_cast <uint32_t>(stopInput(input))); |
| 532 | return NO_ERROR; |
| 533 | } break; |
| 534 | |
| 535 | case RELEASE_INPUT: { |
| 536 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 537 | 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] | 538 | releaseInput(input); |
| 539 | return NO_ERROR; |
| 540 | } break; |
| 541 | |
| 542 | case INIT_STREAM_VOLUME: { |
| 543 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 544 | audio_stream_type_t stream = |
| 545 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 546 | int indexMin = data.readInt32(); |
| 547 | int indexMax = data.readInt32(); |
| 548 | reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); |
| 549 | return NO_ERROR; |
| 550 | } break; |
| 551 | |
| 552 | case SET_STREAM_VOLUME: { |
| 553 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 554 | audio_stream_type_t stream = |
| 555 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 556 | int index = data.readInt32(); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 557 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 558 | reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, |
| 559 | index, |
| 560 | device))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 561 | return NO_ERROR; |
| 562 | } break; |
| 563 | |
| 564 | case GET_STREAM_VOLUME: { |
| 565 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 566 | audio_stream_type_t stream = |
| 567 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 568 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 569 | int index; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 570 | status_t status = getStreamVolumeIndex(stream, &index, device); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 571 | reply->writeInt32(index); |
| 572 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 573 | return NO_ERROR; |
| 574 | } break; |
| 575 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 576 | case GET_STRATEGY_FOR_STREAM: { |
| 577 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 578 | audio_stream_type_t stream = |
| 579 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 580 | reply->writeInt32(getStrategyForStream(stream)); |
| 581 | return NO_ERROR; |
| 582 | } break; |
| 583 | |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 584 | case GET_DEVICES_FOR_STREAM: { |
| 585 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 586 | audio_stream_type_t stream = |
| 587 | static_cast <audio_stream_type_t>(data.readInt32()); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 588 | reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); |
| 589 | return NO_ERROR; |
| 590 | } break; |
| 591 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 592 | case GET_OUTPUT_FOR_EFFECT: { |
| 593 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 594 | effect_descriptor_t desc; |
| 595 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 596 | audio_io_handle_t output = getOutputForEffect(&desc); |
| 597 | reply->writeInt32(static_cast <int>(output)); |
| 598 | return NO_ERROR; |
| 599 | } break; |
| 600 | |
| 601 | case REGISTER_EFFECT: { |
| 602 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 603 | effect_descriptor_t desc; |
| 604 | data.read(&desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 605 | audio_io_handle_t io = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 606 | uint32_t strategy = data.readInt32(); |
| 607 | int session = data.readInt32(); |
| 608 | int id = data.readInt32(); |
| 609 | reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 610 | io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 611 | strategy, |
| 612 | session, |
| 613 | id))); |
| 614 | return NO_ERROR; |
| 615 | } break; |
| 616 | |
| 617 | case UNREGISTER_EFFECT: { |
| 618 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 619 | int id = data.readInt32(); |
| 620 | reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); |
| 621 | return NO_ERROR; |
| 622 | } break; |
| 623 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 624 | case SET_EFFECT_ENABLED: { |
| 625 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 626 | int id = data.readInt32(); |
| 627 | bool enabled = static_cast <bool>(data.readInt32()); |
| 628 | reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); |
| 629 | return NO_ERROR; |
| 630 | } break; |
| 631 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 632 | case IS_STREAM_ACTIVE: { |
| 633 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 634 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 635 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 636 | reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) ); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 637 | return NO_ERROR; |
| 638 | } break; |
| 639 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 640 | case IS_STREAM_ACTIVE_REMOTELY: { |
| 641 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 642 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 643 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
| 644 | reply->writeInt32( isStreamActiveRemotely((audio_stream_type_t) stream, inPastMs) ); |
| 645 | return NO_ERROR; |
| 646 | } break; |
| 647 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 648 | case IS_SOURCE_ACTIVE: { |
| 649 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 650 | audio_source_t source = (audio_source_t) data.readInt32(); |
| 651 | reply->writeInt32( isSourceActive(source)); |
| 652 | return NO_ERROR; |
| 653 | } |
| 654 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 655 | case QUERY_DEFAULT_PRE_PROCESSING: { |
| 656 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 657 | int audioSession = data.readInt32(); |
| 658 | uint32_t count = data.readInt32(); |
| 659 | uint32_t retCount = count; |
| 660 | effect_descriptor_t *descriptors = |
| 661 | (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; |
| 662 | status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); |
| 663 | reply->writeInt32(status); |
| 664 | if (status != NO_ERROR && status != NO_MEMORY) { |
| 665 | retCount = 0; |
| 666 | } |
| 667 | reply->writeInt32(retCount); |
| 668 | if (retCount) { |
| 669 | if (retCount < count) { |
| 670 | count = retCount; |
| 671 | } |
| 672 | reply->write(descriptors, sizeof(effect_descriptor_t) * count); |
| 673 | } |
| 674 | delete[] descriptors; |
| 675 | return status; |
| 676 | } |
| 677 | |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame^] | 678 | case IS_OFFLOAD_SUPPORTED: { |
| 679 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 680 | audio_offload_info_t info; |
| 681 | data.read(&info, sizeof(audio_offload_info_t)); |
| 682 | bool isSupported = isOffloadSupported(info); |
| 683 | reply->writeInt32(isSupported); |
| 684 | return NO_ERROR; |
| 685 | } |
| 686 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 687 | default: |
| 688 | return BBinder::onTransact(code, data, reply, flags); |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | // ---------------------------------------------------------------------------- |
| 693 | |
| 694 | }; // namespace android |