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 | |
| 28 | namespace android { |
| 29 | |
| 30 | enum { |
| 31 | SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, |
| 32 | GET_DEVICE_CONNECTION_STATE, |
| 33 | SET_PHONE_STATE, |
| 34 | SET_RINGER_MODE, |
| 35 | SET_FORCE_USE, |
| 36 | GET_FORCE_USE, |
| 37 | GET_OUTPUT, |
| 38 | START_OUTPUT, |
| 39 | STOP_OUTPUT, |
| 40 | RELEASE_OUTPUT, |
| 41 | GET_INPUT, |
| 42 | START_INPUT, |
| 43 | STOP_INPUT, |
| 44 | RELEASE_INPUT, |
| 45 | INIT_STREAM_VOLUME, |
| 46 | SET_STREAM_VOLUME, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 47 | GET_STREAM_VOLUME, |
| 48 | GET_STRATEGY_FOR_STREAM, |
| 49 | GET_OUTPUT_FOR_EFFECT, |
| 50 | REGISTER_EFFECT, |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame^] | 51 | UNREGISTER_EFFECT, |
| 52 | IS_STREAM_ACTIVE |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | class BpAudioPolicyService : public BpInterface<IAudioPolicyService> |
| 56 | { |
| 57 | public: |
| 58 | BpAudioPolicyService(const sp<IBinder>& impl) |
| 59 | : BpInterface<IAudioPolicyService>(impl) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | virtual status_t setDeviceConnectionState( |
| 64 | AudioSystem::audio_devices device, |
| 65 | AudioSystem::device_connection_state state, |
| 66 | const char *device_address) |
| 67 | { |
| 68 | Parcel data, reply; |
| 69 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 70 | data.writeInt32(static_cast <uint32_t>(device)); |
| 71 | data.writeInt32(static_cast <uint32_t>(state)); |
| 72 | data.writeCString(device_address); |
| 73 | remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); |
| 74 | return static_cast <status_t> (reply.readInt32()); |
| 75 | } |
| 76 | |
| 77 | virtual AudioSystem::device_connection_state getDeviceConnectionState( |
| 78 | AudioSystem::audio_devices device, |
| 79 | const char *device_address) |
| 80 | { |
| 81 | Parcel data, reply; |
| 82 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 83 | data.writeInt32(static_cast <uint32_t>(device)); |
| 84 | data.writeCString(device_address); |
| 85 | remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); |
| 86 | return static_cast <AudioSystem::device_connection_state>(reply.readInt32()); |
| 87 | } |
| 88 | |
| 89 | virtual status_t setPhoneState(int state) |
| 90 | { |
| 91 | Parcel data, reply; |
| 92 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 93 | data.writeInt32(state); |
| 94 | remote()->transact(SET_PHONE_STATE, data, &reply); |
| 95 | return static_cast <status_t> (reply.readInt32()); |
| 96 | } |
| 97 | |
| 98 | virtual status_t setRingerMode(uint32_t mode, uint32_t mask) |
| 99 | { |
| 100 | Parcel data, reply; |
| 101 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 102 | data.writeInt32(mode); |
| 103 | data.writeInt32(mask); |
| 104 | remote()->transact(SET_RINGER_MODE, data, &reply); |
| 105 | return static_cast <status_t> (reply.readInt32()); |
| 106 | } |
| 107 | |
| 108 | virtual status_t setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config) |
| 109 | { |
| 110 | Parcel data, reply; |
| 111 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 112 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 113 | data.writeInt32(static_cast <uint32_t>(config)); |
| 114 | remote()->transact(SET_FORCE_USE, data, &reply); |
| 115 | return static_cast <status_t> (reply.readInt32()); |
| 116 | } |
| 117 | |
| 118 | virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage) |
| 119 | { |
| 120 | Parcel data, reply; |
| 121 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 122 | data.writeInt32(static_cast <uint32_t>(usage)); |
| 123 | remote()->transact(GET_FORCE_USE, data, &reply); |
| 124 | return static_cast <AudioSystem::forced_config> (reply.readInt32()); |
| 125 | } |
| 126 | |
| 127 | virtual audio_io_handle_t getOutput( |
| 128 | AudioSystem::stream_type stream, |
| 129 | uint32_t samplingRate, |
| 130 | uint32_t format, |
| 131 | uint32_t channels, |
| 132 | AudioSystem::output_flags flags) |
| 133 | { |
| 134 | Parcel data, reply; |
| 135 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 136 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 137 | data.writeInt32(samplingRate); |
| 138 | data.writeInt32(static_cast <uint32_t>(format)); |
| 139 | data.writeInt32(channels); |
| 140 | data.writeInt32(static_cast <uint32_t>(flags)); |
| 141 | remote()->transact(GET_OUTPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 142 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 145 | virtual status_t startOutput(audio_io_handle_t output, |
| 146 | AudioSystem::stream_type stream, |
| 147 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 148 | { |
| 149 | Parcel data, reply; |
| 150 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 151 | data.writeInt32(output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 152 | data.writeInt32(stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 153 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 154 | remote()->transact(START_OUTPUT, data, &reply); |
| 155 | return static_cast <status_t> (reply.readInt32()); |
| 156 | } |
| 157 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 158 | virtual status_t stopOutput(audio_io_handle_t output, |
| 159 | AudioSystem::stream_type stream, |
| 160 | int session) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 161 | { |
| 162 | Parcel data, reply; |
| 163 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 164 | data.writeInt32(output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 165 | data.writeInt32(stream); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 166 | data.writeInt32(session); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 167 | remote()->transact(STOP_OUTPUT, data, &reply); |
| 168 | return static_cast <status_t> (reply.readInt32()); |
| 169 | } |
| 170 | |
| 171 | virtual void releaseOutput(audio_io_handle_t output) |
| 172 | { |
| 173 | Parcel data, reply; |
| 174 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 175 | data.writeInt32(output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 176 | remote()->transact(RELEASE_OUTPUT, data, &reply); |
| 177 | } |
| 178 | |
| 179 | virtual audio_io_handle_t getInput( |
| 180 | int inputSource, |
| 181 | uint32_t samplingRate, |
| 182 | uint32_t format, |
| 183 | uint32_t channels, |
| 184 | AudioSystem::audio_in_acoustics acoustics) |
| 185 | { |
| 186 | Parcel data, reply; |
| 187 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 188 | data.writeInt32(inputSource); |
| 189 | data.writeInt32(samplingRate); |
| 190 | data.writeInt32(static_cast <uint32_t>(format)); |
| 191 | data.writeInt32(channels); |
| 192 | data.writeInt32(static_cast <uint32_t>(acoustics)); |
| 193 | remote()->transact(GET_INPUT, data, &reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 194 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | virtual status_t startInput(audio_io_handle_t input) |
| 198 | { |
| 199 | Parcel data, reply; |
| 200 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 201 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 202 | remote()->transact(START_INPUT, data, &reply); |
| 203 | return static_cast <status_t> (reply.readInt32()); |
| 204 | } |
| 205 | |
| 206 | virtual status_t stopInput(audio_io_handle_t input) |
| 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(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 211 | remote()->transact(STOP_INPUT, data, &reply); |
| 212 | return static_cast <status_t> (reply.readInt32()); |
| 213 | } |
| 214 | |
| 215 | virtual void releaseInput(audio_io_handle_t input) |
| 216 | { |
| 217 | Parcel data, reply; |
| 218 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 219 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 220 | remote()->transact(RELEASE_INPUT, data, &reply); |
| 221 | } |
| 222 | |
| 223 | virtual status_t initStreamVolume(AudioSystem::stream_type stream, |
| 224 | int indexMin, |
| 225 | int indexMax) |
| 226 | { |
| 227 | Parcel data, reply; |
| 228 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 229 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 230 | data.writeInt32(indexMin); |
| 231 | data.writeInt32(indexMax); |
| 232 | remote()->transact(INIT_STREAM_VOLUME, data, &reply); |
| 233 | return static_cast <status_t> (reply.readInt32()); |
| 234 | } |
| 235 | |
| 236 | virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) |
| 237 | { |
| 238 | Parcel data, reply; |
| 239 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 240 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 241 | data.writeInt32(index); |
| 242 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 243 | return static_cast <status_t> (reply.readInt32()); |
| 244 | } |
| 245 | |
| 246 | virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) |
| 247 | { |
| 248 | Parcel data, reply; |
| 249 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 250 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 251 | remote()->transact(GET_STREAM_VOLUME, data, &reply); |
| 252 | int lIndex = reply.readInt32(); |
| 253 | if (index) *index = lIndex; |
| 254 | return static_cast <status_t> (reply.readInt32()); |
| 255 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 256 | |
| 257 | virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) |
| 258 | { |
| 259 | Parcel data, reply; |
| 260 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 261 | data.writeInt32(static_cast <uint32_t>(stream)); |
| 262 | remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); |
| 263 | return reply.readInt32(); |
| 264 | } |
| 265 | |
| 266 | virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) |
| 267 | { |
| 268 | Parcel data, reply; |
| 269 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 270 | data.write(desc, sizeof(effect_descriptor_t)); |
| 271 | remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); |
| 272 | return static_cast <audio_io_handle_t> (reply.readInt32()); |
| 273 | } |
| 274 | |
| 275 | virtual status_t registerEffect(effect_descriptor_t *desc, |
| 276 | audio_io_handle_t output, |
| 277 | uint32_t strategy, |
| 278 | int session, |
| 279 | int id) |
| 280 | { |
| 281 | Parcel data, reply; |
| 282 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 283 | data.write(desc, sizeof(effect_descriptor_t)); |
| 284 | data.writeInt32(output); |
| 285 | data.writeInt32(strategy); |
| 286 | data.writeInt32(session); |
| 287 | data.writeInt32(id); |
| 288 | remote()->transact(REGISTER_EFFECT, data, &reply); |
| 289 | return static_cast <status_t> (reply.readInt32()); |
| 290 | } |
| 291 | |
| 292 | virtual status_t unregisterEffect(int id) |
| 293 | { |
| 294 | Parcel data, reply; |
| 295 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 296 | data.writeInt32(id); |
| 297 | remote()->transact(UNREGISTER_EFFECT, data, &reply); |
| 298 | return static_cast <status_t> (reply.readInt32()); |
| 299 | } |
| 300 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame^] | 301 | virtual bool isStreamActive(int stream, uint32_t inPastMs) const |
| 302 | { |
| 303 | Parcel data, reply; |
| 304 | data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); |
| 305 | data.writeInt32(stream); |
| 306 | data.writeInt32(inPastMs); |
| 307 | remote()->transact(IS_STREAM_ACTIVE, data, &reply); |
| 308 | return reply.readInt32(); |
| 309 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); |
| 313 | |
| 314 | // ---------------------------------------------------------------------- |
| 315 | |
| 316 | |
| 317 | status_t BnAudioPolicyService::onTransact( |
| 318 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 319 | { |
| 320 | switch(code) { |
| 321 | case SET_DEVICE_CONNECTION_STATE: { |
| 322 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 323 | AudioSystem::audio_devices device = |
| 324 | static_cast <AudioSystem::audio_devices>(data.readInt32()); |
| 325 | AudioSystem::device_connection_state state = |
| 326 | static_cast <AudioSystem::device_connection_state>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 327 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 328 | reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, |
| 329 | state, |
| 330 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 331 | return NO_ERROR; |
| 332 | } break; |
| 333 | |
| 334 | case GET_DEVICE_CONNECTION_STATE: { |
| 335 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 336 | AudioSystem::audio_devices device = |
| 337 | static_cast<AudioSystem::audio_devices> (data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 338 | const char *device_address = data.readCString(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 339 | reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, |
| 340 | device_address))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 341 | return NO_ERROR; |
| 342 | } break; |
| 343 | |
| 344 | case SET_PHONE_STATE: { |
| 345 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 346 | reply->writeInt32(static_cast <uint32_t>(setPhoneState(data.readInt32()))); |
| 347 | return NO_ERROR; |
| 348 | } break; |
| 349 | |
| 350 | case SET_RINGER_MODE: { |
| 351 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 352 | uint32_t mode = data.readInt32(); |
| 353 | uint32_t mask = data.readInt32(); |
| 354 | reply->writeInt32(static_cast <uint32_t>(setRingerMode(mode, mask))); |
| 355 | return NO_ERROR; |
| 356 | } break; |
| 357 | |
| 358 | case SET_FORCE_USE: { |
| 359 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 360 | AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32()); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 361 | AudioSystem::forced_config config = |
| 362 | static_cast <AudioSystem::forced_config>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 363 | reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); |
| 364 | return NO_ERROR; |
| 365 | } break; |
| 366 | |
| 367 | case GET_FORCE_USE: { |
| 368 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 369 | AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32()); |
| 370 | reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); |
| 371 | return NO_ERROR; |
| 372 | } break; |
| 373 | |
| 374 | case GET_OUTPUT: { |
| 375 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 376 | AudioSystem::stream_type stream = |
| 377 | static_cast <AudioSystem::stream_type>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 378 | uint32_t samplingRate = data.readInt32(); |
| 379 | uint32_t format = data.readInt32(); |
| 380 | uint32_t channels = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 381 | AudioSystem::output_flags flags = |
| 382 | static_cast <AudioSystem::output_flags>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 383 | |
| 384 | audio_io_handle_t output = getOutput(stream, |
| 385 | samplingRate, |
| 386 | format, |
| 387 | channels, |
| 388 | flags); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 389 | reply->writeInt32(static_cast <int>(output)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 390 | return NO_ERROR; |
| 391 | } break; |
| 392 | |
| 393 | case START_OUTPUT: { |
| 394 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 395 | 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] | 396 | uint32_t stream = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 397 | int session = data.readInt32(); |
| 398 | reply->writeInt32(static_cast <uint32_t>(startOutput(output, |
| 399 | (AudioSystem::stream_type)stream, |
| 400 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 401 | return NO_ERROR; |
| 402 | } break; |
| 403 | |
| 404 | case STOP_OUTPUT: { |
| 405 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 406 | 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] | 407 | uint32_t stream = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 408 | int session = data.readInt32(); |
| 409 | reply->writeInt32(static_cast <uint32_t>(stopOutput(output, |
| 410 | (AudioSystem::stream_type)stream, |
| 411 | session))); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 412 | return NO_ERROR; |
| 413 | } break; |
| 414 | |
| 415 | case RELEASE_OUTPUT: { |
| 416 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 417 | 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] | 418 | releaseOutput(output); |
| 419 | return NO_ERROR; |
| 420 | } break; |
| 421 | |
| 422 | case GET_INPUT: { |
| 423 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 424 | int inputSource = data.readInt32(); |
| 425 | uint32_t samplingRate = data.readInt32(); |
| 426 | uint32_t format = data.readInt32(); |
| 427 | uint32_t channels = data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 428 | AudioSystem::audio_in_acoustics acoustics = |
| 429 | static_cast <AudioSystem::audio_in_acoustics>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 430 | audio_io_handle_t input = getInput(inputSource, |
| 431 | samplingRate, |
| 432 | format, |
| 433 | channels, |
| 434 | acoustics); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 435 | reply->writeInt32(static_cast <int>(input)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 436 | return NO_ERROR; |
| 437 | } break; |
| 438 | |
| 439 | case START_INPUT: { |
| 440 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 441 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 442 | reply->writeInt32(static_cast <uint32_t>(startInput(input))); |
| 443 | return NO_ERROR; |
| 444 | } break; |
| 445 | |
| 446 | case STOP_INPUT: { |
| 447 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 448 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 449 | reply->writeInt32(static_cast <uint32_t>(stopInput(input))); |
| 450 | return NO_ERROR; |
| 451 | } break; |
| 452 | |
| 453 | case RELEASE_INPUT: { |
| 454 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 455 | audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 456 | releaseInput(input); |
| 457 | return NO_ERROR; |
| 458 | } break; |
| 459 | |
| 460 | case INIT_STREAM_VOLUME: { |
| 461 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 462 | AudioSystem::stream_type stream = |
| 463 | static_cast <AudioSystem::stream_type>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 464 | int indexMin = data.readInt32(); |
| 465 | int indexMax = data.readInt32(); |
| 466 | reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); |
| 467 | return NO_ERROR; |
| 468 | } break; |
| 469 | |
| 470 | case SET_STREAM_VOLUME: { |
| 471 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 472 | AudioSystem::stream_type stream = |
| 473 | static_cast <AudioSystem::stream_type>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 474 | int index = data.readInt32(); |
| 475 | reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index))); |
| 476 | return NO_ERROR; |
| 477 | } break; |
| 478 | |
| 479 | case GET_STREAM_VOLUME: { |
| 480 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 481 | AudioSystem::stream_type stream = |
| 482 | static_cast <AudioSystem::stream_type>(data.readInt32()); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 483 | int index; |
| 484 | status_t status = getStreamVolumeIndex(stream, &index); |
| 485 | reply->writeInt32(index); |
| 486 | reply->writeInt32(static_cast <uint32_t>(status)); |
| 487 | return NO_ERROR; |
| 488 | } break; |
| 489 | |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 490 | case GET_STRATEGY_FOR_STREAM: { |
| 491 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 492 | AudioSystem::stream_type stream = |
| 493 | static_cast <AudioSystem::stream_type>(data.readInt32()); |
| 494 | reply->writeInt32(getStrategyForStream(stream)); |
| 495 | return NO_ERROR; |
| 496 | } break; |
| 497 | |
| 498 | case GET_OUTPUT_FOR_EFFECT: { |
| 499 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 500 | effect_descriptor_t desc; |
| 501 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 502 | audio_io_handle_t output = getOutputForEffect(&desc); |
| 503 | reply->writeInt32(static_cast <int>(output)); |
| 504 | return NO_ERROR; |
| 505 | } break; |
| 506 | |
| 507 | case REGISTER_EFFECT: { |
| 508 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 509 | effect_descriptor_t desc; |
| 510 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 511 | audio_io_handle_t output = data.readInt32(); |
| 512 | uint32_t strategy = data.readInt32(); |
| 513 | int session = data.readInt32(); |
| 514 | int id = data.readInt32(); |
| 515 | reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, |
| 516 | output, |
| 517 | strategy, |
| 518 | session, |
| 519 | id))); |
| 520 | return NO_ERROR; |
| 521 | } break; |
| 522 | |
| 523 | case UNREGISTER_EFFECT: { |
| 524 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 525 | int id = data.readInt32(); |
| 526 | reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); |
| 527 | return NO_ERROR; |
| 528 | } break; |
| 529 | |
Eric Laurent | eda6c36 | 2011-02-02 09:33:30 -0800 | [diff] [blame^] | 530 | case IS_STREAM_ACTIVE: { |
| 531 | CHECK_INTERFACE(IAudioPolicyService, data, reply); |
| 532 | int stream = data.readInt32(); |
| 533 | uint32_t inPastMs = (uint32_t)data.readInt32(); |
| 534 | reply->writeInt32( isStreamActive(stream, inPastMs) ); |
| 535 | return NO_ERROR; |
| 536 | } break; |
| 537 | |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 538 | default: |
| 539 | return BBinder::onTransact(code, data, reply, flags); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | // ---------------------------------------------------------------------------- |
| 544 | |
| 545 | }; // namespace android |