IAudioPolicyService.cpp revision 7c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745
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, 36c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_RINGER_MODE, 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, 56c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 57c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 67fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 68fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 80fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 81fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 89fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setPhoneState(int state) 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setRingerMode(uint32_t mode, uint32_t mask) 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(mode); 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(mask); 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_RINGER_MODE, data, &reply); 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 111fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 121fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 127fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 131fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format, 134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels, 135fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_output_flags_t flags) 136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(channels); 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 145fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 148de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 149fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 150de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 154fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(stream); 156de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 159c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 161de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 162fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 163de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 167fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(stream); 169de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 171c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 178fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int inputSource, 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format, 186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels, 1877c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_in_acoustics_t acoustics, 1887c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(inputSource); 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(channels); 196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(acoustics)); 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 241fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index) 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 251fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index) 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 261de070137f11d346fba77605bd76a44c040a618fcEric Laurent 262fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 263de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 264de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 265de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 266de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 267de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 268de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 269de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 270de070137f11d346fba77605bd76a44c040a618fcEric Laurent 271fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getDevicesForStream(audio_stream_type_t stream) 2726b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2736b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2746b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2756b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2766b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2776b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return (uint32_t) reply.readInt32(); 2786b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2796b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 280de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) 281de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 282de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 283de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 284de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 285de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 286de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 287de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 288de070137f11d346fba77605bd76a44c040a618fcEric Laurent 289de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t registerEffect(effect_descriptor_t *desc, 2907c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 291de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 292de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 293de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 294de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 295de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 296de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 297de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 2987c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 303de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 304de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 305de070137f11d346fba77605bd76a44c040a618fcEric Laurent 306de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 312de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 313de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 314de070137f11d346fba77605bd76a44c040a618fcEric Laurent 315eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent virtual bool isStreamActive(int stream, uint32_t inPastMs) const 316eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 317eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 318eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 319eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(stream); 320eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 321eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 322eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 323eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 324c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 325c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 326c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 327c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 328c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 329c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 330c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 331c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 332c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 333c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 334c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent switch(code) { 335c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 336c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 337fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 338fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 339fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 340fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 341c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 342de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 343de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 344de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 345c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 346c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 347c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 348c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 349c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 350fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 351fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 352c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 353de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 354de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 355c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 356c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setPhoneState(data.readInt32()))); 361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_RINGER_MODE: { 365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t mode = data.readInt32(); 367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t mask = data.readInt32(); 368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setRingerMode(mode, mask))); 369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 371c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 374fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); 375fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 376fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 377c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 379c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 380c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 382c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 383fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); 384c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 385c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 387c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 388c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 390fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 391fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format = data.readInt32(); 394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels = data.readInt32(); 395fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_output_flags_t flags = 396fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_output_flags_t>(data.readInt32()); 397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent channels, 402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent flags); 403fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 407c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 408c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 409fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 411de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 412de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 413fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 414de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 420fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 422de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 423de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 424fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 425de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 427c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 429c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 430c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 431fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 437c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 438c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int inputSource = data.readInt32(); 439c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 440c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t format = data.readInt32(); 441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t channels = data.readInt32(); 442fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_in_acoustics_t acoustics = 443fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_in_acoustics_t>(data.readInt32()); 4447c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 446c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 447c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 448c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent channels, 4497c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent acoustics, 4507c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 451fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 455c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 457fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 458c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 459c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 460c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 461c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 462c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 463c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 464fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 465c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 470c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 471fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 472c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 478fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 479fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 480c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 481c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 482c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 483c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 488fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 489fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index))); 492c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 493c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 494c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 495c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 497fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 498fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent status_t status = getStreamVolumeIndex(stream, &index); 501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 506de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 507de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 508fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 509fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 510de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 511de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 512de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 513de070137f11d346fba77605bd76a44c040a618fcEric Laurent 5146b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 5156b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 516fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 517fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 5186b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 5196b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 5206b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 5216b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 522de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 523de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 524de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 525de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 526de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 527de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 528de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 529de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 530de070137f11d346fba77605bd76a44c040a618fcEric Laurent 531de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 532de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 533de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 534de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 5357c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 536de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 537de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 538de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 539de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 5407c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 541de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 542de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 543de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 544de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 545de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 546de070137f11d346fba77605bd76a44c040a618fcEric Laurent 547de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 548de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 549de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 550de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 551de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 552de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 553de070137f11d346fba77605bd76a44c040a618fcEric Laurent 554eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 555eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 556eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent int stream = data.readInt32(); 557eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 558eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent reply->writeInt32( isStreamActive(stream, inPastMs) ); 559eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 560eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 561eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 562c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 563c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 564c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 565c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 566c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 567c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 568c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 569c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 570