IAudioPolicyService.cpp revision b1a270d1e926fb9a01b4265a7675ed0c2c8f4868
1c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent/* 2c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 3c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Copyright 2009, The Android Open Source Project 4c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 5c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Licensed under the Apache License, Version 2.0 (the "License"); 6c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** you may not use this file except in compliance with the License. 7c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** You may obtain a copy of the License at 8c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 9c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** http://www.apache.org/licenses/LICENSE-2.0 10c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 11c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Unless required by applicable law or agreed to in writing, software 12c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** distributed under the License is distributed on an "AS IS" BASIS, 13c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** See the License for the specific language governing permissions and 15c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** limitations under the License. 16c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent*/ 17c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 18c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#define LOG_TAG "IAudioPolicyService" 19c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <utils/Log.h> 20c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 21c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <stdint.h> 22c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <sys/types.h> 23c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <binder/Parcel.h> 25c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 26c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/IAudioPolicyService.h> 27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2864760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h> 29fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin 30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android { 31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum { 33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, 34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_DEVICE_CONNECTION_STATE, 35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_PHONE_STATE, 360b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7Glenn Kasten SET_RINGER_MODE, // reserved, no longer used 37c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_FORCE_USE, 38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_FORCE_USE, 39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_OUTPUT, 40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_OUTPUT, 41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_OUTPUT, 42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_OUTPUT, 43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_INPUT, 44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_INPUT, 45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_INPUT, 46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_INPUT, 47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INIT_STREAM_VOLUME, 48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_STREAM_VOLUME, 49de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STREAM_VOLUME, 50de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STRATEGY_FOR_STREAM, 51de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_OUTPUT_FOR_EFFECT, 52de070137f11d346fba77605bd76a44c040a618fcEric Laurent REGISTER_EFFECT, 53eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent UNREGISTER_EFFECT, 546b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten IS_STREAM_ACTIVE, 55d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi IS_SOURCE_ACTIVE, 566b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten GET_DEVICES_FOR_STREAM, 57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent QUERY_DEFAULT_PRE_PROCESSING, 58272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi SET_EFFECT_ENABLED, 59ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald IS_STREAM_ACTIVE_REMOTELY, 60ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald IS_OFFLOAD_SUPPORTED 61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 72fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 73fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 85fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 86fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 94fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 97f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 106fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 116fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 122fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 126fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 12858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 129254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 130ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald audio_output_flags_t flags, 131ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald const audio_offload_info_t *offloadInfo) 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 138254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 140b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (offloadInfo == NULL) { 141b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(0); 142b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } else { 143b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(1); 144b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(offloadInfo, sizeof(audio_offload_info_t)); 145b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 147fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 150de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 151fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 152de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 156fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 157fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 158de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 159c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 163de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 164fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 165de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 169fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 170fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 171de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 180fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 185eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 18758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 188254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 1897c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 193eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 196254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 1977c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 199fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 206fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 215fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 224fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 228fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 24283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 24383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 24983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 25483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 25583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 25683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 26183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 26283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 263c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 268de070137f11d346fba77605bd76a44c040a618fcEric Laurent 269fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 270de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 271de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 272de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 273de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 274de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 275de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 276de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 277de070137f11d346fba77605bd76a44c040a618fcEric Laurent 2786374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 2796b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2806b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2816b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2826b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2836b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2846374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 2856b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2866b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 28758e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) 288de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 289de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 290de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 291de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 292de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 293de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 294de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 295de070137f11d346fba77605bd76a44c040a618fcEric Laurent 29658e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual status_t registerEffect(const effect_descriptor_t *desc, 2977c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 298de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 303de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 304de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 3057c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 306de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 312de070137f11d346fba77605bd76a44c040a618fcEric Laurent 313de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 314de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 315de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 316de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 317de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 318de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 319de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 320de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 321de070137f11d346fba77605bd76a44c040a618fcEric Laurent 322db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 323db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 324db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 325db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 326db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 327db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 328db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 329db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 330db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 331db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 332fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 333eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 334eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 335eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 336fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 337eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 338eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 339eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 340eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 34157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 342272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 343272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi { 344272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi Parcel data, reply; 345272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 346272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32((int32_t) stream); 347272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32(inPastMs); 348272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); 349272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return reply.readInt32(); 350272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } 351272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 352d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi virtual bool isSourceActive(audio_source_t source) const 353d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi { 354d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi Parcel data, reply; 355d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 356d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInt32((int32_t) source); 357d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi remote()->transact(IS_SOURCE_ACTIVE, data, &reply); 358d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return reply.readInt32(); 359d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 360d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 36157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 36257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 36357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 36457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 36557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 36657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 36757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 36857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 36957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 37057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 37157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 37257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 37357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 37457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 37557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 37657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 37757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 37857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 37957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 38057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 38157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 38257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 38357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 38457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 385ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald 386ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald virtual bool isOffloadSupported(const audio_offload_info_t& info) 387ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald { 388b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald Parcel data, reply; 389b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 390b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(&info, sizeof(audio_offload_info_t)); 391b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); 392b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return reply.readInt32(); } 393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 403e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 406fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 407fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 408fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 409fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 411de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 412de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 413de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 419fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 420fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 422de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 423de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 424c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 425c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 427c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 42985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState( 43085ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten (audio_mode_t) data.readInt32()))); 431c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 43685ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 43785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 438fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 439fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 440c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 44685ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 44785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 448c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 449c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 454fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 455fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 45758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 458254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 4590ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 4600ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 461b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool hasOffloadInfo = data.readInt32() != 0; 462b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t offloadInfo; 463b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (hasOffloadInfo) { 464b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&offloadInfo, sizeof(audio_offload_info_t)); 465b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 469254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 470b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald flags, 471b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald hasOffloadInfo ? &offloadInfo : NULL); 472fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 478fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 479c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 480de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 481de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 482fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 483de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 488c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 489fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 491de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 492de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 493fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 494de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 495c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 497c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 500fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 507eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 508c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 50958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 510254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 5117c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 512c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 513c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 514c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 515254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 5167c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 517fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 518c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 519c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 520c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 522c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 523fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 524c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 525c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 526c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 530fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 531c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 532c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 533c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 534c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 535c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 537fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 538c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 540c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 541c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 542c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 543c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 544fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 545fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 546c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 547c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 548c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 549c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 550c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 551c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 552c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 553c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 554fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 555fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 556c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 55783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 55883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 55983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 56083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 561c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 562c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 563c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 564c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 565c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 566fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 567fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 56883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 569c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 57083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 571c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 572c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 573c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 574c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 575c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 576de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 577de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 578fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 579fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 580de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 581de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 582de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 583de070137f11d346fba77605bd76a44c040a618fcEric Laurent 5846b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 5856b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 586fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 587fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 5886b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 5896b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 5906b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 5916b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 592de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 593de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 594de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 595de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 596de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 597de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 598de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 599de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 600de070137f11d346fba77605bd76a44c040a618fcEric Laurent 601de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 602de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 603de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 604de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 6057c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 606de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 607de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 608de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 609de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 6107c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 611de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 612de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 613de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 614de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 615de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 616de070137f11d346fba77605bd76a44c040a618fcEric Laurent 617de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 618de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 619de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 620de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 621de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 622de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 623de070137f11d346fba77605bd76a44c040a618fcEric Laurent 624db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 625db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 626db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 627db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 628db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 629db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 630db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 631db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 632eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 633eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 634fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 635eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 636fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) ); 637eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 638eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 639eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 640272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi case IS_STREAM_ACTIVE_REMOTELY: { 641272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 642272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 643272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi uint32_t inPastMs = (uint32_t)data.readInt32(); 644272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi reply->writeInt32( isStreamActiveRemotely((audio_stream_type_t) stream, inPastMs) ); 645272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return NO_ERROR; 646272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } break; 647272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 648d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi case IS_SOURCE_ACTIVE: { 649d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 650d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi audio_source_t source = (audio_source_t) data.readInt32(); 651d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi reply->writeInt32( isSourceActive(source)); 652d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return NO_ERROR; 653d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 654d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 65557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 65657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 65757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 65857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 65957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 66057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 66157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 66257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 66357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 66457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 66557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 66657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 66757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 66857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 66957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 67057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 67157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 67257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 67357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 67457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 67557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 67657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 67757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 678b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald case IS_OFFLOAD_SUPPORTED: { 679b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald CHECK_INTERFACE(IAudioPolicyService, data, reply); 680b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t info; 681b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&info, sizeof(audio_offload_info_t)); 682b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool isSupported = isOffloadSupported(info); 683b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald reply->writeInt32(isSupported); 684b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return NO_ERROR; 685b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 686b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald 687c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 688c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 689c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 690c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 691c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 692c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 693c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 694c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 695