IAudioPolicyService.cpp revision bb6c9a05840d924b502ce0f1868fca4881ada1ed
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, 675bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi REGISTER_CLIENT, 68df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent GET_OUTPUT_FOR_ATTR, 69df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent ACQUIRE_SOUNDTRIGGER_SESSION, 70bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent RELEASE_SOUNDTRIGGER_SESSION, 71bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent GET_PHONE_STATE 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 83fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 84fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 96fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 97fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 105fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 108f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 117fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 127fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 133fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 137fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 13958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 140254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 141ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald audio_output_flags_t flags, 142ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald const audio_offload_info_t *offloadInfo) 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 149254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 1512301acc6a9c7a3af4ad01f3d1d0f76f13eca7350Glenn Kasten // hasOffloadInfo 152b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (offloadInfo == NULL) { 153b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(0); 154b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } else { 155b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(1); 156b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(offloadInfo, sizeof(audio_offload_info_t)); 157b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 159fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 1625bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi virtual audio_io_handle_t getOutputForAttr( 1635bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi const audio_attributes_t *attr, 1645bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi uint32_t samplingRate, 1655bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_format_t format, 1665bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_channel_mask_t channelMask, 1675bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_output_flags_t flags, 1685bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi const audio_offload_info_t *offloadInfo) 1695bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi { 1705bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi Parcel data, reply; 1715bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 1725bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi if (attr == NULL) { 1735bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi ALOGE("Writing NULL audio attributes - shouldn't happen"); 1745bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi return (audio_io_handle_t) 0; 1755bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 1765bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.write(attr, sizeof(audio_attributes_t)); 1775bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(samplingRate); 1785bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(static_cast <uint32_t>(format)); 1795bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(channelMask); 1805bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(static_cast <uint32_t>(flags)); 1815bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi // hasOffloadInfo 1825bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi if (offloadInfo == NULL) { 1835bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(0); 1845bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } else { 1855bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(1); 1865bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.write(offloadInfo, sizeof(audio_offload_info_t)); 1875bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 1885bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi remote()->transact(GET_OUTPUT_FOR_ATTR, data, &reply); 1895bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi return static_cast <audio_io_handle_t> (reply.readInt32()); 1905bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 1915bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi 192de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 193fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 194de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 198fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 199fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 200de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 205de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 206fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 207de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 211fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 212fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 213de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 222fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 227eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 22958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 230254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 231b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten int audioSession, 232b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten audio_input_flags_t flags) 233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 236eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 239254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 2407c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 241b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten data.writeInt32(flags); 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 243fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2464dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent virtual status_t startInput(audio_io_handle_t input, 2474dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent audio_session_t session) 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 251fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 2524dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent data.writeInt32(session); 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2574dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent virtual status_t stopInput(audio_io_handle_t input, 2584dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent audio_session_t session) 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 262fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 2634dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent data.writeInt32(session); 264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2684dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent virtual void releaseInput(audio_io_handle_t input, 2694dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent audio_session_t session) 270c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 271c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 272c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 273fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 2744dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent data.writeInt32(session); 275c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 276c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 277c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 278fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 279c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 280c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 281c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 282c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 283c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 284c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 285c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 286c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 287c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 288c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 289c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 290c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 29183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 29283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 29383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 294c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 295c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 296c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 297c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 298c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 29983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 300c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 301c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 302c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 303c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 30483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 30583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 30683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 307c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 308c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 309c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 310c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 31183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 31283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 313c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 314c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 315c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 316c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 317c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 318de070137f11d346fba77605bd76a44c040a618fcEric Laurent 319fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 320de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 321de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 322de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 323de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 324de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 325de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 326de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 327de070137f11d346fba77605bd76a44c040a618fcEric Laurent 3286374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 3296b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 3306b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 3316b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 3326b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 3336b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 3346374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 3356b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 3366b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 33758e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) 338de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 339de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 340de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 341de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 342de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 343de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 344de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 345de070137f11d346fba77605bd76a44c040a618fcEric Laurent 34658e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual status_t registerEffect(const effect_descriptor_t *desc, 3477c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 348de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 349de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 350de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 351de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 352de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 353de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 354de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 3557c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 356de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 357de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 358de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 359de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 360de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 361de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 362de070137f11d346fba77605bd76a44c040a618fcEric Laurent 363de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 364de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 365de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 366de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 367de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 368de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 369de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 370de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 371de070137f11d346fba77605bd76a44c040a618fcEric Laurent 372db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 373db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 374db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 375db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 376db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 377db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 378db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 379db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 380db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 381db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 382fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 383eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 384eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 385eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 386fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 387eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 388eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 389eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 390eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 39157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 392272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 393272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi { 394272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi Parcel data, reply; 395272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 396272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32((int32_t) stream); 397272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32(inPastMs); 398272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); 399272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return reply.readInt32(); 400272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } 401272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 402d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi virtual bool isSourceActive(audio_source_t source) const 403d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi { 404d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi Parcel data, reply; 405d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 406d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInt32((int32_t) source); 407d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi remote()->transact(IS_SOURCE_ACTIVE, data, &reply); 408d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return reply.readInt32(); 409d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 410d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 41157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 41257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 41357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 41457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 41557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 41657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 41757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 41857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 41957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 42057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 42157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 42257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 42357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 42457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 42557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 42657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 42757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 42857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 42957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 43057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 43157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 43257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 43357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 43457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 435ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald 436ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald virtual bool isOffloadSupported(const audio_offload_info_t& info) 437ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald { 438b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald Parcel data, reply; 439b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 440b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(&info, sizeof(audio_offload_info_t)); 441b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); 442203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return reply.readInt32(); 443203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 444203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 445203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPorts(audio_port_role_t role, 446203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type, 447203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *num_ports, 448203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports, 449203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 450203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 451203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_ports == NULL || (*num_ports != 0 && ports == NULL) || 452203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 453203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 454203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 455203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 456203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 457203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports; 458203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(role); 459203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(type); 460203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPortsReq); 461203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); 462203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 463203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 464203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_ports = (unsigned int)reply.readInt32(); 465203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 466203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 467203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > *num_ports) { 468203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = *num_ports; 469203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 470203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > 0) { 471203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(ports, numPortsReq * sizeof(struct audio_port)); 472203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 473203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 474203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 475203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 476203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 477203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 478203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t getAudioPort(struct audio_port *port) 479203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 480203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (port == NULL) { 481203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 482203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 483203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 484203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 485203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(port, sizeof(struct audio_port)); 486203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); 487203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 488203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 489203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 490203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 491203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(port, sizeof(struct audio_port)); 492203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 493203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 494203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 495203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t createAudioPatch(const struct audio_patch *patch, 496203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t *handle) 497203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 498203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (patch == NULL || handle == NULL) { 499203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 500203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 501203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 502203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 503203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(patch, sizeof(struct audio_patch)); 504203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(handle, sizeof(audio_patch_handle_t)); 505203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); 506203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 507203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 508203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 509203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 510203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(handle, sizeof(audio_patch_handle_t)); 511203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 512203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 513203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 514203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t releaseAudioPatch(audio_patch_handle_t handle) 515203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 516203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 517203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 518203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(&handle, sizeof(audio_patch_handle_t)); 519203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); 520203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 521203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 522203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 523203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 524203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 525203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 526203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPatches(unsigned int *num_patches, 527203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches, 528203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 529203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 530203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_patches == NULL || (*num_patches != 0 && patches == NULL) || 531203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 532203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 533203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 534203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 535203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 536203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches; 537203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPatchesReq); 538203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); 539203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 540203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 541203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_patches = (unsigned int)reply.readInt32(); 542203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 543203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 544203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > *num_patches) { 545203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = *num_patches; 546203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 547203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > 0) { 548203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(patches, numPatchesReq * sizeof(struct audio_patch)); 549203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 550203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 551203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 552203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 553203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 554203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 555203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t setAudioPortConfig(const struct audio_port_config *config) 556203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 557203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (config == NULL) { 558203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 559203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 560203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 561203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 562203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(config, sizeof(struct audio_port_config)); 563203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); 564203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 565203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 566203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 567203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 568203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 569df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent 570b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) 571b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent { 572b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent Parcel data, reply; 573b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 574b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.writeStrongBinder(client->asBinder()); 575b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent remote()->transact(REGISTER_CLIENT, data, &reply); 576b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent } 577df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent 578df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent virtual status_t acquireSoundTriggerSession(audio_session_t *session, 579df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent audio_io_handle_t *ioHandle, 580df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent audio_devices_t *device) 581df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent { 582df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent if (session == NULL || ioHandle == NULL || device == NULL) { 583df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return BAD_VALUE; 584df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 585df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent Parcel data, reply; 586df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 587df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent status_t status = remote()->transact(ACQUIRE_SOUNDTRIGGER_SESSION, data, &reply); 588df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent if (status != NO_ERROR) { 589df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return status; 590df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 591df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent status = (status_t)reply.readInt32(); 592df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent if (status == NO_ERROR) { 593df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent *session = (audio_session_t)reply.readInt32(); 594df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent *ioHandle = (audio_io_handle_t)reply.readInt32(); 595df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent *device = (audio_devices_t)reply.readInt32(); 596df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 597df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return status; 598df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 599df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent 600df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent virtual status_t releaseSoundTriggerSession(audio_session_t session) 601df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent { 602df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent Parcel data, reply; 603df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 604df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent data.writeInt32(session); 605df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent status_t status = remote()->transact(RELEASE_SOUNDTRIGGER_SESSION, data, &reply); 606df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent if (status != NO_ERROR) { 607df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return status; 608df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 609df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return (status_t)reply.readInt32(); 610df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 611bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent 612bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent virtual audio_mode_t getPhoneState() 613bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent { 614bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent Parcel data, reply; 615bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 616bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent status_t status = remote()->transact(GET_PHONE_STATE, data, &reply); 617bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent if (status != NO_ERROR) { 618bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent return AUDIO_MODE_INVALID; 619bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent } 620bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent return (audio_mode_t)reply.readInt32(); 621bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent } 622c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 623c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 624c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 625c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 626c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 627c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 628c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 629c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 630c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 631c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 632e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 633c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 634c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 635fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 636fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 637fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 638fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 639c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 640de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 641de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 642de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 643c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 644c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 645c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 646c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 647c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 648fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 649fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 650c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 651de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 652de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 653c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 654c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 655c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 656c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 657c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 65885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState( 65985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten (audio_mode_t) data.readInt32()))); 660c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 661c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 662c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 663c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 664c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 66585ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 66685ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 667fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 668fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 669c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 670c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 671c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 672c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 673c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 674c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 67585ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 67685ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 677c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 678c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 679c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 680c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 681c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 682c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 683fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 684fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 685c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 68658f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 687254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 6880ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 6890ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 690b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool hasOffloadInfo = data.readInt32() != 0; 691b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t offloadInfo; 692b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (hasOffloadInfo) { 693b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&offloadInfo, sizeof(audio_offload_info_t)); 694b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 695c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 696c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 697c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 698254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 699b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald flags, 700b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald hasOffloadInfo ? &offloadInfo : NULL); 701fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 702c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 703c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 704c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 7055bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi case GET_OUTPUT_FOR_ATTR: { 7065bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 7075bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_attributes_t *attr = (audio_attributes_t *) calloc(1, sizeof(audio_attributes_t)); 7085bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.read(attr, sizeof(audio_attributes_t)); 7095bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi uint32_t samplingRate = data.readInt32(); 7105bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_format_t format = (audio_format_t) data.readInt32(); 7115bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_channel_mask_t channelMask = data.readInt32(); 7125bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_output_flags_t flags = 7135bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi static_cast <audio_output_flags_t>(data.readInt32()); 7145bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi bool hasOffloadInfo = data.readInt32() != 0; 7155bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_offload_info_t offloadInfo; 7165bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi if (hasOffloadInfo) { 7175bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.read(&offloadInfo, sizeof(audio_offload_info_t)); 7185bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 7195bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_io_handle_t output = getOutputForAttr(attr, 7205bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi samplingRate, 7215bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi format, 7225bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi channelMask, 7235bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi flags, 7245bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi hasOffloadInfo ? &offloadInfo : NULL); 7255bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi reply->writeInt32(static_cast <int>(output)); 7265bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi return NO_ERROR; 7275bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } break; 7285bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi 729c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 730c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 731fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 732ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 733ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 734de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 735de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 736ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 737de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 738c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 739c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 740c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 741c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 742c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 743fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 744ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 745ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 746de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 747de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 748ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 749de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 750c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 751c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 752c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 753c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 754c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 755fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 756c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 757c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 758c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 759c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 760c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 761c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 762eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 763c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 76458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 765254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 7667c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 767b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); 768c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 769c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 770c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 771254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 772b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten audioSession, 773b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten flags); 774fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 775c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 776c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 777c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 778c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 779c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 780fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 7814dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent audio_session_t session = static_cast <audio_session_t>(data.readInt32()); 7824dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input, session))); 783c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 784c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 785c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 786c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 787c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 788fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 7894dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent audio_session_t session = static_cast <audio_session_t>(data.readInt32()); 7904dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input, session))); 791c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 792c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 793c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 794c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 795c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 796fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 7974dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent audio_session_t session = static_cast <audio_session_t>(data.readInt32()); 7984dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent releaseInput(input, session); 799c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 800c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 801c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 802c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 803c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 804fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 805fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 806c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 807c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 808c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 809c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 810c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 811c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 812c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 813c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 814fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 815fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 816c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 81783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 81883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 81983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 82083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 821c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 822c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 823c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 824c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 825c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 826fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 827fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 82883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 829c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 83083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 831c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 832c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 833c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 834c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 835c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 836de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 837de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 838fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 839fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 840de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 841de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 842de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 843de070137f11d346fba77605bd76a44c040a618fcEric Laurent 8446b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 8456b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 846fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 847fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 8486b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 8496b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 8506b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 8516b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 852de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 853de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 854de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 855de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 856de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 857de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 858de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 859de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 860de070137f11d346fba77605bd76a44c040a618fcEric Laurent 861de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 862de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 863de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 864de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 8657c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 866de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 867de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 868de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 869de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 8707c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 871de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 872de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 873de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 874de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 875de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 876de070137f11d346fba77605bd76a44c040a618fcEric Laurent 877de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 878de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 879de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 880de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 881de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 882de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 883de070137f11d346fba77605bd76a44c040a618fcEric Laurent 884db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 885db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 886db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 887db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 888db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 889db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 890db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 891db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 892eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 893eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 894fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 895eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 896ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActive(stream, inPastMs) ); 897eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 898eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 899eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 900272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi case IS_STREAM_ACTIVE_REMOTELY: { 901272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 902272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 903272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi uint32_t inPastMs = (uint32_t)data.readInt32(); 904ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); 905272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return NO_ERROR; 906272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } break; 907272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 908d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi case IS_SOURCE_ACTIVE: { 909d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 910d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi audio_source_t source = (audio_source_t) data.readInt32(); 911d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi reply->writeInt32( isSourceActive(source)); 912d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return NO_ERROR; 913d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 914d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 91557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 91657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 91757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 91857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 91957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 92057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 92157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 92257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 92357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 92457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 92557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 92657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 92757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 92857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 92957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 93057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 93157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 93257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 93357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 93457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 93557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 93657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 93757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 938b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald case IS_OFFLOAD_SUPPORTED: { 939b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald CHECK_INTERFACE(IAudioPolicyService, data, reply); 940b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t info; 941b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&info, sizeof(audio_offload_info_t)); 942b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool isSupported = isOffloadSupported(info); 943b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald reply->writeInt32(isSupported); 944b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return NO_ERROR; 945b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 946b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald 947203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PORTS: { 948203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 949203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_role_t role = (audio_port_role_t)data.readInt32(); 950203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type = (audio_port_type_t)data.readInt32(); 951203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = data.readInt32(); 952203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPorts = numPortsReq; 953203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 954203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports = 955203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_port *)calloc(numPortsReq, sizeof(struct audio_port)); 956203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPorts(role, type, &numPorts, ports, &generation); 957203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 958203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPorts); 959203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 960203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 961203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > numPorts) { 962203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = numPorts; 963203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 964203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(ports, numPortsReq * sizeof(struct audio_port)); 965203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 966203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 967203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(ports); 968203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 969203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 970203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 971203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case GET_AUDIO_PORT: { 972203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 973203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port port; 974203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&port, sizeof(struct audio_port)); 975203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = getAudioPort(&port); 976203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 977203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 978203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&port, sizeof(struct audio_port)); 979203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 980203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 981203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 982203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 983203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case CREATE_AUDIO_PATCH: { 984203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 985203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch patch; 986203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&patch, sizeof(struct audio_patch)); 987203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 988203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 989203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = createAudioPatch(&patch, &handle); 990203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 991203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 992203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&handle, sizeof(audio_patch_handle_t)); 993203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 994203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 995203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 996203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 997203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case RELEASE_AUDIO_PATCH: { 998203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 999203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 1000203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 1001203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = releaseAudioPatch(handle); 1002203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 1003203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 1004203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 1005203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 1006203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PATCHES: { 1007203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 1008203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = data.readInt32(); 1009203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatches = numPatchesReq; 1010203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 1011203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches = 1012203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_patch *)calloc(numPatchesReq, 1013203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent sizeof(struct audio_patch)); 1014203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPatches(&numPatches, patches, &generation); 1015203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 1016203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPatches); 1017203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 1018203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > numPatches) { 1019203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = numPatches; 1020203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 1021203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); 1022203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 1023203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 1024203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(patches); 1025203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 1026203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 1027203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 1028203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case SET_AUDIO_PORT_CONFIG: { 1029203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 1030203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port_config config; 1031203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&config, sizeof(struct audio_port_config)); 1032203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = setAudioPortConfig(&config); 1033203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 1034203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 1035203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 1036df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent 1037b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent case REGISTER_CLIENT: { 1038b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 1039b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( 1040b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.readStrongBinder()); 1041b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent registerClient(client); 1042b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent return NO_ERROR; 1043b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent } break; 1044203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 1045df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent case ACQUIRE_SOUNDTRIGGER_SESSION: { 1046df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 1047df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( 1048df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent data.readStrongBinder()); 1049df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent audio_session_t session; 1050df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent audio_io_handle_t ioHandle; 1051df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent audio_devices_t device; 1052df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent status_t status = acquireSoundTriggerSession(&session, &ioHandle, &device); 1053df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent reply->writeInt32(status); 1054df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent if (status == NO_ERROR) { 1055df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent reply->writeInt32(session); 1056df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent reply->writeInt32(ioHandle); 1057df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent reply->writeInt32(device); 1058df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } 1059df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return NO_ERROR; 1060df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } break; 1061df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent 1062df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent case RELEASE_SOUNDTRIGGER_SESSION: { 1063df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 1064df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( 1065df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent data.readStrongBinder()); 1066df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent audio_session_t session = (audio_session_t)data.readInt32(); 1067df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent status_t status = releaseSoundTriggerSession(session); 1068df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent reply->writeInt32(status); 1069df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent return NO_ERROR; 1070df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent } break; 1071df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent 1072bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent case GET_PHONE_STATE: { 1073bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 1074bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent reply->writeInt32((int32_t)getPhoneState()); 1075bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent return NO_ERROR; 1076bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent } break; 1077bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent 1078c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 1079c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 1080c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 1081c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 1082c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 1083c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 1084c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 1085c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 1086