IAudioPolicyService.cpp revision 0b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7
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, 556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten GET_DEVICES_FOR_STREAM, 56db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent QUERY_DEFAULT_PRE_PROCESSING, 57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent SET_EFFECT_ENABLED 58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 69fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 70fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 82fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 83fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 91fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 94f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 103fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 113fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 119fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 123fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format, 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels, 127fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_output_flags_t flags) 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(channels); 135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 137fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 140de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 141fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 142de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 146fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 147fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 148de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 153de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 154fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 155de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 159fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 160fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 161de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 170fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 171c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int inputSource, 176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format, 178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels, 1797c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_in_acoustics_t acoustics, 1807c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(inputSource); 185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(channels); 188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(acoustics)); 1897c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 191fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 198fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 207fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 216fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 220fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 23383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 23483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 23583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 24183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 24783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 24883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 25383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 25483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 260de070137f11d346fba77605bd76a44c040a618fcEric Laurent 261fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 262de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 263de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 264de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 265de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 266de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 267de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 268de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 269de070137f11d346fba77605bd76a44c040a618fcEric Laurent 270fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getDevicesForStream(audio_stream_type_t stream) 2716b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2726b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2736b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2746b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2756b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2766b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return (uint32_t) reply.readInt32(); 2776b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2786b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 279de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) 280de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 281de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 282de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 283de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 284de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 285de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 286de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 287de070137f11d346fba77605bd76a44c040a618fcEric Laurent 288de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t registerEffect(effect_descriptor_t *desc, 2897c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 290de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 291de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 292de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 293de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 294de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 295de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 296de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 2977c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 298de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 303de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 304de070137f11d346fba77605bd76a44c040a618fcEric Laurent 305de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 306de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 312de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 313de070137f11d346fba77605bd76a44c040a618fcEric Laurent 314db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 315db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 316db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 317db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 318db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 319db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 320db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 321db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 322db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 323db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 324fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 325eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 326eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 327eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 328fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 329eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 330eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 331eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 332eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 33357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 33457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 33557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 33657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 33757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 33857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 33957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 34057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 34157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 34257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 34357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 34457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 34557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 34657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 34757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 34857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 34957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 35057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 35157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 35257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 35357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 35457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 35557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 35657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 35757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent switch(code) { 369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 371fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 372fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 373fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 374fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 375c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 376de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 377de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 378de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 379c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 380c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 382c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 383c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 384fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 385fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 387de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 388de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 390c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 394f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState((audio_mode_t) data.readInt32()))); 395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 400fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); 401fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 402fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 407c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 408c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 409fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); 410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 412c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 413c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 416fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 417fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format = data.readInt32(); 420c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels = data.readInt32(); 421fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_output_flags_t flags = 422fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_output_flags_t>(data.readInt32()); 423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 424c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 425c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 427c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent channels, 428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent flags); 429fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 430c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 431c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 435fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 437de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 438de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 439fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 440de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 446fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 447c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 448de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 449de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 450fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 451de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 455c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 457fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 458c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 459c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 460c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 461c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 462c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 463c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 464c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int inputSource = data.readInt32(); 465c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format = data.readInt32(); 467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels = data.readInt32(); 468fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_in_acoustics_t acoustics = 469fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_in_acoustics_t>(data.readInt32()); 4707c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 471c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 472c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent channels, 4757c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent acoustics, 4767c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 477fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 479c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 480c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 481c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 482c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 483fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 488c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 490fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 492c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 493c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 494c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 495c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 497fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 504fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 505fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 508c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 509c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 510c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 511c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 512c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 513c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 514fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 515fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 516c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 51783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 51883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 51983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 52083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 522c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 523c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 524c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 525c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 526fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 527fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 52883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 53083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 531c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 532c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 533c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 534c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 535c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 536de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 537de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 538fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 539fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 540de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 541de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 542de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 543de070137f11d346fba77605bd76a44c040a618fcEric Laurent 5446b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 5456b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 546fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 547fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 5486b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 5496b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 5506b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 5516b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 552de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 553de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 554de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 555de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 556de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 557de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 558de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 559de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 560de070137f11d346fba77605bd76a44c040a618fcEric Laurent 561de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 562de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 563de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 564de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 5657c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 566de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 567de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 568de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 569de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 5707c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 571de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 572de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 573de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 574de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 575de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 576de070137f11d346fba77605bd76a44c040a618fcEric Laurent 577de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 578de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 579de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 580de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 581de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 582de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 583de070137f11d346fba77605bd76a44c040a618fcEric Laurent 584db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 585db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 586db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 587db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 588db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 589db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 590db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 591db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 592eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 593eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 594fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 595eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 596fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) ); 597eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 598eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 599eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 60057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 60157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 60257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 60357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 60457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 60557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 60657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 60757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 60857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 60957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 61057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 61157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 61257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 61357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 61457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 61557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 61657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 61757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 61857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 61957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 62057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 62157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 62257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 623c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 624c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 625c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 626c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 627c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 628c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 629c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 630c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 631