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