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