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