IAudioPolicyService.cpp revision 892354335d49f0b9fcd10e20e0c13e3cd0f1f1cb
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 26e360f0f6cad290f69e07fd3a20dcf11a1dbc4160Eric Laurent#include <media/AudioEffect.h> 27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/IAudioPolicyService.h> 28c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2964760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h> 30fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin 31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android { 32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum { 34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, 35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_DEVICE_CONNECTION_STATE, 36c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_PHONE_STATE, 370b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7Glenn Kasten SET_RINGER_MODE, // reserved, no longer used 38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_FORCE_USE, 39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_FORCE_USE, 40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_OUTPUT, 41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_OUTPUT, 42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_OUTPUT, 43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_OUTPUT, 44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_INPUT, 45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_INPUT, 46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_INPUT, 47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_INPUT, 48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INIT_STREAM_VOLUME, 49c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_STREAM_VOLUME, 50de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STREAM_VOLUME, 51de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STRATEGY_FOR_STREAM, 52de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_OUTPUT_FOR_EFFECT, 53de070137f11d346fba77605bd76a44c040a618fcEric Laurent REGISTER_EFFECT, 54eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent UNREGISTER_EFFECT, 556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten IS_STREAM_ACTIVE, 56d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi IS_SOURCE_ACTIVE, 576b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten GET_DEVICES_FOR_STREAM, 58db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent QUERY_DEFAULT_PRE_PROCESSING, 59272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi SET_EFFECT_ENABLED, 60ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald IS_STREAM_ACTIVE_REMOTELY, 61ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald IS_OFFLOAD_SUPPORTED 62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 73fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 74fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 86fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 87fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 95fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 98f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 107fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 117fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 123fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 127fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 12958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 130254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 131ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald audio_output_flags_t flags, 132ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald const audio_offload_info_t *offloadInfo) 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)); 139254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 141b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (offloadInfo == NULL) { 142b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(0); 143b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } else { 144b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(1); 145b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(offloadInfo, sizeof(audio_offload_info_t)); 146b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 148fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 151de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 152fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 153de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 157fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 158fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 159de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 164de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 165fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 166de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 170fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 171fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 172de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 181fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 186eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 18858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 189254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 1907c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 194eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 197254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 1987c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 200fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 207fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 216fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 225fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 229fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 24383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 24483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 25083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 25583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 25683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 25783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 26283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 26383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 268c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 269de070137f11d346fba77605bd76a44c040a618fcEric Laurent 270fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 271de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 272de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 273de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 274de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 275de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 276de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 277de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 278de070137f11d346fba77605bd76a44c040a618fcEric Laurent 2796374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 2806b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2816b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2826b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2836b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2846b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2856374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 2866b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2876b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 28858e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) 289de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 290de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 291de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 292de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 293de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 294de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 295de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 296de070137f11d346fba77605bd76a44c040a618fcEric Laurent 29758e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual status_t registerEffect(const effect_descriptor_t *desc, 2987c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 303de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 304de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 305de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 3067c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 312de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 313de070137f11d346fba77605bd76a44c040a618fcEric Laurent 314de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 315de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 316de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 317de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 318de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 319de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 320de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 321de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 322de070137f11d346fba77605bd76a44c040a618fcEric Laurent 323db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 324db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 325db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 326db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 327db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 328db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 329db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 330db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 331db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 332db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 333fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 334eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 335eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 336eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 337fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 338eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 339eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 340eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 341eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 34257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 343272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 344272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi { 345272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi Parcel data, reply; 346272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 347272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32((int32_t) stream); 348272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32(inPastMs); 349272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); 350272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return reply.readInt32(); 351272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } 352272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 353d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi virtual bool isSourceActive(audio_source_t source) const 354d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi { 355d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi Parcel data, reply; 356d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 357d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInt32((int32_t) source); 358d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi remote()->transact(IS_SOURCE_ACTIVE, data, &reply); 359d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return reply.readInt32(); 360d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 361d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 36257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 36357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 36457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 36557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 36657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 36757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 36857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 36957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 37057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 37157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 37257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 37357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 37457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 37557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 37657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 37757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 37857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 37957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 38057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 38157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 38257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 38357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 38457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 38557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 386ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald 387ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald virtual bool isOffloadSupported(const audio_offload_info_t& info) 388ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald { 389b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald Parcel data, reply; 390b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 391b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(&info, sizeof(audio_offload_info_t)); 392b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); 393b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return reply.readInt32(); } 394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 404e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 407fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 408fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 409fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 410fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 412de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 413de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 414de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 420fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 421fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 423de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 424de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 425c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 427c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 429c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 43085ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState( 43185ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten (audio_mode_t) data.readInt32()))); 432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 43785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 43885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 439fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 440fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 446c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 44785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 44885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 449c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 455fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 456fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 457c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 45858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 459254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 4600ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 4610ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 462b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool hasOffloadInfo = data.readInt32() != 0; 463b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t offloadInfo; 464b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (hasOffloadInfo) { 465b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&offloadInfo, sizeof(audio_offload_info_t)); 466b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 470254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 471b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald flags, 472b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald hasOffloadInfo ? &offloadInfo : NULL); 473fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 479fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 480c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 481de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 482de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 483fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 484de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 488c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 490fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t stream = data.readInt32(); 492de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 493de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 494fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin (audio_stream_type_t)stream, 495de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 497c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 501fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 508eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 509c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 51058f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 511254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 5127c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 513c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 514c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 515c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 516254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 5177c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 518fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 519c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 520c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 522c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 523c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 524fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 525c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 526c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 530c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 531fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 532c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 533c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 534c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 535c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 537c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 538fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 540c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 541c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 542c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 543c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 544c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 545fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 546fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 547c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 548c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 549c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 550c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 551c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 552c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 553c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 554c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 555fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 556fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 557c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 55883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 55983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 56083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 56183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 562c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 563c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 564c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 565c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 566c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 567fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 568fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 56983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 570892354335d49f0b9fcd10e20e0c13e3cd0f1f1cbRobert Shih int index = 0; 57183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 572c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 573c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 574c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 575c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 576c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 577de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 578de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 579fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 580fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 581de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 582de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 583de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 584de070137f11d346fba77605bd76a44c040a618fcEric Laurent 5856b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 5866b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 587fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 588fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 5896b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 5906b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 5916b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 5926b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 593de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 594de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 595de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 596de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 597de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 598de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 599de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 600de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 601de070137f11d346fba77605bd76a44c040a618fcEric Laurent 602de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 603de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 604de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 605de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 6067c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 607de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 608de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 609de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 610de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 6117c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 612de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 613de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 614de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 615de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 616de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 617de070137f11d346fba77605bd76a44c040a618fcEric Laurent 618de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 619de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 620de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 621de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 622de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 623de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 624de070137f11d346fba77605bd76a44c040a618fcEric Laurent 625db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 626db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 627db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 628db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 629db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 630db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 631db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 632db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 633eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 634eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 635fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 636eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 637fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) ); 638eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 639eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 640eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 641272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi case IS_STREAM_ACTIVE_REMOTELY: { 642272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 643272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 644272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi uint32_t inPastMs = (uint32_t)data.readInt32(); 645272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi reply->writeInt32( isStreamActiveRemotely((audio_stream_type_t) stream, inPastMs) ); 646272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return NO_ERROR; 647272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } break; 648272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 649d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi case IS_SOURCE_ACTIVE: { 650d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 651d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi audio_source_t source = (audio_source_t) data.readInt32(); 652d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi reply->writeInt32( isSourceActive(source)); 653d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return NO_ERROR; 654d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 655d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 65657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 65757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 65857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 65957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 660e360f0f6cad290f69e07fd3a20dcf11a1dbc4160Eric Laurent if (count > AudioEffect::kMaxPreProcessing) { 661e360f0f6cad290f69e07fd3a20dcf11a1dbc4160Eric Laurent count = AudioEffect::kMaxPreProcessing; 662e360f0f6cad290f69e07fd3a20dcf11a1dbc4160Eric Laurent } 66357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 664e360f0f6cad290f69e07fd3a20dcf11a1dbc4160Eric Laurent effect_descriptor_t *descriptors = new effect_descriptor_t[count]; 66557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 66657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 66757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 66857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 66957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 67057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 671e360f0f6cad290f69e07fd3a20dcf11a1dbc4160Eric Laurent if (retCount != 0) { 67257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 67357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 67457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 67557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 67657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 67757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 67857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 67957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 68057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 681b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald case IS_OFFLOAD_SUPPORTED: { 682b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald CHECK_INTERFACE(IAudioPolicyService, data, reply); 683b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t info; 684b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&info, sizeof(audio_offload_info_t)); 685b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool isSupported = isOffloadSupported(info); 686b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald reply->writeInt32(isSupported); 687b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return NO_ERROR; 688b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 689b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald 690c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 691c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 692c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 693c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 694c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 695c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 696c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 697c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 698