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