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