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