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