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