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