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