IAudioPolicyService.cpp revision 203b1a18a806e2c56c701aac49cda963bccfad5b
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, 55d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi IS_SOURCE_ACTIVE, 566b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten GET_DEVICES_FOR_STREAM, 57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent QUERY_DEFAULT_PRE_PROCESSING, 58272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi SET_EFFECT_ENABLED, 59ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald IS_STREAM_ACTIVE_REMOTELY, 60203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent IS_OFFLOAD_SUPPORTED, 61203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent LIST_AUDIO_PORTS, 62203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent GET_AUDIO_PORT, 63203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CREATE_AUDIO_PATCH, 64203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent RELEASE_AUDIO_PATCH, 65203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent LIST_AUDIO_PATCHES, 66203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent SET_AUDIO_PORT_CONFIG 67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 78fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 79fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 91fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 92fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 100fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 103f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 112fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 122fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 128fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 132fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 13458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 135254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 136ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald audio_output_flags_t flags, 137ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald const audio_offload_info_t *offloadInfo) 138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 144254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 1462301acc6a9c7a3af4ad01f3d1d0f76f13eca7350Glenn Kasten // hasOffloadInfo 147b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (offloadInfo == NULL) { 148b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(0); 149b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } else { 150b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(1); 151b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(offloadInfo, sizeof(audio_offload_info_t)); 152b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 154fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 157de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 158fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 159de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 163fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 164fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 165de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 170de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 171fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 172de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 176fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 177fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 178de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 187fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 192eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 19458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 195254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 1967c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 200eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 203254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 2047c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 206fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 213fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 222fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 231fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 235fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 24983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 25083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 25683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 26183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 26283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 26383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 26883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 26983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 270c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 271c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 272c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 273c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 274c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 275de070137f11d346fba77605bd76a44c040a618fcEric Laurent 276fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 277de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 278de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 279de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 280de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 281de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 282de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 283de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 284de070137f11d346fba77605bd76a44c040a618fcEric Laurent 2856374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 2866b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2876b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2886b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2896b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2906b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2916374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 2926b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2936b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 29458e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) 295de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 296de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 297de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 298de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent 30358e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual status_t registerEffect(const effect_descriptor_t *desc, 3047c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 305de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 306de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 3127c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 313de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 314de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 315de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 316de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 317de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 318de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 319de070137f11d346fba77605bd76a44c040a618fcEric Laurent 320de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 321de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 322de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 323de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 324de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 325de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 326de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 327de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 328de070137f11d346fba77605bd76a44c040a618fcEric Laurent 329db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 330db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 331db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 332db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 333db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 334db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 335db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 336db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 337db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 338db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 339fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 340eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 341eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 342eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 343fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 344eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 345eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 346eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 347eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 34857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 349272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 350272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi { 351272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi Parcel data, reply; 352272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 353272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32((int32_t) stream); 354272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32(inPastMs); 355272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); 356272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return reply.readInt32(); 357272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } 358272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 359d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi virtual bool isSourceActive(audio_source_t source) const 360d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi { 361d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi Parcel data, reply; 362d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 363d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInt32((int32_t) source); 364d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi remote()->transact(IS_SOURCE_ACTIVE, data, &reply); 365d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return reply.readInt32(); 366d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 367d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 36857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 36957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 37057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 37157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 37257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 37357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 37457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 37557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 37657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 37757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 37857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 37957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 38057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 38157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 38257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 38357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 38457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 38557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 38657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 38757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 38857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 38957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 39057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 39157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 392ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald 393ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald virtual bool isOffloadSupported(const audio_offload_info_t& info) 394ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald { 395b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald Parcel data, reply; 396b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 397b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(&info, sizeof(audio_offload_info_t)); 398b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); 399203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return reply.readInt32(); 400203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 401203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 402203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPorts(audio_port_role_t role, 403203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type, 404203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *num_ports, 405203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports, 406203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 407203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 408203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_ports == NULL || (*num_ports != 0 && ports == NULL) || 409203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 410203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 411203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 412203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 413203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 414203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports; 415203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(role); 416203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(type); 417203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPortsReq); 418203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); 419203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 420203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 421203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_ports = (unsigned int)reply.readInt32(); 422203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 423203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent ALOGI("listAudioPorts() status %d got *num_ports %d", status, *num_ports); 424203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 425203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > *num_ports) { 426203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = *num_ports; 427203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 428203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > 0) { 429203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(ports, numPortsReq * sizeof(struct audio_port)); 430203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 431203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 432203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 433203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 434203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 435203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 436203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t getAudioPort(struct audio_port *port) 437203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 438203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (port == NULL) { 439203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 440203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 441203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 442203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 443203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(port, sizeof(struct audio_port)); 444203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); 445203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 446203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 447203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 448203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 449203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(port, sizeof(struct audio_port)); 450203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 451203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 452203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 453203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t createAudioPatch(const struct audio_patch *patch, 454203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t *handle) 455203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 456203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (patch == NULL || handle == NULL) { 457203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 458203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 459203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 460203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 461203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(patch, sizeof(struct audio_patch)); 462203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(handle, sizeof(audio_patch_handle_t)); 463203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); 464203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 465203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 466203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 467203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 468203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(handle, sizeof(audio_patch_handle_t)); 469203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 470203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 471203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 472203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t releaseAudioPatch(audio_patch_handle_t handle) 473203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 474203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 475203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 476203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(&handle, sizeof(audio_patch_handle_t)); 477203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); 478203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 479203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 480203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 481203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 482203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 483203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 484203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPatches(unsigned int *num_patches, 485203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches, 486203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 487203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 488203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_patches == NULL || (*num_patches != 0 && patches == NULL) || 489203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 490203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 491203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 492203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 493203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 494203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches; 495203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPatchesReq); 496203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); 497203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 498203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 499203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_patches = (unsigned int)reply.readInt32(); 500203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 501203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 502203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > *num_patches) { 503203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = *num_patches; 504203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 505203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > 0) { 506203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(patches, numPatchesReq * sizeof(struct audio_patch)); 507203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 508203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 509203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 510203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 511203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 512203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 513203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t setAudioPortConfig(const struct audio_port_config *config) 514203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 515203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (config == NULL) { 516203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 517203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 518203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 519203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 520203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(config, sizeof(struct audio_port_config)); 521203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); 522203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 523203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 524203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 525203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 526203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 530c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 531c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 532c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 533c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 534c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 535c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 537e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 538c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 540fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 541fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 542fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 543fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 544c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 545de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 546de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 547de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 548c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 549c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 550c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 551c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 552c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 553fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 554fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 555c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 556de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 557de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 558c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 559c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 560c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 561c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 562c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 56385ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState( 56485ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten (audio_mode_t) data.readInt32()))); 565c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 566c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 567c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 568c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 569c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 57085ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 57185ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 572fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 573fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 574c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 575c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 576c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 577c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 578c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 579c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 58085ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 58185ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 582c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 583c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 584c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 585c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 586c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 587c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 588fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 589fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 590c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 59158f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 592254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 5930ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 5940ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 595b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool hasOffloadInfo = data.readInt32() != 0; 596b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t offloadInfo; 597b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (hasOffloadInfo) { 598b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&offloadInfo, sizeof(audio_offload_info_t)); 599b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 600c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 601c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 602c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 603254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 604b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald flags, 605b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald hasOffloadInfo ? &offloadInfo : NULL); 606fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 607c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 608c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 609c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 610c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 611c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 612fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 613ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 614ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 615de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 616de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 617ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 618de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 619c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 620c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 621c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 622c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 623c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 624fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 625ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 626ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 627de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 628de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 629ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 630de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 631c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 632c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 633c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 634c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 635c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 636fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 637c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 638c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 639c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 640c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 641c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 642c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 643eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 644c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 64558f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 646254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 6477c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 648c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 649c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 650c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 651254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 6527c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 653fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 654c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 655c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 656c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 657c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 658c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 659fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 660c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 661c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 662c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 663c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 664c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 665c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 666fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 667c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 668c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 669c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 670c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 671c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 672c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 673fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 674c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 675c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 676c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 677c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 678c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 679c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 680fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 681fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 682c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 683c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 684c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 685c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 686c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 687c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 688c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 689c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 690fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 691fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 692c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 69383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 69483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 69583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 69683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 697c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 698c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 699c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 700c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 701c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 702fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 703fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 70483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 705c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 70683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 707c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 708c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 709c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 710c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 711c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 712de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 713de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 714fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 715fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 716de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 717de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 718de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 719de070137f11d346fba77605bd76a44c040a618fcEric Laurent 7206b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 7216b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 722fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 723fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 7246b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 7256b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 7266b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 7276b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 728de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 729de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 730de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 731de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 732de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 733de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 734de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 735de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 736de070137f11d346fba77605bd76a44c040a618fcEric Laurent 737de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 738de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 739de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 740de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 7417c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 742de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 743de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 744de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 745de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 7467c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 747de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 748de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 749de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 750de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 751de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 752de070137f11d346fba77605bd76a44c040a618fcEric Laurent 753de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 754de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 755de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 756de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 757de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 758de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 759de070137f11d346fba77605bd76a44c040a618fcEric Laurent 760db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 761db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 762db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 763db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 764db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 765db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 766db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 767db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 768eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 769eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 770fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 771eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 772ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActive(stream, inPastMs) ); 773eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 774eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 775eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 776272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi case IS_STREAM_ACTIVE_REMOTELY: { 777272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 778272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 779272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi uint32_t inPastMs = (uint32_t)data.readInt32(); 780ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); 781272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return NO_ERROR; 782272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } break; 783272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 784d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi case IS_SOURCE_ACTIVE: { 785d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 786d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi audio_source_t source = (audio_source_t) data.readInt32(); 787d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi reply->writeInt32( isSourceActive(source)); 788d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return NO_ERROR; 789d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 790d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 79157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 79257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 79357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 79457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 79557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 79657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 79757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 79857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 79957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 80057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 80157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 80257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 80357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 80457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 80557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 80657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 80757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 80857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 80957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 81057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 81157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 81257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 81357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 814b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald case IS_OFFLOAD_SUPPORTED: { 815b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald CHECK_INTERFACE(IAudioPolicyService, data, reply); 816b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t info; 817b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&info, sizeof(audio_offload_info_t)); 818b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool isSupported = isOffloadSupported(info); 819b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald reply->writeInt32(isSupported); 820b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return NO_ERROR; 821b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 822b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald 823203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PORTS: { 824203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 825203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_role_t role = (audio_port_role_t)data.readInt32(); 826203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type = (audio_port_type_t)data.readInt32(); 827203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = data.readInt32(); 828203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPorts = numPortsReq; 829203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 830203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports = 831203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_port *)calloc(numPortsReq, sizeof(struct audio_port)); 832203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPorts(role, type, &numPorts, ports, &generation); 833203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 834203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPorts); 835203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent ALOGI("LIST_AUDIO_PORTS status %d got numPorts %d", status, numPorts); 836203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 837203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 838203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > numPorts) { 839203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = numPorts; 840203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 841203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(ports, numPortsReq * sizeof(struct audio_port)); 842203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 843203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 844203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(ports); 845203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 846203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 847203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 848203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case GET_AUDIO_PORT: { 849203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 850203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port port; 851203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&port, sizeof(struct audio_port)); 852203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = getAudioPort(&port); 853203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 854203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 855203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&port, sizeof(struct audio_port)); 856203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 857203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 858203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 859203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 860203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case CREATE_AUDIO_PATCH: { 861203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 862203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch patch; 863203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&patch, sizeof(struct audio_patch)); 864203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 865203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 866203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = createAudioPatch(&patch, &handle); 867203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 868203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 869203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&handle, sizeof(audio_patch_handle_t)); 870203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 871203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 872203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 873203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 874203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case RELEASE_AUDIO_PATCH: { 875203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 876203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 877203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 878203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = releaseAudioPatch(handle); 879203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 880203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 881203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 882203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 883203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PATCHES: { 884203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 885203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = data.readInt32(); 886203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatches = numPatchesReq; 887203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 888203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches = 889203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_patch *)calloc(numPatchesReq, 890203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent sizeof(struct audio_patch)); 891203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPatches(&numPatches, patches, &generation); 892203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 893203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPatches); 894203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 895203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > numPatches) { 896203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = numPatches; 897203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 898203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); 899203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 900203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 901203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(patches); 902203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 903203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 904203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 905203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case SET_AUDIO_PORT_CONFIG: { 906203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 907203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port_config config; 908203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&config, sizeof(struct audio_port_config)); 909203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = setAudioPortConfig(&config); 910203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 911203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 912203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 913203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 914c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 915c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 916c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 917c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 918c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 919c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 920c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 921c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 922