IAudioPolicyService.cpp revision b52c152d553556b2d227ffc943489de0c60b4b02
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, 66b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent SET_AUDIO_PORT_CONFIG, 67b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent REGISTER_CLIENT 68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 79fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 80fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 92fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 93fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 101fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 104f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 113fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 123fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 129fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 133fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 13558f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 136254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 137ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald audio_output_flags_t flags, 138ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald const audio_offload_info_t *offloadInfo) 139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 145254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 1472301acc6a9c7a3af4ad01f3d1d0f76f13eca7350Glenn Kasten // hasOffloadInfo 148b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (offloadInfo == NULL) { 149b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(0); 150b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } else { 151b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(1); 152b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(offloadInfo, sizeof(audio_offload_info_t)); 153b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 155fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 158de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 159fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 160de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 164fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 165fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 166de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 171de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 172fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 173de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 177fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 178fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 179de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 188fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 193eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 19558f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 196254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 1977c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 201eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 204254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 2057c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 207fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 214fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 223fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 232fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 236fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 25083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 25183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 25783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 26283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 26383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 26483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 268c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 26983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 27083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 271c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 272c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 273c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 274c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 275c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 276de070137f11d346fba77605bd76a44c040a618fcEric Laurent 277fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 278de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 279de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 280de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 281de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 282de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 283de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 284de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 285de070137f11d346fba77605bd76a44c040a618fcEric Laurent 2866374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 2876b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 2886b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 2896b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 2906b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 2916b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 2926374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 2936b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 2946b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 29558e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) 296de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 297de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 298de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 299de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 300de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 301de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 302de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 303de070137f11d346fba77605bd76a44c040a618fcEric Laurent 30458e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual status_t registerEffect(const effect_descriptor_t *desc, 3057c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 306de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 308de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 312de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 3137c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 314de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 315de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 316de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 317de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 318de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 319de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 320de070137f11d346fba77605bd76a44c040a618fcEric Laurent 321de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 322de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 323de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 324de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 325de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 326de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 327de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 328de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 329de070137f11d346fba77605bd76a44c040a618fcEric Laurent 330db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 331db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 332db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 333db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 334db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 335db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 336db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 337db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 338db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 339db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 340fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 341eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 342eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 343eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 344fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 345eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 346eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 347eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 348eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 34957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 350272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 351272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi { 352272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi Parcel data, reply; 353272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 354272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32((int32_t) stream); 355272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32(inPastMs); 356272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); 357272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return reply.readInt32(); 358272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } 359272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 360d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi virtual bool isSourceActive(audio_source_t source) const 361d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi { 362d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi Parcel data, reply; 363d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 364d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInt32((int32_t) source); 365d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi remote()->transact(IS_SOURCE_ACTIVE, data, &reply); 366d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return reply.readInt32(); 367d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 368d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 36957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 37057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 37157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 37257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 37357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 37457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 37557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 37657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 37757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 37857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 37957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 38057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 38157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 38257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 38357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 38457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 38557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 38657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 38757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 38857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 38957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 39057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 39157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 39257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 393ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald 394ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald virtual bool isOffloadSupported(const audio_offload_info_t& info) 395ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald { 396b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald Parcel data, reply; 397b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 398b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(&info, sizeof(audio_offload_info_t)); 399b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); 400203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return reply.readInt32(); 401203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 402203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 403203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPorts(audio_port_role_t role, 404203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type, 405203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *num_ports, 406203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports, 407203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 408203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 409203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_ports == NULL || (*num_ports != 0 && ports == NULL) || 410203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 411203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 412203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 413203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 414203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 415203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports; 416203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(role); 417203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(type); 418203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPortsReq); 419203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); 420203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 421203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 422203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_ports = (unsigned int)reply.readInt32(); 423203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 424203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent ALOGI("listAudioPorts() status %d got *num_ports %d", status, *num_ports); 425203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 426203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > *num_ports) { 427203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = *num_ports; 428203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 429203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > 0) { 430203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(ports, numPortsReq * sizeof(struct audio_port)); 431203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 432203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 433203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 434203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 435203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 436203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 437203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t getAudioPort(struct audio_port *port) 438203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 439203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (port == NULL) { 440203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 441203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 442203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 443203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 444203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(port, sizeof(struct audio_port)); 445203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); 446203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 447203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 448203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 449203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 450203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(port, sizeof(struct audio_port)); 451203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 452203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 453203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 454203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t createAudioPatch(const struct audio_patch *patch, 455203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t *handle) 456203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 457203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (patch == NULL || handle == NULL) { 458203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 459203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 460203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 461203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 462203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(patch, sizeof(struct audio_patch)); 463203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(handle, sizeof(audio_patch_handle_t)); 464203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); 465203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 466203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 467203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 468203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 469203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(handle, sizeof(audio_patch_handle_t)); 470203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 471203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 472203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 473203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t releaseAudioPatch(audio_patch_handle_t handle) 474203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 475203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 476203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 477203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(&handle, sizeof(audio_patch_handle_t)); 478203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); 479203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 480203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 481203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 482203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 483203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 484203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 485203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPatches(unsigned int *num_patches, 486203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches, 487203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 488203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 489203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_patches == NULL || (*num_patches != 0 && patches == NULL) || 490203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 491203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 492203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 493203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 494203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 495203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches; 496203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPatchesReq); 497203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); 498203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 499203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 500203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_patches = (unsigned int)reply.readInt32(); 501203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 502203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 503203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > *num_patches) { 504203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = *num_patches; 505203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 506203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > 0) { 507203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(patches, numPatchesReq * sizeof(struct audio_patch)); 508203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 509203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 510203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 511203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 512203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 513203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 514203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t setAudioPortConfig(const struct audio_port_config *config) 515203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 516203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (config == NULL) { 517203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 518203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 519203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 520203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 521203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(config, sizeof(struct audio_port_config)); 522203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); 523203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 524203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 525203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 526203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 527203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 528b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) 529b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent { 530b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent Parcel data, reply; 531b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 532b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.writeStrongBinder(client->asBinder()); 533b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent remote()->transact(REGISTER_CLIENT, data, &reply); 534b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent } 535c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 537c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 538c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 540c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 541c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 542c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 543c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 544c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 545e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 546c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 547c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 548fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 549fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 550fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 551fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 552c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 553de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 554de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 555de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 556c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 557c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 558c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 559c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 560c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 561fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 562fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 563c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 564de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 565de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 566c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 567c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 568c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 569c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 570c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 57185ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState( 57285ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten (audio_mode_t) data.readInt32()))); 573c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 574c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 575c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 576c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 577c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 57885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 57985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 580fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 581fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 582c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 583c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 584c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 585c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 586c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 587c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 58885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 58985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 590c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 591c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 592c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 593c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 594c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 595c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 596fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 597fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 598c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 59958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 600254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 6010ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 6020ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 603b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool hasOffloadInfo = data.readInt32() != 0; 604b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t offloadInfo; 605b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (hasOffloadInfo) { 606b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&offloadInfo, sizeof(audio_offload_info_t)); 607b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 608c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 609c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 610c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 611254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 612b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald flags, 613b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald hasOffloadInfo ? &offloadInfo : NULL); 614fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 615c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 616c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 617c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 618c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 619c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 620fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 621ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 622ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 623de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 624de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 625ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 626de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 627c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 628c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 629c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 630c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 631c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 632fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 633ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 634ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 635de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 636de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 637ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 638de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 639c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 640c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 641c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 642c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 643c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 644fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 645c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 646c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 647c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 648c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 649c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 650c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 651eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 652c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 65358f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 654254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 6557c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 656c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 657c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 658c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 659254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 6607c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 661fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 662c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 663c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 664c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 665c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 666c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 667fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 668c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 669c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 670c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 671c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 672c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 673c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 674fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 675c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 676c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 677c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 678c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 679c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 680c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 681fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 682c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 683c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 684c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 685c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 686c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 687c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 688fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 689fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 690c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 691c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 692c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 693c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 694c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 695c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 696c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 697c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 698fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 699fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 700c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 70183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 70283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 70383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 70483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 705c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 706c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 707c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 708c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 709c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 710fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 711fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 71283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 713c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 71483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 715c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 716c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 717c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 718c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 719c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 720de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 721de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 722fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 723fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 724de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 725de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 726de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 727de070137f11d346fba77605bd76a44c040a618fcEric Laurent 7286b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 7296b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 730fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 731fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 7326b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 7336b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 7346b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 7356b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 736de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 737de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 738de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 739de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 740de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 741de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 742de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 743de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 744de070137f11d346fba77605bd76a44c040a618fcEric Laurent 745de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 746de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 747de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 748de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 7497c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 750de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 751de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 752de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 753de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 7547c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 755de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 756de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 757de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 758de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 759de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 760de070137f11d346fba77605bd76a44c040a618fcEric Laurent 761de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 762de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 763de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 764de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 765de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 766de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 767de070137f11d346fba77605bd76a44c040a618fcEric Laurent 768db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 769db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 770db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 771db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 772db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 773db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 774db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 775db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 776eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 777eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 778fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 779eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 780ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActive(stream, inPastMs) ); 781eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 782eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 783eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 784272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi case IS_STREAM_ACTIVE_REMOTELY: { 785272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 786272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 787272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi uint32_t inPastMs = (uint32_t)data.readInt32(); 788ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); 789272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return NO_ERROR; 790272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } break; 791272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 792d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi case IS_SOURCE_ACTIVE: { 793d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 794d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi audio_source_t source = (audio_source_t) data.readInt32(); 795d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi reply->writeInt32( isSourceActive(source)); 796d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return NO_ERROR; 797d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 798d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 79957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 80057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 80157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 80257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 80357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 80457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 80557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 80657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 80757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 80857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 80957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 81057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 81157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 81257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 81357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 81457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 81557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 81657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 81757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 81857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 81957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 82057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 82157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 822b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald case IS_OFFLOAD_SUPPORTED: { 823b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald CHECK_INTERFACE(IAudioPolicyService, data, reply); 824b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t info; 825b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&info, sizeof(audio_offload_info_t)); 826b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool isSupported = isOffloadSupported(info); 827b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald reply->writeInt32(isSupported); 828b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return NO_ERROR; 829b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 830b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald 831203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PORTS: { 832203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 833203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_role_t role = (audio_port_role_t)data.readInt32(); 834203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type = (audio_port_type_t)data.readInt32(); 835203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = data.readInt32(); 836203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPorts = numPortsReq; 837203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 838203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports = 839203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_port *)calloc(numPortsReq, sizeof(struct audio_port)); 840203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPorts(role, type, &numPorts, ports, &generation); 841203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 842203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPorts); 843203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent ALOGI("LIST_AUDIO_PORTS status %d got numPorts %d", status, numPorts); 844203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 845203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 846203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > numPorts) { 847203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = numPorts; 848203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 849203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(ports, numPortsReq * sizeof(struct audio_port)); 850203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 851203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 852203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(ports); 853203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 854203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 855203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 856203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case GET_AUDIO_PORT: { 857203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 858203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port port; 859203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&port, sizeof(struct audio_port)); 860203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = getAudioPort(&port); 861203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 862203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 863203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&port, sizeof(struct audio_port)); 864203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 865203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 866203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 867203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 868203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case CREATE_AUDIO_PATCH: { 869203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 870203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch patch; 871203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&patch, sizeof(struct audio_patch)); 872203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 873203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 874203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = createAudioPatch(&patch, &handle); 875203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 876203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 877203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&handle, sizeof(audio_patch_handle_t)); 878203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 879203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 880203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 881203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 882203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case RELEASE_AUDIO_PATCH: { 883203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 884203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 885203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 886203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = releaseAudioPatch(handle); 887203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 888203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 889203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 890203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 891203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PATCHES: { 892203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 893203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = data.readInt32(); 894203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatches = numPatchesReq; 895203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 896203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches = 897203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_patch *)calloc(numPatchesReq, 898203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent sizeof(struct audio_patch)); 899203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPatches(&numPatches, patches, &generation); 900203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 901203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPatches); 902203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 903203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > numPatches) { 904203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = numPatches; 905203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 906203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); 907203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 908203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 909203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(patches); 910203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 911203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 912203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 913203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case SET_AUDIO_PORT_CONFIG: { 914203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 915203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port_config config; 916203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&config, sizeof(struct audio_port_config)); 917203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = setAudioPortConfig(&config); 918203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 919203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 920203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 921b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent case REGISTER_CLIENT: { 922b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 923b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( 924b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.readStrongBinder()); 925b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent registerClient(client); 926b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent return NO_ERROR; 927b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent } break; 928203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 929c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 930c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 931c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 932c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 933c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 934c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 935c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 936c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 937