IAudioPolicyService.cpp revision 254af180475346b6186b49c297f340c9c4817511
1c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent/* 2c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 3c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Copyright 2009, The Android Open Source Project 4c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 5c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Licensed under the Apache License, Version 2.0 (the "License"); 6c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** you may not use this file except in compliance with the License. 7c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** You may obtain a copy of the License at 8c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 9c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** http://www.apache.org/licenses/LICENSE-2.0 10c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 11c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Unless required by applicable law or agreed to in writing, software 12c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** distributed under the License is distributed on an "AS IS" BASIS, 13c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** See the License for the specific language governing permissions and 15c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** limitations under the License. 16c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent*/ 17c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 18c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#define LOG_TAG "IAudioPolicyService" 19c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <utils/Log.h> 20c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 21c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <stdint.h> 22c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <sys/types.h> 23c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <binder/Parcel.h> 25c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 26c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/IAudioPolicyService.h> 27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2864760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h> 29fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin 30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android { 31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum { 33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, 34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_DEVICE_CONNECTION_STATE, 35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_PHONE_STATE, 360b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7Glenn Kasten SET_RINGER_MODE, // reserved, no longer used 37c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_FORCE_USE, 38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_FORCE_USE, 39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_OUTPUT, 40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_OUTPUT, 41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_OUTPUT, 42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_OUTPUT, 43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_INPUT, 44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_INPUT, 45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_INPUT, 46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_INPUT, 47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INIT_STREAM_VOLUME, 48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_STREAM_VOLUME, 49de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STREAM_VOLUME, 50de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STRATEGY_FOR_STREAM, 51de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_OUTPUT_FOR_EFFECT, 52de070137f11d346fba77605bd76a44c040a618fcEric Laurent REGISTER_EFFECT, 53eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent UNREGISTER_EFFECT, 546b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten IS_STREAM_ACTIVE, 556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten GET_DEVICES_FOR_STREAM, 56db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent QUERY_DEFAULT_PRE_PROCESSING, 57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent SET_EFFECT_ENABLED 58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 69fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 70fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 82fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 83fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 91fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 94f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 103fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 113fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 119fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 123fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 12558f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 126254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 1270ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags) 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 134254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 137fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 140de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 141fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 142de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 146fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 147fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 148de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 153de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 154fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 155de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 159fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 160fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 161de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 170fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 171c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 175eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 17758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 178254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 1797c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 183eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 186254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 1877c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 189fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 196fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 205fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 214fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 218fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 23183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 23283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 23383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 23983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 24583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 24683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 25183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 25283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 258de070137f11d346fba77605bd76a44c040a618fcEric Laurent 259fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 260de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 261de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 262de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 263de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 264de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 265de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 266de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 267de070137f11d346fba77605bd76a44c040a618fcEric Laurent 2686374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 2696b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2706b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2716b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2726b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2736b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2746374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 2756b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2766b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 277de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) 278de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 279de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 280de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 281de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 282de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 283de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 284de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 285de070137f11d346fba77605bd76a44c040a618fcEric Laurent 286de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t registerEffect(effect_descriptor_t *desc, 2877c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 288de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 289de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 290de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 291de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 292de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 293de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 294de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 2957c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 296de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 297de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 298de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent 303de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 304de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 305de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 306de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent 312db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 313db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 314db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 315db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 316db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 317db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 318db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 319db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 320db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 321db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 322fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 323eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 324eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 325eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 326fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 327eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 328eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 329eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 330eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 33157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 33257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 33357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 33457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 33557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 33657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 33757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 33857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 33957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 34057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 34157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 34257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 34357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 34457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 34557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 34657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 34757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 34857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 34957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 35057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 35157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 35257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 35357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 35457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 35557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 356c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 366e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 369fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 370fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 371fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 372fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 374de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 375de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 376de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 377c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 379c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 380c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 382fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 383fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 384c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 385de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 386de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 387c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 388c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 390c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 392f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState((audio_mode_t) data.readInt32()))); 393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 398fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); 399fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 400fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 407fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32()); 408c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 409c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 412c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 413c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 414fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 415fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 41758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 418254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 4190ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 4200ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 424c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 425254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent flags); 427fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 429c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 430c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 431c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 433fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 435de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 436de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 437fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 438de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 439c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 440c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 444fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 446de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 447de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 448fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 449de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 455fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 457c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 458c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 459c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 460c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 461c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 462eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 463c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 46458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 465254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 4667c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 470254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 4717c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 472fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 478fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 479c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 480c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 481c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 482c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 483c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 485fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 488c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 492fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 493c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 494c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 495c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 497c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 499fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 500fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 508c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 509fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 510fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 511c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 51283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 51383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 51483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 51583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 516c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 517c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 518c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 519c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 520c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 521fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 522fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 52383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 524c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 52583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 526c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 530c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 531de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 532de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 533fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 534fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 535de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 536de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 537de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 538de070137f11d346fba77605bd76a44c040a618fcEric Laurent 5396b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 5406b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 541fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 542fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 5436b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 5446b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 5456b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 5466b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 547de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 548de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 549de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 550de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 551de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 552de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 553de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 554de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 555de070137f11d346fba77605bd76a44c040a618fcEric Laurent 556de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 557de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 558de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 559de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 5607c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 561de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 562de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 563de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 564de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 5657c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 566de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 567de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 568de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 569de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 570de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 571de070137f11d346fba77605bd76a44c040a618fcEric Laurent 572de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 573de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 574de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 575de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 576de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 577de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 578de070137f11d346fba77605bd76a44c040a618fcEric Laurent 579db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 580db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 581db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 582db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 583db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 584db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 585db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 586db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 587eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 588eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 589fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 590eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 591fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) ); 592eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 593eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 594eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 59557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 59657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 59757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 59857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 59957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 60057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 60157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 60257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 60357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 60457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 60557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 60657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 60757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 60857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 60957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 61057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 61157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 61257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 61357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 61457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 61557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 61657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 61757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 618c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 619c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 620c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 621c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 622c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 623c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 624c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 625c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 626