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