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 | 74adca9 | 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, |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 44 | GET_INPUT_FOR_ATTR, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 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, |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 61 | IS_OFFLOAD_SUPPORTED, |
| 62 | LIST_AUDIO_PORTS, |
| 63 | GET_AUDIO_PORT, |
| 64 | CREATE_AUDIO_PATCH, |
| 65 | RELEASE_AUDIO_PATCH, |
| 66 | LIST_AUDIO_PATCHES, |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 67 | SET_AUDIO_PORT_CONFIG, |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 68 | REGISTER_CLIENT, |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 69 | GET_OUTPUT_FOR_ATTR, |
| 70 | ACQUIRE_SOUNDTRIGGER_SESSION, |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 71 | RELEASE_SOUNDTRIGGER_SESSION, |
| 72 | GET_PHONE_STATE |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | class BpAudioPolicyService : public BpInterface<IAudioPolicyService> |
| 76 | { |
| 77 | public: |
| 78 | BpAudioPolicyService(const sp<IBinder>& impl) |
| 79 | : BpInterface<IAudioPolicyService>(impl) |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | virtual status_t setDeviceConnectionState( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 84 | audio_devices_t device, |
| 85 | audio_policy_dev_state_t state, |
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.writeInt32(static_cast <uint32_t>(state)); |
| 92 | data.writeCString(device_address); |
| 93 | remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); |
| 94 | return static_cast <status_t> (reply.readInt32()); |
| 95 | } |
| 96 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 97 | virtual audio_policy_dev_state_t getDeviceConnectionState( |
| 98 | audio_devices_t device, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 99 | const char *device_address) |
| 100 | { |
| 101 | Parcel data, reply; |
| 102 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 103 | data.writeInt32(static_cast <uint32_t>(device)); |
| 104 | data.writeCString(device_address); |
| 105 | remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 106 | return static_cast <audio_policy_dev_state_t>(reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 109 | virtual status_t setPhoneState(audio_mode_t state) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 110 | { |
| 111 | Parcel data, reply; |
| 112 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 113 | data.writeInt32(state); |
| 114 | remote()->transact(SET_PHONE_STATE, data, &reply); |
| 115 | return static_cast <status_t> (reply.readInt32()); |
| 116 | } |
| 117 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 118 | 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] | 119 | { |
| 120 | Parcel data, reply; |
| 121 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 122 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 123 | data.writeInt32(static_cast <uint32_t>(config)); |
| 124 | remote()->transact(SET_FORCE_USE, data, &reply); |
| 125 | return static_cast <status_t> (reply.readInt32()); |
| 126 | } |
| 127 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 128 | 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] | 129 | { |
| 130 | Parcel data, reply; |
| 131 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 132 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 133 | remote()->transact(GET_FORCE_USE, data, &reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 134 | return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | virtual audio_io_handle_t getOutput( |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 138 | audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 139 | uint32_t samplingRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 140 | audio_format_t format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 141 | audio_channel_mask_t channelMask, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 142 | audio_output_flags_t flags, |
| 143 | const audio_offload_info_t *offloadInfo) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 144 | { |
| 145 | Parcel data, reply; |
| 146 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 147 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 148 | data.writeInt32(samplingRate); |
| 149 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 150 | data.writeInt32(channelMask); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 151 | data.writeInt32(static_cast <uint32_t>(flags)); |
Glenn Kasten | 2301acc | 2014-01-17 10:21:00 -0800 | [diff] [blame] | 152 | // hasOffloadInfo |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 153 | if (offloadInfo == NULL) { |
| 154 | data.writeInt32(0); |
| 155 | } else { |
| 156 | data.writeInt32(1); |
| 157 | data.write(offloadInfo, sizeof(audio_offload_info_t)); |
| 158 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 159 | remote()->transact(GET_OUTPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 160 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 163 | virtual status_t getOutputForAttr(const audio_attributes_t *attr, |
| 164 | audio_io_handle_t *output, |
| 165 | audio_session_t session, |
| 166 | audio_stream_type_t *stream, |
| 167 | uint32_t samplingRate, |
| 168 | audio_format_t format, |
| 169 | audio_channel_mask_t channelMask, |
| 170 | audio_output_flags_t flags, |
| 171 | const audio_offload_info_t *offloadInfo) |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 172 | { |
| 173 | Parcel data, reply; |
| 174 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 175 | if (attr == NULL) { |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 176 | if (stream == NULL) { |
| 177 | ALOGE("getOutputForAttr(): NULL audio attributes and stream type"); |
| 178 | return BAD_VALUE; |
| 179 | } |
| 180 | if (*stream == AUDIO_STREAM_DEFAULT) { |
| 181 | ALOGE("getOutputForAttr unspecified stream type"); |
| 182 | return BAD_VALUE; |
| 183 | } |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 184 | } |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 185 | if (output == NULL) { |
| 186 | ALOGE("getOutputForAttr NULL output - shouldn't happen"); |
| 187 | return BAD_VALUE; |
| 188 | } |
| 189 | if (attr == NULL) { |
| 190 | data.writeInt32(0); |
| 191 | } else { |
| 192 | data.writeInt32(1); |
| 193 | data.write(attr, sizeof(audio_attributes_t)); |
| 194 | } |
| 195 | data.writeInt32(session); |
| 196 | if (stream == NULL) { |
| 197 | data.writeInt32(0); |
| 198 | } else { |
| 199 | data.writeInt32(1); |
| 200 | data.writeInt32(*stream); |
| 201 | } |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 202 | data.writeInt32(samplingRate); |
| 203 | data.writeInt32(static_cast <uint32_t>(format)); |
| 204 | data.writeInt32(channelMask); |
| 205 | data.writeInt32(static_cast <uint32_t>(flags)); |
| 206 | // hasOffloadInfo |
| 207 | if (offloadInfo == NULL) { |
| 208 | data.writeInt32(0); |
| 209 | } else { |
| 210 | data.writeInt32(1); |
| 211 | data.write(offloadInfo, sizeof(audio_offload_info_t)); |
| 212 | } |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 213 | status_t status = remote()->transact(GET_OUTPUT_FOR_ATTR, data, &reply); |
| 214 | if (status != NO_ERROR) { |
| 215 | return status; |
| 216 | } |
| 217 | status = (status_t)reply.readInt32(); |
| 218 | if (status != NO_ERROR) { |
| 219 | return status; |
| 220 | } |
| 221 | *output = (audio_io_handle_t)reply.readInt32(); |
| 222 | if (stream != NULL) { |
| 223 | *stream = (audio_stream_type_t)reply.readInt32(); |
| 224 | } |
| 225 | return status; |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 228 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 229 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 230 | audio_session_t session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 231 | { |
| 232 | Parcel data, reply; |
| 233 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 234 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 235 | data.writeInt32((int32_t) stream); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 236 | data.writeInt32((int32_t)session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 237 | remote()->transact(START_OUTPUT, data, &reply); |
| 238 | return static_cast <status_t> (reply.readInt32()); |
| 239 | } |
| 240 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 241 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 242 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 243 | audio_session_t session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 244 | { |
| 245 | Parcel data, reply; |
| 246 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 247 | data.writeInt32(output); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 248 | data.writeInt32((int32_t) stream); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 249 | data.writeInt32((int32_t)session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 250 | remote()->transact(STOP_OUTPUT, data, &reply); |
| 251 | return static_cast <status_t> (reply.readInt32()); |
| 252 | } |
| 253 | |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 254 | virtual void releaseOutput(audio_io_handle_t output, |
| 255 | audio_stream_type_t stream, |
| 256 | audio_session_t session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 257 | { |
| 258 | Parcel data, reply; |
| 259 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 260 | data.writeInt32(output); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 261 | data.writeInt32((int32_t)stream); |
| 262 | data.writeInt32((int32_t)session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 263 | remote()->transact(RELEASE_OUTPUT, data, &reply); |
| 264 | } |
| 265 | |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 266 | virtual status_t getInputForAttr(const audio_attributes_t *attr, |
| 267 | audio_io_handle_t *input, |
| 268 | audio_session_t session, |
| 269 | uint32_t samplingRate, |
| 270 | audio_format_t format, |
| 271 | audio_channel_mask_t channelMask, |
| 272 | audio_input_flags_t flags) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 273 | { |
| 274 | Parcel data, reply; |
| 275 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 276 | if (attr == NULL) { |
| 277 | ALOGE("getInputForAttr NULL attr - shouldn't happen"); |
| 278 | return BAD_VALUE; |
| 279 | } |
| 280 | if (input == NULL) { |
| 281 | ALOGE("getInputForAttr NULL input - shouldn't happen"); |
| 282 | return BAD_VALUE; |
| 283 | } |
| 284 | data.write(attr, sizeof(audio_attributes_t)); |
| 285 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 286 | data.writeInt32(samplingRate); |
| 287 | data.writeInt32(static_cast <uint32_t>(format)); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 288 | data.writeInt32(channelMask); |
Glenn Kasten | b3b1660 | 2014-07-16 08:36:31 -0700 | [diff] [blame] | 289 | data.writeInt32(flags); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 290 | status_t status = remote()->transact(GET_INPUT_FOR_ATTR, data, &reply); |
| 291 | if (status != NO_ERROR) { |
| 292 | return status; |
| 293 | } |
| 294 | status = reply.readInt32(); |
| 295 | if (status != NO_ERROR) { |
| 296 | return status; |
| 297 | } |
| 298 | *input = (audio_io_handle_t)reply.readInt32(); |
| 299 | return NO_ERROR; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 300 | } |
| 301 | |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 302 | virtual status_t startInput(audio_io_handle_t input, |
| 303 | audio_session_t session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 304 | { |
| 305 | Parcel data, reply; |
| 306 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 307 | data.writeInt32(input); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 308 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 309 | remote()->transact(START_INPUT, data, &reply); |
| 310 | return static_cast <status_t> (reply.readInt32()); |
| 311 | } |
| 312 | |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 313 | virtual status_t stopInput(audio_io_handle_t input, |
| 314 | audio_session_t session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 315 | { |
| 316 | Parcel data, reply; |
| 317 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 318 | data.writeInt32(input); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 319 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 320 | remote()->transact(STOP_INPUT, data, &reply); |
| 321 | return static_cast <status_t> (reply.readInt32()); |
| 322 | } |
| 323 | |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 324 | virtual void releaseInput(audio_io_handle_t input, |
| 325 | audio_session_t session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 326 | { |
| 327 | Parcel data, reply; |
| 328 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 329 | data.writeInt32(input); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 330 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 331 | remote()->transact(RELEASE_INPUT, data, &reply); |
| 332 | } |
| 333 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 334 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 335 | int indexMin, |
| 336 | int indexMax) |
| 337 | { |
| 338 | Parcel data, reply; |
| 339 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 340 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 341 | data.writeInt32(indexMin); |
| 342 | data.writeInt32(indexMax); |
| 343 | remote()->transact(INIT_STREAM_VOLUME, data, &reply); |
| 344 | return static_cast <status_t> (reply.readInt32()); |
| 345 | } |
| 346 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 347 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 348 | int index, |
| 349 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 350 | { |
| 351 | Parcel data, reply; |
| 352 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 353 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 354 | data.writeInt32(index); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 355 | data.writeInt32(static_cast <uint32_t>(device)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 356 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 357 | return static_cast <status_t> (reply.readInt32()); |
| 358 | } |
| 359 | |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 360 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 361 | int *index, |
| 362 | audio_devices_t device) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 363 | { |
| 364 | Parcel data, reply; |
| 365 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 366 | data.writeInt32(static_cast <uint32_t>(stream)); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 367 | data.writeInt32(static_cast <uint32_t>(device)); |
| 368 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 369 | remote()->transact(GET_STREAM_VOLUME, data, &reply); |
| 370 | int lIndex = reply.readInt32(); |
| 371 | if (index) *index = lIndex; |
| 372 | return static_cast <status_t> (reply.readInt32()); |
| 373 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 374 | |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 375 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 376 | { |
| 377 | Parcel data, reply; |
| 378 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 379 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 380 | remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); |
| 381 | return reply.readInt32(); |
| 382 | } |
| 383 | |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 384 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 385 | { |
| 386 | Parcel data, reply; |
| 387 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 388 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 389 | remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 390 | return (audio_devices_t) reply.readInt32(); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 393 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 394 | { |
| 395 | Parcel data, reply; |
| 396 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 397 | data.write(desc, sizeof(effect_descriptor_t)); |
| 398 | remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); |
| 399 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
| 400 | } |
| 401 | |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 402 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 403 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 404 | uint32_t strategy, |
| 405 | int session, |
| 406 | int id) |
| 407 | { |
| 408 | Parcel data, reply; |
| 409 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 410 | data.write(desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 411 | data.writeInt32(io); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 412 | data.writeInt32(strategy); |
| 413 | data.writeInt32(session); |
| 414 | data.writeInt32(id); |
| 415 | remote()->transact(REGISTER_EFFECT, data, &reply); |
| 416 | return static_cast <status_t> (reply.readInt32()); |
| 417 | } |
| 418 | |
| 419 | virtual status_t unregisterEffect(int id) |
| 420 | { |
| 421 | Parcel data, reply; |
| 422 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 423 | data.writeInt32(id); |
| 424 | remote()->transact(UNREGISTER_EFFECT, data, &reply); |
| 425 | return static_cast <status_t> (reply.readInt32()); |
| 426 | } |
| 427 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 428 | virtual status_t setEffectEnabled(int id, bool enabled) |
| 429 | { |
| 430 | Parcel data, reply; |
| 431 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 432 | data.writeInt32(id); |
| 433 | data.writeInt32(enabled); |
| 434 | remote()->transact(SET_EFFECT_ENABLED, data, &reply); |
| 435 | return static_cast <status_t> (reply.readInt32()); |
| 436 | } |
| 437 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 438 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 439 | { |
| 440 | Parcel data, reply; |
| 441 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 442 | data.writeInt32((int32_t) stream); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 443 | data.writeInt32(inPastMs); |
| 444 | remote()->transact(IS_STREAM_ACTIVE, data, &reply); |
| 445 | return reply.readInt32(); |
| 446 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 447 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 448 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const |
| 449 | { |
| 450 | Parcel data, reply; |
| 451 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 452 | data.writeInt32((int32_t) stream); |
| 453 | data.writeInt32(inPastMs); |
| 454 | remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); |
| 455 | return reply.readInt32(); |
| 456 | } |
| 457 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 458 | virtual bool isSourceActive(audio_source_t source) const |
| 459 | { |
| 460 | Parcel data, reply; |
| 461 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 462 | data.writeInt32((int32_t) source); |
| 463 | remote()->transact(IS_SOURCE_ACTIVE, data, &reply); |
| 464 | return reply.readInt32(); |
| 465 | } |
| 466 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 467 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 468 | effect_descriptor_t *descriptors, |
| 469 | uint32_t *count) |
| 470 | { |
| 471 | if (descriptors == NULL || count == NULL) { |
| 472 | return BAD_VALUE; |
| 473 | } |
| 474 | Parcel data, reply; |
| 475 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 476 | data.writeInt32(audioSession); |
| 477 | data.writeInt32(*count); |
| 478 | status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); |
| 479 | if (status != NO_ERROR) { |
| 480 | return status; |
| 481 | } |
| 482 | status = static_cast <status_t> (reply.readInt32()); |
| 483 | uint32_t retCount = reply.readInt32(); |
| 484 | if (retCount != 0) { |
| 485 | uint32_t numDesc = (retCount < *count) ? retCount : *count; |
| 486 | reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); |
| 487 | } |
| 488 | *count = retCount; |
| 489 | return status; |
| 490 | } |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 491 | |
| 492 | virtual bool isOffloadSupported(const audio_offload_info_t& info) |
| 493 | { |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 494 | Parcel data, reply; |
| 495 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 496 | data.write(&info, sizeof(audio_offload_info_t)); |
| 497 | remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 498 | return reply.readInt32(); |
| 499 | } |
| 500 | |
| 501 | virtual status_t listAudioPorts(audio_port_role_t role, |
| 502 | audio_port_type_t type, |
| 503 | unsigned int *num_ports, |
| 504 | struct audio_port *ports, |
| 505 | unsigned int *generation) |
| 506 | { |
| 507 | if (num_ports == NULL || (*num_ports != 0 && ports == NULL) || |
| 508 | generation == NULL) { |
| 509 | return BAD_VALUE; |
| 510 | } |
| 511 | Parcel data, reply; |
| 512 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 513 | unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports; |
| 514 | data.writeInt32(role); |
| 515 | data.writeInt32(type); |
| 516 | data.writeInt32(numPortsReq); |
| 517 | status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); |
| 518 | if (status == NO_ERROR) { |
| 519 | status = (status_t)reply.readInt32(); |
| 520 | *num_ports = (unsigned int)reply.readInt32(); |
| 521 | } |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 522 | if (status == NO_ERROR) { |
| 523 | if (numPortsReq > *num_ports) { |
| 524 | numPortsReq = *num_ports; |
| 525 | } |
| 526 | if (numPortsReq > 0) { |
| 527 | reply.read(ports, numPortsReq * sizeof(struct audio_port)); |
| 528 | } |
| 529 | *generation = reply.readInt32(); |
| 530 | } |
| 531 | return status; |
| 532 | } |
| 533 | |
| 534 | virtual status_t getAudioPort(struct audio_port *port) |
| 535 | { |
| 536 | if (port == NULL) { |
| 537 | return BAD_VALUE; |
| 538 | } |
| 539 | Parcel data, reply; |
| 540 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 541 | data.write(port, sizeof(struct audio_port)); |
| 542 | status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); |
| 543 | if (status != NO_ERROR || |
| 544 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 545 | return status; |
| 546 | } |
| 547 | reply.read(port, sizeof(struct audio_port)); |
| 548 | return status; |
| 549 | } |
| 550 | |
| 551 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 552 | audio_patch_handle_t *handle) |
| 553 | { |
| 554 | if (patch == NULL || handle == NULL) { |
| 555 | return BAD_VALUE; |
| 556 | } |
| 557 | Parcel data, reply; |
| 558 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 559 | data.write(patch, sizeof(struct audio_patch)); |
| 560 | data.write(handle, sizeof(audio_patch_handle_t)); |
| 561 | status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); |
| 562 | if (status != NO_ERROR || |
| 563 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 564 | return status; |
| 565 | } |
| 566 | reply.read(handle, sizeof(audio_patch_handle_t)); |
| 567 | return status; |
| 568 | } |
| 569 | |
| 570 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle) |
| 571 | { |
| 572 | Parcel data, reply; |
| 573 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 574 | data.write(&handle, sizeof(audio_patch_handle_t)); |
| 575 | status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); |
| 576 | if (status != NO_ERROR) { |
| 577 | status = (status_t)reply.readInt32(); |
| 578 | } |
| 579 | return status; |
| 580 | } |
| 581 | |
| 582 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 583 | struct audio_patch *patches, |
| 584 | unsigned int *generation) |
| 585 | { |
| 586 | if (num_patches == NULL || (*num_patches != 0 && patches == NULL) || |
| 587 | generation == NULL) { |
| 588 | return BAD_VALUE; |
| 589 | } |
| 590 | Parcel data, reply; |
| 591 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 592 | unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches; |
| 593 | data.writeInt32(numPatchesReq); |
| 594 | status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); |
| 595 | if (status == NO_ERROR) { |
| 596 | status = (status_t)reply.readInt32(); |
| 597 | *num_patches = (unsigned int)reply.readInt32(); |
| 598 | } |
| 599 | if (status == NO_ERROR) { |
| 600 | if (numPatchesReq > *num_patches) { |
| 601 | numPatchesReq = *num_patches; |
| 602 | } |
| 603 | if (numPatchesReq > 0) { |
| 604 | reply.read(patches, numPatchesReq * sizeof(struct audio_patch)); |
| 605 | } |
| 606 | *generation = reply.readInt32(); |
| 607 | } |
| 608 | return status; |
| 609 | } |
| 610 | |
| 611 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) |
| 612 | { |
| 613 | if (config == NULL) { |
| 614 | return BAD_VALUE; |
| 615 | } |
| 616 | Parcel data, reply; |
| 617 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 618 | data.write(config, sizeof(struct audio_port_config)); |
| 619 | status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); |
| 620 | if (status != NO_ERROR) { |
| 621 | status = (status_t)reply.readInt32(); |
| 622 | } |
| 623 | return status; |
| 624 | } |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 625 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 626 | virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) |
| 627 | { |
| 628 | Parcel data, reply; |
| 629 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 630 | data.writeStrongBinder(client->asBinder()); |
| 631 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 632 | } |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 633 | |
| 634 | virtual status_t acquireSoundTriggerSession(audio_session_t *session, |
| 635 | audio_io_handle_t *ioHandle, |
| 636 | audio_devices_t *device) |
| 637 | { |
| 638 | if (session == NULL || ioHandle == NULL || device == NULL) { |
| 639 | return BAD_VALUE; |
| 640 | } |
| 641 | Parcel data, reply; |
| 642 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 643 | status_t status = remote()->transact(ACQUIRE_SOUNDTRIGGER_SESSION, data, &reply); |
| 644 | if (status != NO_ERROR) { |
| 645 | return status; |
| 646 | } |
| 647 | status = (status_t)reply.readInt32(); |
| 648 | if (status == NO_ERROR) { |
| 649 | *session = (audio_session_t)reply.readInt32(); |
| 650 | *ioHandle = (audio_io_handle_t)reply.readInt32(); |
| 651 | *device = (audio_devices_t)reply.readInt32(); |
| 652 | } |
| 653 | return status; |
| 654 | } |
| 655 | |
| 656 | virtual status_t releaseSoundTriggerSession(audio_session_t session) |
| 657 | { |
| 658 | Parcel data, reply; |
| 659 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 660 | data.writeInt32(session); |
| 661 | status_t status = remote()->transact(RELEASE_SOUNDTRIGGER_SESSION, data, &reply); |
| 662 | if (status != NO_ERROR) { |
| 663 | return status; |
| 664 | } |
| 665 | return (status_t)reply.readInt32(); |
| 666 | } |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 667 | |
| 668 | virtual audio_mode_t getPhoneState() |
| 669 | { |
| 670 | Parcel data, reply; |
| 671 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 672 | status_t status = remote()->transact(GET_PHONE_STATE, data, &reply); |
| 673 | if (status != NO_ERROR) { |
| 674 | return AUDIO_MODE_INVALID; |
| 675 | } |
| 676 | return (audio_mode_t)reply.readInt32(); |
| 677 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 678 | }; |
| 679 | |
| 680 | IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); |
| 681 | |
| 682 | // ---------------------------------------------------------------------- |
| 683 | |
| 684 | |
| 685 | status_t BnAudioPolicyService::onTransact( |
| 686 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 687 | { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 688 | switch (code) { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 689 | case SET_DEVICE_CONNECTION_STATE: { |
| 690 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 691 | audio_devices_t device = |
| 692 | static_cast <audio_devices_t>(data.readInt32()); |
| 693 | audio_policy_dev_state_t state = |
| 694 | static_cast <audio_policy_dev_state_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 695 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 696 | reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, |
| 697 | state, |
| 698 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 699 | return NO_ERROR; |
| 700 | } break; |
| 701 | |
| 702 | case GET_DEVICE_CONNECTION_STATE: { |
| 703 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 704 | audio_devices_t device = |
| 705 | static_cast<audio_devices_t> (data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 706 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 707 | reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, |
| 708 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 709 | return NO_ERROR; |
| 710 | } break; |
| 711 | |
| 712 | case SET_PHONE_STATE: { |
| 713 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 714 | reply->writeInt32(static_cast <uint32_t>(setPhoneState( |
| 715 | (audio_mode_t) data.readInt32()))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 716 | return NO_ERROR; |
| 717 | } break; |
| 718 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 719 | case SET_FORCE_USE: { |
| 720 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 721 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 722 | data.readInt32()); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 723 | audio_policy_forced_cfg_t config = |
| 724 | static_cast <audio_policy_forced_cfg_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 725 | reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); |
| 726 | return NO_ERROR; |
| 727 | } break; |
| 728 | |
| 729 | case GET_FORCE_USE: { |
| 730 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 731 | audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( |
| 732 | data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 733 | reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); |
| 734 | return NO_ERROR; |
| 735 | } break; |
| 736 | |
| 737 | case GET_OUTPUT: { |
| 738 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 739 | audio_stream_type_t stream = |
| 740 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 741 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 742 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 743 | audio_channel_mask_t channelMask = data.readInt32(); |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 744 | audio_output_flags_t flags = |
| 745 | static_cast <audio_output_flags_t>(data.readInt32()); |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 746 | bool hasOffloadInfo = data.readInt32() != 0; |
| 747 | audio_offload_info_t offloadInfo; |
| 748 | if (hasOffloadInfo) { |
| 749 | data.read(&offloadInfo, sizeof(audio_offload_info_t)); |
| 750 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 751 | audio_io_handle_t output = getOutput(stream, |
| 752 | samplingRate, |
| 753 | format, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 754 | channelMask, |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 755 | flags, |
| 756 | hasOffloadInfo ? &offloadInfo : NULL); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 757 | reply->writeInt32(static_cast <int>(output)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 758 | return NO_ERROR; |
| 759 | } break; |
| 760 | |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 761 | case GET_OUTPUT_FOR_ATTR: { |
| 762 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | 85f480e | 2014-11-05 17:44:51 -0800 | [diff] [blame] | 763 | audio_attributes_t attr; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 764 | bool hasAttributes = data.readInt32() != 0; |
| 765 | if (hasAttributes) { |
| 766 | data.read(&attr, sizeof(audio_attributes_t)); |
| 767 | } |
| 768 | audio_session_t session = (audio_session_t)data.readInt32(); |
| 769 | audio_stream_type_t stream = AUDIO_STREAM_DEFAULT; |
| 770 | bool hasStream = data.readInt32() != 0; |
| 771 | if (hasStream) { |
| 772 | stream = (audio_stream_type_t)data.readInt32(); |
| 773 | } |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 774 | uint32_t samplingRate = data.readInt32(); |
| 775 | audio_format_t format = (audio_format_t) data.readInt32(); |
| 776 | audio_channel_mask_t channelMask = data.readInt32(); |
| 777 | audio_output_flags_t flags = |
| 778 | static_cast <audio_output_flags_t>(data.readInt32()); |
| 779 | bool hasOffloadInfo = data.readInt32() != 0; |
| 780 | audio_offload_info_t offloadInfo; |
| 781 | if (hasOffloadInfo) { |
| 782 | data.read(&offloadInfo, sizeof(audio_offload_info_t)); |
| 783 | } |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 784 | audio_io_handle_t output; |
| 785 | status_t status = getOutputForAttr(hasAttributes ? &attr : NULL, |
| 786 | &output, session, &stream, |
| 787 | samplingRate, format, channelMask, |
| 788 | flags, hasOffloadInfo ? &offloadInfo : NULL); |
| 789 | reply->writeInt32(status); |
| 790 | reply->writeInt32(output); |
| 791 | reply->writeInt32(stream); |
Jean-Michel Trivi | 5bd3f38 | 2014-06-13 16:06:54 -0700 | [diff] [blame] | 792 | return NO_ERROR; |
| 793 | } break; |
| 794 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 795 | case START_OUTPUT: { |
| 796 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 797 | audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 798 | audio_stream_type_t stream = |
| 799 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 800 | audio_session_t session = (audio_session_t)data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 801 | reply->writeInt32(static_cast <uint32_t>(startOutput(output, |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 802 | stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 803 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 804 | return NO_ERROR; |
| 805 | } break; |
| 806 | |
| 807 | case STOP_OUTPUT: { |
| 808 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 809 | audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 810 | audio_stream_type_t stream = |
| 811 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 812 | audio_session_t session = (audio_session_t)data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 813 | reply->writeInt32(static_cast <uint32_t>(stopOutput(output, |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 814 | stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 815 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 816 | return NO_ERROR; |
| 817 | } break; |
| 818 | |
| 819 | case RELEASE_OUTPUT: { |
| 820 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 821 | audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 822 | audio_stream_type_t stream = (audio_stream_type_t)data.readInt32(); |
| 823 | audio_session_t session = (audio_session_t)data.readInt32(); |
| 824 | releaseOutput(output, stream, session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 825 | return NO_ERROR; |
| 826 | } break; |
| 827 | |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 828 | case GET_INPUT_FOR_ATTR: { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 829 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 830 | audio_attributes_t attr; |
| 831 | data.read(&attr, sizeof(audio_attributes_t)); |
| 832 | audio_session_t session = (audio_session_t)data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 833 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 834 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 835 | audio_channel_mask_t channelMask = data.readInt32(); |
Glenn Kasten | b3b1660 | 2014-07-16 08:36:31 -0700 | [diff] [blame] | 836 | audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame^] | 837 | audio_io_handle_t input; |
| 838 | status_t status = getInputForAttr(&attr, &input, session, |
| 839 | samplingRate, format, channelMask, |
| 840 | flags); |
| 841 | reply->writeInt32(status); |
| 842 | if (status == NO_ERROR) { |
| 843 | reply->writeInt32(input); |
| 844 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 845 | return NO_ERROR; |
| 846 | } break; |
| 847 | |
| 848 | case START_INPUT: { |
| 849 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 850 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 851 | audio_session_t session = static_cast <audio_session_t>(data.readInt32()); |
| 852 | reply->writeInt32(static_cast <uint32_t>(startInput(input, session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 853 | return NO_ERROR; |
| 854 | } break; |
| 855 | |
| 856 | case STOP_INPUT: { |
| 857 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 858 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 859 | audio_session_t session = static_cast <audio_session_t>(data.readInt32()); |
| 860 | reply->writeInt32(static_cast <uint32_t>(stopInput(input, session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 861 | return NO_ERROR; |
| 862 | } break; |
| 863 | |
| 864 | case RELEASE_INPUT: { |
| 865 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 866 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 867 | audio_session_t session = static_cast <audio_session_t>(data.readInt32()); |
| 868 | releaseInput(input, session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 869 | return NO_ERROR; |
| 870 | } break; |
| 871 | |
| 872 | case INIT_STREAM_VOLUME: { |
| 873 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 874 | audio_stream_type_t stream = |
| 875 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 876 | int indexMin = data.readInt32(); |
| 877 | int indexMax = data.readInt32(); |
| 878 | reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); |
| 879 | return NO_ERROR; |
| 880 | } break; |
| 881 | |
| 882 | case SET_STREAM_VOLUME: { |
| 883 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 884 | audio_stream_type_t stream = |
| 885 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 886 | int index = data.readInt32(); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 887 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
| 888 | reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, |
| 889 | index, |
| 890 | device))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 891 | return NO_ERROR; |
| 892 | } break; |
| 893 | |
| 894 | case GET_STREAM_VOLUME: { |
| 895 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 896 | audio_stream_type_t stream = |
| 897 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 898 | audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 899 | int index; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 900 | status_t status = getStreamVolumeIndex(stream, &index, device); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 901 | reply->writeInt32(index); |
| 902 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 903 | return NO_ERROR; |
| 904 | } break; |
| 905 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 906 | case GET_STRATEGY_FOR_STREAM: { |
| 907 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 908 | audio_stream_type_t stream = |
| 909 | static_cast <audio_stream_type_t>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 910 | reply->writeInt32(getStrategyForStream(stream)); |
| 911 | return NO_ERROR; |
| 912 | } break; |
| 913 | |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 914 | case GET_DEVICES_FOR_STREAM: { |
| 915 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 916 | audio_stream_type_t stream = |
| 917 | static_cast <audio_stream_type_t>(data.readInt32()); |
Glenn Kasten | 6b2718c | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 918 | reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); |
| 919 | return NO_ERROR; |
| 920 | } break; |
| 921 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 922 | case GET_OUTPUT_FOR_EFFECT: { |
| 923 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 924 | effect_descriptor_t desc; |
| 925 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 926 | audio_io_handle_t output = getOutputForEffect(&desc); |
| 927 | reply->writeInt32(static_cast <int>(output)); |
| 928 | return NO_ERROR; |
| 929 | } break; |
| 930 | |
| 931 | case REGISTER_EFFECT: { |
| 932 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 933 | effect_descriptor_t desc; |
| 934 | data.read(&desc, sizeof(effect_descriptor_t)); |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 935 | audio_io_handle_t io = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 936 | uint32_t strategy = data.readInt32(); |
| 937 | int session = data.readInt32(); |
| 938 | int id = data.readInt32(); |
| 939 | reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 940 | io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 941 | strategy, |
| 942 | session, |
| 943 | id))); |
| 944 | return NO_ERROR; |
| 945 | } break; |
| 946 | |
| 947 | case UNREGISTER_EFFECT: { |
| 948 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 949 | int id = data.readInt32(); |
| 950 | reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); |
| 951 | return NO_ERROR; |
| 952 | } break; |
| 953 | |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 954 | case SET_EFFECT_ENABLED: { |
| 955 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 956 | int id = data.readInt32(); |
| 957 | bool enabled = static_cast <bool>(data.readInt32()); |
| 958 | reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); |
| 959 | return NO_ERROR; |
| 960 | } break; |
| 961 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 962 | case IS_STREAM_ACTIVE: { |
| 963 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 964 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 965 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 966 | reply->writeInt32( isStreamActive(stream, inPastMs) ); |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 967 | return NO_ERROR; |
| 968 | } break; |
| 969 | |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 970 | case IS_STREAM_ACTIVE_REMOTELY: { |
| 971 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 972 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 973 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
Eric Laurent | ebcb254 | 2014-03-05 18:30:08 -0800 | [diff] [blame] | 974 | reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 975 | return NO_ERROR; |
| 976 | } break; |
| 977 | |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 978 | case IS_SOURCE_ACTIVE: { |
| 979 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 980 | audio_source_t source = (audio_source_t) data.readInt32(); |
| 981 | reply->writeInt32( isSourceActive(source)); |
| 982 | return NO_ERROR; |
| 983 | } |
| 984 | |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 985 | case QUERY_DEFAULT_PRE_PROCESSING: { |
| 986 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 987 | int audioSession = data.readInt32(); |
| 988 | uint32_t count = data.readInt32(); |
Eric Laurent | 74adca9 | 2014-11-05 12:15:36 -0800 | [diff] [blame] | 989 | if (count > AudioEffect::kMaxPreProcessing) { |
| 990 | count = AudioEffect::kMaxPreProcessing; |
| 991 | } |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 992 | uint32_t retCount = count; |
Eric Laurent | 74adca9 | 2014-11-05 12:15:36 -0800 | [diff] [blame] | 993 | effect_descriptor_t *descriptors = new effect_descriptor_t[count]; |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 994 | status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); |
| 995 | reply->writeInt32(status); |
| 996 | if (status != NO_ERROR && status != NO_MEMORY) { |
| 997 | retCount = 0; |
| 998 | } |
| 999 | reply->writeInt32(retCount); |
Eric Laurent | 74adca9 | 2014-11-05 12:15:36 -0800 | [diff] [blame] | 1000 | if (retCount != 0) { |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 1001 | if (retCount < count) { |
| 1002 | count = retCount; |
| 1003 | } |
| 1004 | reply->write(descriptors, sizeof(effect_descriptor_t) * count); |
| 1005 | } |
| 1006 | delete[] descriptors; |
| 1007 | return status; |
| 1008 | } |
| 1009 | |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 1010 | case IS_OFFLOAD_SUPPORTED: { |
| 1011 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1012 | audio_offload_info_t info; |
| 1013 | data.read(&info, sizeof(audio_offload_info_t)); |
| 1014 | bool isSupported = isOffloadSupported(info); |
| 1015 | reply->writeInt32(isSupported); |
| 1016 | return NO_ERROR; |
| 1017 | } |
| 1018 | |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 1019 | case LIST_AUDIO_PORTS: { |
| 1020 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1021 | audio_port_role_t role = (audio_port_role_t)data.readInt32(); |
| 1022 | audio_port_type_t type = (audio_port_type_t)data.readInt32(); |
| 1023 | unsigned int numPortsReq = data.readInt32(); |
| 1024 | unsigned int numPorts = numPortsReq; |
| 1025 | unsigned int generation; |
| 1026 | struct audio_port *ports = |
| 1027 | (struct audio_port *)calloc(numPortsReq, sizeof(struct audio_port)); |
| 1028 | status_t status = listAudioPorts(role, type, &numPorts, ports, &generation); |
| 1029 | reply->writeInt32(status); |
| 1030 | reply->writeInt32(numPorts); |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 1031 | |
| 1032 | if (status == NO_ERROR) { |
| 1033 | if (numPortsReq > numPorts) { |
| 1034 | numPortsReq = numPorts; |
| 1035 | } |
| 1036 | reply->write(ports, numPortsReq * sizeof(struct audio_port)); |
| 1037 | reply->writeInt32(generation); |
| 1038 | } |
| 1039 | free(ports); |
| 1040 | return NO_ERROR; |
| 1041 | } |
| 1042 | |
| 1043 | case GET_AUDIO_PORT: { |
| 1044 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1045 | struct audio_port port; |
| 1046 | data.read(&port, sizeof(struct audio_port)); |
| 1047 | status_t status = getAudioPort(&port); |
| 1048 | reply->writeInt32(status); |
| 1049 | if (status == NO_ERROR) { |
| 1050 | reply->write(&port, sizeof(struct audio_port)); |
| 1051 | } |
| 1052 | return NO_ERROR; |
| 1053 | } |
| 1054 | |
| 1055 | case CREATE_AUDIO_PATCH: { |
| 1056 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1057 | struct audio_patch patch; |
| 1058 | data.read(&patch, sizeof(struct audio_patch)); |
| 1059 | audio_patch_handle_t handle; |
| 1060 | data.read(&handle, sizeof(audio_patch_handle_t)); |
| 1061 | status_t status = createAudioPatch(&patch, &handle); |
| 1062 | reply->writeInt32(status); |
| 1063 | if (status == NO_ERROR) { |
| 1064 | reply->write(&handle, sizeof(audio_patch_handle_t)); |
| 1065 | } |
| 1066 | return NO_ERROR; |
| 1067 | } |
| 1068 | |
| 1069 | case RELEASE_AUDIO_PATCH: { |
| 1070 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1071 | audio_patch_handle_t handle; |
| 1072 | data.read(&handle, sizeof(audio_patch_handle_t)); |
| 1073 | status_t status = releaseAudioPatch(handle); |
| 1074 | reply->writeInt32(status); |
| 1075 | return NO_ERROR; |
| 1076 | } |
| 1077 | |
| 1078 | case LIST_AUDIO_PATCHES: { |
| 1079 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1080 | unsigned int numPatchesReq = data.readInt32(); |
| 1081 | unsigned int numPatches = numPatchesReq; |
| 1082 | unsigned int generation; |
| 1083 | struct audio_patch *patches = |
| 1084 | (struct audio_patch *)calloc(numPatchesReq, |
| 1085 | sizeof(struct audio_patch)); |
| 1086 | status_t status = listAudioPatches(&numPatches, patches, &generation); |
| 1087 | reply->writeInt32(status); |
| 1088 | reply->writeInt32(numPatches); |
| 1089 | if (status == NO_ERROR) { |
| 1090 | if (numPatchesReq > numPatches) { |
| 1091 | numPatchesReq = numPatches; |
| 1092 | } |
| 1093 | reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); |
| 1094 | reply->writeInt32(generation); |
| 1095 | } |
| 1096 | free(patches); |
| 1097 | return NO_ERROR; |
| 1098 | } |
| 1099 | |
| 1100 | case SET_AUDIO_PORT_CONFIG: { |
| 1101 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1102 | struct audio_port_config config; |
| 1103 | data.read(&config, sizeof(struct audio_port_config)); |
| 1104 | status_t status = setAudioPortConfig(&config); |
| 1105 | reply->writeInt32(status); |
| 1106 | return NO_ERROR; |
| 1107 | } |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 1108 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 1109 | case REGISTER_CLIENT: { |
| 1110 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1111 | sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( |
| 1112 | data.readStrongBinder()); |
| 1113 | registerClient(client); |
| 1114 | return NO_ERROR; |
| 1115 | } break; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 1116 | |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 1117 | case ACQUIRE_SOUNDTRIGGER_SESSION: { |
| 1118 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1119 | sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( |
| 1120 | data.readStrongBinder()); |
| 1121 | audio_session_t session; |
| 1122 | audio_io_handle_t ioHandle; |
| 1123 | audio_devices_t device; |
| 1124 | status_t status = acquireSoundTriggerSession(&session, &ioHandle, &device); |
| 1125 | reply->writeInt32(status); |
| 1126 | if (status == NO_ERROR) { |
| 1127 | reply->writeInt32(session); |
| 1128 | reply->writeInt32(ioHandle); |
| 1129 | reply->writeInt32(device); |
| 1130 | } |
| 1131 | return NO_ERROR; |
| 1132 | } break; |
| 1133 | |
| 1134 | case RELEASE_SOUNDTRIGGER_SESSION: { |
| 1135 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1136 | sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( |
| 1137 | data.readStrongBinder()); |
| 1138 | audio_session_t session = (audio_session_t)data.readInt32(); |
| 1139 | status_t status = releaseSoundTriggerSession(session); |
| 1140 | reply->writeInt32(status); |
| 1141 | return NO_ERROR; |
| 1142 | } break; |
| 1143 | |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 1144 | case GET_PHONE_STATE: { |
| 1145 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 1146 | reply->writeInt32((int32_t)getPhoneState()); |
| 1147 | return NO_ERROR; |
| 1148 | } break; |
| 1149 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1150 | default: |
| 1151 | return BBinder::onTransact(code, data, reply, flags); |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | // ---------------------------------------------------------------------------- |
| 1156 | |
| 1157 | }; // namespace android |