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, |
| 55 | GET_DEVICES_FOR_STREAM, |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 56 | QUERY_DEFAULT_PRE_PROCESSING, |
| 57 | SET_EFFECT_ENABLED |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | class BpAudioPolicyService : public BpInterface<IAudioPolicyService> |
| 61 | { |
| 62 | public: |
| 63 | BpAudioPolicyService(const sp<IBinder>& impl) |
| 64 | : BpInterface<IAudioPolicyService>(impl) |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | virtual status_t setDeviceConnectionState( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 69 | audio_devices_t device, |
| 70 | audio_policy_dev_state_t state, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 71 | const char *device_address) |
| 72 | { |
| 73 | Parcel data, reply; |
| 74 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 75 | data.writeInt32(static_cast <uint32_t>(device)); |
| 76 | data.writeInt32(static_cast <uint32_t>(state)); |
| 77 | data.writeCString(device_address); |
| 78 | remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); |
| 79 | return static_cast <status_t> (reply.readInt32()); |
| 80 | } |
| 81 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 82 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 83 | audio_devices_t device, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 84 | const char *device_address) |
| 85 | { |
| 86 | Parcel data, reply; |
| 87 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 88 | data.writeInt32(static_cast <uint32_t>(device)); |
| 89 | data.writeCString(device_address); |
| 90 | remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 91 | return static_cast <audio_policy_dev_state_t>(reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 94 | virtual status_t setPhoneState(audio_mode_t state) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 95 | { |
| 96 | Parcel data, reply; |
| 97 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 98 | data.writeInt32(state); |
| 99 | remote()->transact(SET_PHONE_STATE, data, &reply); |
| 100 | return static_cast <status_t> (reply.readInt32()); |
| 101 | } |
| 102 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 103 | 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] | 104 | { |
| 105 | Parcel data, reply; |
| 106 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 107 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 108 | data.writeInt32(static_cast <uint32_t>(config)); |
| 109 | remote()->transact(SET_FORCE_USE, data, &reply); |
| 110 | return static_cast <status_t> (reply.readInt32()); |
| 111 | } |
| 112 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 113 | 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] | 114 | { |
| 115 | Parcel data, reply; |
| 116 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 117 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 118 | remote()->transact(GET_FORCE_USE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 119 | return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | virtual audio_io_handle_t getOutput( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 123 | audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 124 | uint32_t samplingRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 125 | audio_format_t format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 126 | audio_channel_mask_t channelMask, |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 127 | audio_output_flags_t flags) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 128 | { |
| 129 | Parcel data, reply; |
| 130 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 131 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 132 | data.writeInt32(samplingRate); |
| 133 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 134 | data.writeInt32(channelMask); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 135 | data.writeInt32(static_cast <uint32_t>(flags)); |
| 136 | remote()->transact(GET_OUTPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 137 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 140 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 141 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 142 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 143 | { |
| 144 | Parcel data, reply; |
| 145 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 146 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 147 | data.writeInt32((int32_t) stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 148 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 149 | remote()->transact(START_OUTPUT, data, &reply); |
| 150 | return static_cast <status_t> (reply.readInt32()); |
| 151 | } |
| 152 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 153 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 154 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 155 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 156 | { |
| 157 | Parcel data, reply; |
| 158 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 159 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 160 | data.writeInt32((int32_t) stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 161 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 162 | remote()->transact(STOP_OUTPUT, data, &reply); |
| 163 | return static_cast <status_t> (reply.readInt32()); |
| 164 | } |
| 165 | |
| 166 | virtual void releaseOutput(audio_io_handle_t output) |
| 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); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 171 | remote()->transact(RELEASE_OUTPUT, data, &reply); |
| 172 | } |
| 173 | |
| 174 | virtual audio_io_handle_t getInput( |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 175 | audio_source_t inputSource, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 176 | uint32_t samplingRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 177 | audio_format_t format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 178 | audio_channel_mask_t channelMask, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 179 | int audioSession) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 180 | { |
| 181 | Parcel data, reply; |
| 182 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 183 | data.writeInt32((int32_t) inputSource); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 184 | data.writeInt32(samplingRate); |
| 185 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 186 | data.writeInt32(channelMask); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 187 | data.writeInt32(audioSession); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 188 | remote()->transact(GET_INPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 189 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | virtual status_t startInput(audio_io_handle_t input) |
| 193 | { |
| 194 | Parcel data, reply; |
| 195 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 196 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 197 | remote()->transact(START_INPUT, data, &reply); |
| 198 | return static_cast <status_t> (reply.readInt32()); |
| 199 | } |
| 200 | |
| 201 | virtual status_t stopInput(audio_io_handle_t input) |
| 202 | { |
| 203 | Parcel data, reply; |
| 204 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 205 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 206 | remote()->transact(STOP_INPUT, data, &reply); |
| 207 | return static_cast <status_t> (reply.readInt32()); |
| 208 | } |
| 209 | |
| 210 | virtual void releaseInput(audio_io_handle_t input) |
| 211 | { |
| 212 | Parcel data, reply; |
| 213 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 214 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 215 | remote()->transact(RELEASE_INPUT, data, &reply); |
| 216 | } |
| 217 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 218 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 219 | int indexMin, |
| 220 | int indexMax) |
| 221 | { |
| 222 | Parcel data, reply; |
| 223 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 224 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 225 | data.writeInt32(indexMin); |
| 226 | data.writeInt32(indexMax); |
| 227 | remote()->transact(INIT_STREAM_VOLUME, data, &reply); |
| 228 | return static_cast <status_t> (reply.readInt32()); |
| 229 | } |
| 230 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 231 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 232 | int index, |
| 233 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 234 | { |
| 235 | Parcel data, reply; |
| 236 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 237 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 238 | data.writeInt32(index); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 239 | data.writeInt32(static_cast <uint32_t>(device)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 240 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 241 | return static_cast <status_t> (reply.readInt32()); |
| 242 | } |
| 243 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 244 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 245 | int *index, |
| 246 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 247 | { |
| 248 | Parcel data, reply; |
| 249 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 250 | data.writeInt32(static_cast <uint32_t>(stream)); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 251 | data.writeInt32(static_cast <uint32_t>(device)); |
| 252 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 253 | remote()->transact(GET_STREAM_VOLUME, data, &reply); |
| 254 | int lIndex = reply.readInt32(); |
| 255 | if (index) *index = lIndex; |
| 256 | return static_cast <status_t> (reply.readInt32()); |
| 257 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 258 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 259 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 260 | { |
| 261 | Parcel data, reply; |
| 262 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 263 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 264 | remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); |
| 265 | return reply.readInt32(); |
| 266 | } |
| 267 | |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 268 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 269 | { |
| 270 | Parcel data, reply; |
| 271 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 272 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 273 | remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 274 | return (audio_devices_t) reply.readInt32(); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame^] | 277 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 278 | { |
| 279 | Parcel data, reply; |
| 280 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 281 | data.write(desc, sizeof(effect_descriptor_t)); |
| 282 | remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); |
| 283 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
| 284 | } |
| 285 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame^] | 286 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 287 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 288 | uint32_t strategy, |
| 289 | int session, |
| 290 | int id) |
| 291 | { |
| 292 | Parcel data, reply; |
| 293 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 294 | data.write(desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 295 | data.writeInt32(io); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 296 | data.writeInt32(strategy); |
| 297 | data.writeInt32(session); |
| 298 | data.writeInt32(id); |
| 299 | remote()->transact(REGISTER_EFFECT, data, &reply); |
| 300 | return static_cast <status_t> (reply.readInt32()); |
| 301 | } |
| 302 | |
| 303 | virtual status_t unregisterEffect(int id) |
| 304 | { |
| 305 | Parcel data, reply; |
| 306 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 307 | data.writeInt32(id); |
| 308 | remote()->transact(UNREGISTER_EFFECT, data, &reply); |
| 309 | return static_cast <status_t> (reply.readInt32()); |
| 310 | } |
| 311 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 312 | virtual status_t setEffectEnabled(int id, bool enabled) |
| 313 | { |
| 314 | Parcel data, reply; |
| 315 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 316 | data.writeInt32(id); |
| 317 | data.writeInt32(enabled); |
| 318 | remote()->transact(SET_EFFECT_ENABLED, data, &reply); |
| 319 | return static_cast <status_t> (reply.readInt32()); |
| 320 | } |
| 321 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 322 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 323 | { |
| 324 | Parcel data, reply; |
| 325 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 326 | data.writeInt32((int32_t) stream); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 327 | data.writeInt32(inPastMs); |
| 328 | remote()->transact(IS_STREAM_ACTIVE, data, &reply); |
| 329 | return reply.readInt32(); |
| 330 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 331 | |
| 332 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 333 | effect_descriptor_t *descriptors, |
| 334 | uint32_t *count) |
| 335 | { |
| 336 | if (descriptors == NULL || count == NULL) { |
| 337 | return BAD_VALUE; |
| 338 | } |
| 339 | Parcel data, reply; |
| 340 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 341 | data.writeInt32(audioSession); |
| 342 | data.writeInt32(*count); |
| 343 | status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); |
| 344 | if (status != NO_ERROR) { |
| 345 | return status; |
| 346 | } |
| 347 | status = static_cast <status_t> (reply.readInt32()); |
| 348 | uint32_t retCount = reply.readInt32(); |
| 349 | if (retCount != 0) { |
| 350 | uint32_t numDesc = (retCount < *count) ? retCount : *count; |
| 351 | reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); |
| 352 | } |
| 353 | *count = retCount; |
| 354 | return status; |
| 355 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); |
| 359 | |
| 360 | // ---------------------------------------------------------------------- |
| 361 | |
| 362 | |
| 363 | status_t BnAudioPolicyService::onTransact( |
| 364 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 365 | { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 366 | switch (code) { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 367 | case SET_DEVICE_CONNECTION_STATE: { |
| 368 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 369 | audio_devices_t device = |
| 370 | static_cast <audio_devices_t>(data.readInt32()); |
| 371 | audio_policy_dev_state_t state = |
| 372 | static_cast <audio_policy_dev_state_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 373 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 374 | reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, |
| 375 | state, |
| 376 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 377 | return NO_ERROR; |
| 378 | } break; |
| 379 | |
| 380 | case GET_DEVICE_CONNECTION_STATE: { |
| 381 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 382 | audio_devices_t device = |
| 383 | static_cast<audio_devices_t> (data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 384 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 385 | reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, |
| 386 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 387 | return NO_ERROR; |
| 388 | } break; |
| 389 | |
| 390 | case SET_PHONE_STATE: { |
| 391 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 392 | reply->writeInt32(static_cast <uint32_t>(setPhoneState((audio_mode_t) data.readInt32()))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 393 | return NO_ERROR; |
| 394 | } break; |
| 395 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 396 | case SET_FORCE_USE: { |
| 397 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 398 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); |
| 399 | audio_policy_forced_cfg_t config = |
| 400 | static_cast <audio_policy_forced_cfg_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 401 | reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); |
| 402 | return NO_ERROR; |
| 403 | } break; |
| 404 | |
| 405 | case GET_FORCE_USE: { |
| 406 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 407 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 408 | reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); |
| 409 | return NO_ERROR; |
| 410 | } break; |
| 411 | |
| 412 | case GET_OUTPUT: { |
| 413 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 414 | audio_stream_type_t stream = |
| 415 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 416 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 417 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 418 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 419 | audio_output_flags_t flags = |
| 420 | static_cast <audio_output_flags_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 421 | |
| 422 | audio_io_handle_t output = getOutput(stream, |
| 423 | samplingRate, |
| 424 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 425 | channelMask, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 426 | flags); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 427 | reply->writeInt32(static_cast <int>(output)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 428 | return NO_ERROR; |
| 429 | } break; |
| 430 | |
| 431 | case START_OUTPUT: { |
| 432 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 433 | 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] | 434 | uint32_t stream = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 435 | int session = data.readInt32(); |
| 436 | reply->writeInt32(static_cast <uint32_t>(startOutput(output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 437 | (audio_stream_type_t)stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 438 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 439 | return NO_ERROR; |
| 440 | } break; |
| 441 | |
| 442 | case STOP_OUTPUT: { |
| 443 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 444 | 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] | 445 | uint32_t stream = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 446 | int session = data.readInt32(); |
| 447 | reply->writeInt32(static_cast <uint32_t>(stopOutput(output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 448 | (audio_stream_type_t)stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 449 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 450 | return NO_ERROR; |
| 451 | } break; |
| 452 | |
| 453 | case RELEASE_OUTPUT: { |
| 454 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 455 | 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] | 456 | releaseOutput(output); |
| 457 | return NO_ERROR; |
| 458 | } break; |
| 459 | |
| 460 | case GET_INPUT: { |
| 461 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 462 | audio_source_t inputSource = (audio_source_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 463 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 464 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 465 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 466 | int audioSession = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 467 | audio_io_handle_t input = getInput(inputSource, |
| 468 | samplingRate, |
| 469 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 470 | channelMask, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 471 | audioSession); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 472 | reply->writeInt32(static_cast <int>(input)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 473 | return NO_ERROR; |
| 474 | } break; |
| 475 | |
| 476 | case START_INPUT: { |
| 477 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 478 | 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] | 479 | reply->writeInt32(static_cast <uint32_t>(startInput(input))); |
| 480 | return NO_ERROR; |
| 481 | } break; |
| 482 | |
| 483 | case STOP_INPUT: { |
| 484 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 485 | 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] | 486 | reply->writeInt32(static_cast <uint32_t>(stopInput(input))); |
| 487 | return NO_ERROR; |
| 488 | } break; |
| 489 | |
| 490 | case RELEASE_INPUT: { |
| 491 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 492 | 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] | 493 | releaseInput(input); |
| 494 | return NO_ERROR; |
| 495 | } break; |
| 496 | |
| 497 | case INIT_STREAM_VOLUME: { |
| 498 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 499 | audio_stream_type_t stream = |
| 500 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 501 | int indexMin = data.readInt32(); |
| 502 | int indexMax = data.readInt32(); |
| 503 | reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); |
| 504 | return NO_ERROR; |
| 505 | } break; |
| 506 | |
| 507 | case SET_STREAM_VOLUME: { |
| 508 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 509 | audio_stream_type_t stream = |
| 510 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 511 | int index = data.readInt32(); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 512 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 513 | reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, |
| 514 | index, |
| 515 | device))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 516 | return NO_ERROR; |
| 517 | } break; |
| 518 | |
| 519 | case GET_STREAM_VOLUME: { |
| 520 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 521 | audio_stream_type_t stream = |
| 522 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 523 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 524 | int index; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 525 | status_t status = getStreamVolumeIndex(stream, &index, device); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 526 | reply->writeInt32(index); |
| 527 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 528 | return NO_ERROR; |
| 529 | } break; |
| 530 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 531 | case GET_STRATEGY_FOR_STREAM: { |
| 532 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 533 | audio_stream_type_t stream = |
| 534 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 535 | reply->writeInt32(getStrategyForStream(stream)); |
| 536 | return NO_ERROR; |
| 537 | } break; |
| 538 | |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 539 | case GET_DEVICES_FOR_STREAM: { |
| 540 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 541 | audio_stream_type_t stream = |
| 542 | static_cast <audio_stream_type_t>(data.readInt32()); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 543 | reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); |
| 544 | return NO_ERROR; |
| 545 | } break; |
| 546 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 547 | case GET_OUTPUT_FOR_EFFECT: { |
| 548 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 549 | effect_descriptor_t desc; |
| 550 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 551 | audio_io_handle_t output = getOutputForEffect(&desc); |
| 552 | reply->writeInt32(static_cast <int>(output)); |
| 553 | return NO_ERROR; |
| 554 | } break; |
| 555 | |
| 556 | case REGISTER_EFFECT: { |
| 557 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 558 | effect_descriptor_t desc; |
| 559 | data.read(&desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 560 | audio_io_handle_t io = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 561 | uint32_t strategy = data.readInt32(); |
| 562 | int session = data.readInt32(); |
| 563 | int id = data.readInt32(); |
| 564 | reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 565 | io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 566 | strategy, |
| 567 | session, |
| 568 | id))); |
| 569 | return NO_ERROR; |
| 570 | } break; |
| 571 | |
| 572 | case UNREGISTER_EFFECT: { |
| 573 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 574 | int id = data.readInt32(); |
| 575 | reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); |
| 576 | return NO_ERROR; |
| 577 | } break; |
| 578 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 579 | case SET_EFFECT_ENABLED: { |
| 580 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 581 | int id = data.readInt32(); |
| 582 | bool enabled = static_cast <bool>(data.readInt32()); |
| 583 | reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); |
| 584 | return NO_ERROR; |
| 585 | } break; |
| 586 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 587 | case IS_STREAM_ACTIVE: { |
| 588 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 589 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 590 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 591 | reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) ); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 592 | return NO_ERROR; |
| 593 | } break; |
| 594 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 595 | case QUERY_DEFAULT_PRE_PROCESSING: { |
| 596 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 597 | int audioSession = data.readInt32(); |
| 598 | uint32_t count = data.readInt32(); |
| 599 | uint32_t retCount = count; |
| 600 | effect_descriptor_t *descriptors = |
| 601 | (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; |
| 602 | status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); |
| 603 | reply->writeInt32(status); |
| 604 | if (status != NO_ERROR && status != NO_MEMORY) { |
| 605 | retCount = 0; |
| 606 | } |
| 607 | reply->writeInt32(retCount); |
| 608 | if (retCount) { |
| 609 | if (retCount < count) { |
| 610 | count = retCount; |
| 611 | } |
| 612 | reply->write(descriptors, sizeof(effect_descriptor_t) * count); |
| 613 | } |
| 614 | delete[] descriptors; |
| 615 | return status; |
| 616 | } |
| 617 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 618 | default: |
| 619 | return BBinder::onTransact(code, data, reply, flags); |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | // ---------------------------------------------------------------------------- |
| 624 | |
| 625 | }; // namespace android |