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