IAudioPolicyService.cpp revision 5bd3f38638acab633d181359cc9ec27b80f84d43
1c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent/* 2c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 3c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Copyright 2009, The Android Open Source Project 4c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 5c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Licensed under the Apache License, Version 2.0 (the "License"); 6c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** you may not use this file except in compliance with the License. 7c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** You may obtain a copy of the License at 8c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 9c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** http://www.apache.org/licenses/LICENSE-2.0 10c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** 11c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Unless required by applicable law or agreed to in writing, software 12c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** distributed under the License is distributed on an "AS IS" BASIS, 13c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** See the License for the specific language governing permissions and 15c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** limitations under the License. 16c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent*/ 17c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 18c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#define LOG_TAG "IAudioPolicyService" 19c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <utils/Log.h> 20c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 21c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <stdint.h> 22c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <sys/types.h> 23c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 24c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <binder/Parcel.h> 25c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 26c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/IAudioPolicyService.h> 27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 2864760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h> 29fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin 30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android { 31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum { 33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION, 34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_DEVICE_CONNECTION_STATE, 35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_PHONE_STATE, 360b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7Glenn Kasten SET_RINGER_MODE, // reserved, no longer used 37c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_FORCE_USE, 38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_FORCE_USE, 39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_OUTPUT, 40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_OUTPUT, 41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_OUTPUT, 42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_OUTPUT, 43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent GET_INPUT, 44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent START_INPUT, 45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent STOP_INPUT, 46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent RELEASE_INPUT, 47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent INIT_STREAM_VOLUME, 48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent SET_STREAM_VOLUME, 49de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STREAM_VOLUME, 50de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_STRATEGY_FOR_STREAM, 51de070137f11d346fba77605bd76a44c040a618fcEric Laurent GET_OUTPUT_FOR_EFFECT, 52de070137f11d346fba77605bd76a44c040a618fcEric Laurent REGISTER_EFFECT, 53eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent UNREGISTER_EFFECT, 546b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten IS_STREAM_ACTIVE, 55d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi IS_SOURCE_ACTIVE, 566b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten GET_DEVICES_FOR_STREAM, 57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent QUERY_DEFAULT_PRE_PROCESSING, 58272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi SET_EFFECT_ENABLED, 59ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald IS_STREAM_ACTIVE_REMOTELY, 60203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent IS_OFFLOAD_SUPPORTED, 61203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent LIST_AUDIO_PORTS, 62203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent GET_AUDIO_PORT, 63203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CREATE_AUDIO_PATCH, 64203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent RELEASE_AUDIO_PATCH, 65203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent LIST_AUDIO_PATCHES, 66b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent SET_AUDIO_PORT_CONFIG, 675bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi REGISTER_CLIENT, 685bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi GET_OUTPUT_FOR_ATTR 69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService> 72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic: 74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent BpAudioPolicyService(const sp<IBinder>& impl) 75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent : BpInterface<IAudioPolicyService>(impl) 76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t setDeviceConnectionState( 80fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 81fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state, 82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(state)); 88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply); 90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 93fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_dev_state_t getDeviceConnectionState( 94fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device, 95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address) 96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(device)); 100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeCString(device_address); 101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply); 102fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_dev_state_t>(reply.readInt32()); 103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 105f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten virtual status_t setPhoneState(audio_mode_t state) 106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(state); 110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_PHONE_STATE, data, &reply); 111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 114fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) 115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(config)); 120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_FORCE_USE, data, &reply); 121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 124fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) 125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(usage)); 129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_FORCE_USE, data, &reply); 130fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin return static_cast <audio_policy_forced_cfg_t> (reply.readInt32()); 131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getOutput( 134fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 13658f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 137254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 138ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald audio_output_flags_t flags, 139ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald const audio_offload_info_t *offloadInfo) 140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 146254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(flags)); 1482301acc6a9c7a3af4ad01f3d1d0f76f13eca7350Glenn Kasten // hasOffloadInfo 149b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (offloadInfo == NULL) { 150b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(0); 151b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } else { 152b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInt32(1); 153b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(offloadInfo, sizeof(audio_offload_info_t)); 154b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_OUTPUT, data, &reply); 156fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 1595bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi virtual audio_io_handle_t getOutputForAttr( 1605bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi const audio_attributes_t *attr, 1615bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi uint32_t samplingRate, 1625bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_format_t format, 1635bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_channel_mask_t channelMask, 1645bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_output_flags_t flags, 1655bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi const audio_offload_info_t *offloadInfo) 1665bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi { 1675bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi Parcel data, reply; 1685bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 1695bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi if (attr == NULL) { 1705bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi ALOGE("Writing NULL audio attributes - shouldn't happen"); 1715bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi return (audio_io_handle_t) 0; 1725bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 1735bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.write(attr, sizeof(audio_attributes_t)); 1745bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(samplingRate); 1755bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(static_cast <uint32_t>(format)); 1765bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(channelMask); 1775bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(static_cast <uint32_t>(flags)); 1785bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi // hasOffloadInfo 1795bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi if (offloadInfo == NULL) { 1805bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(0); 1815bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } else { 1825bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.writeInt32(1); 1835bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.write(offloadInfo, sizeof(audio_offload_info_t)); 1845bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 1855bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi remote()->transact(GET_OUTPUT_FOR_ATTR, data, &reply); 1865bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi return static_cast <audio_io_handle_t> (reply.readInt32()); 1875bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 1885bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi 189de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t startOutput(audio_io_handle_t output, 190fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 191de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 195fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 196fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 197de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_OUTPUT, data, &reply); 199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 202de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t stopOutput(audio_io_handle_t output, 203fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream, 204de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session) 205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 208fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 209fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 210de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_OUTPUT, data, &reply); 212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseOutput(audio_io_handle_t output) 216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 219fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(output); 220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_OUTPUT, data, &reply); 221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual audio_io_handle_t getInput( 224eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource, 225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate, 22658f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format, 227254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask, 2287c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession) 229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 232eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten data.writeInt32((int32_t) inputSource); 233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(samplingRate); 234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(format)); 235254af180475346b6186b49c297f340c9c4817511Glenn Kasten data.writeInt32(channelMask); 2367c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(audioSession); 237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_INPUT, data, &reply); 238fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t startInput(audio_io_handle_t input) 242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 245fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(START_INPUT, data, &reply); 247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual status_t stopInput(audio_io_handle_t input) 251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 254fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(STOP_INPUT, data, &reply); 256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent virtual void releaseInput(audio_io_handle_t input) 260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 262c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 263fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent data.writeInt32(input); 264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(RELEASE_INPUT, data, &reply); 265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 267fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual status_t initStreamVolume(audio_stream_type_t stream, 268c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin, 269c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax) 270c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 271c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 272c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 273c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 274c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMin); 275c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(indexMax); 276c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(INIT_STREAM_VOLUME, data, &reply); 277c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 278c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 279c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 28083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, 28183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int index, 28283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 283c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 284c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 285c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 286c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 287c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(index); 28883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 289c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(SET_STREAM_VOLUME, data, &reply); 290c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 291c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 292c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 29383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, 29483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent int *index, 29583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device) 296c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent { 297c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent Parcel data, reply; 298c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 299c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 30083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent data.writeInt32(static_cast <uint32_t>(device)); 30183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent 302c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent remote()->transact(GET_STREAM_VOLUME, data, &reply); 303c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int lIndex = reply.readInt32(); 304c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent if (index) *index = lIndex; 305c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return static_cast <status_t> (reply.readInt32()); 306c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 307de070137f11d346fba77605bd76a44c040a618fcEric Laurent 308fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin virtual uint32_t getStrategyForStream(audio_stream_type_t stream) 309de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 310de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 311de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 312de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(static_cast <uint32_t>(stream)); 313de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply); 314de070137f11d346fba77605bd76a44c040a618fcEric Laurent return reply.readInt32(); 315de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 316de070137f11d346fba77605bd76a44c040a618fcEric Laurent 3176374252107fd6539397598195ea6defd5870fafbEric Laurent virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) 3186b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten { 3196b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten Parcel data, reply; 3206b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 3216b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten data.writeInt32(static_cast <uint32_t>(stream)); 3226b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); 3236374252107fd6539397598195ea6defd5870fafbEric Laurent return (audio_devices_t) reply.readInt32(); 3246b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } 3256b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 32658e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) 327de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 328de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 329de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 330de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 331de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply); 332de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <audio_io_handle_t> (reply.readInt32()); 333de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 334de070137f11d346fba77605bd76a44c040a618fcEric Laurent 33558e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten virtual status_t registerEffect(const effect_descriptor_t *desc, 3367c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io, 337de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy, 338de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session, 339de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id) 340de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 341de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 342de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 343de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.write(desc, sizeof(effect_descriptor_t)); 3447c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent data.writeInt32(io); 345de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(strategy); 346de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(session); 347de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 348de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(REGISTER_EFFECT, data, &reply); 349de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 350de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 351de070137f11d346fba77605bd76a44c040a618fcEric Laurent 352de070137f11d346fba77605bd76a44c040a618fcEric Laurent virtual status_t unregisterEffect(int id) 353de070137f11d346fba77605bd76a44c040a618fcEric Laurent { 354de070137f11d346fba77605bd76a44c040a618fcEric Laurent Parcel data, reply; 355de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 356de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.writeInt32(id); 357de070137f11d346fba77605bd76a44c040a618fcEric Laurent remote()->transact(UNREGISTER_EFFECT, data, &reply); 358de070137f11d346fba77605bd76a44c040a618fcEric Laurent return static_cast <status_t> (reply.readInt32()); 359de070137f11d346fba77605bd76a44c040a618fcEric Laurent } 360de070137f11d346fba77605bd76a44c040a618fcEric Laurent 361db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent virtual status_t setEffectEnabled(int id, bool enabled) 362db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent { 363db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent Parcel data, reply; 364db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 365db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(id); 366db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent data.writeInt32(enabled); 367db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent remote()->transact(SET_EFFECT_ENABLED, data, &reply); 368db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return static_cast <status_t> (reply.readInt32()); 369db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } 370db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 371fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 372eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent { 373eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent Parcel data, reply; 374eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 375fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten data.writeInt32((int32_t) stream); 376eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent data.writeInt32(inPastMs); 377eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent remote()->transact(IS_STREAM_ACTIVE, data, &reply); 378eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return reply.readInt32(); 379eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } 38057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 381272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 382272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi { 383272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi Parcel data, reply; 384272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 385272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32((int32_t) stream); 386272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi data.writeInt32(inPastMs); 387272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply); 388272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return reply.readInt32(); 389272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } 390272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 391d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi virtual bool isSourceActive(audio_source_t source) const 392d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi { 393d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi Parcel data, reply; 394d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 395d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi data.writeInt32((int32_t) source); 396d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi remote()->transact(IS_SOURCE_ACTIVE, data, &reply); 397d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return reply.readInt32(); 398d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 399d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 40057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent virtual status_t queryDefaultPreProcessing(int audioSession, 40157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors, 40257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t *count) 40357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent { 40457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (descriptors == NULL || count == NULL) { 40557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return BAD_VALUE; 40657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 40757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent Parcel data, reply; 40857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 40957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(audioSession); 41057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent data.writeInt32(*count); 41157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply); 41257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR) { 41357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 41457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 41557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status = static_cast <status_t> (reply.readInt32()); 41657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = reply.readInt32(); 41757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount != 0) { 41857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t numDesc = (retCount < *count) ? retCount : *count; 41957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc); 42057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 42157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent *count = retCount; 42257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 42357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 424ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald 425ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald virtual bool isOffloadSupported(const audio_offload_info_t& info) 426ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald { 427b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald Parcel data, reply; 428b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 429b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.write(&info, sizeof(audio_offload_info_t)); 430b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply); 431203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return reply.readInt32(); 432203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 433203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 434203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPorts(audio_port_role_t role, 435203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type, 436203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *num_ports, 437203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports, 438203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 439203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 440203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_ports == NULL || (*num_ports != 0 && ports == NULL) || 441203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 442203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 443203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 444203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 445203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 446203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports; 447203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(role); 448203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(type); 449203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPortsReq); 450203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); 451203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 452203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 453203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_ports = (unsigned int)reply.readInt32(); 454203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 455203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 456203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > *num_ports) { 457203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = *num_ports; 458203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 459203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > 0) { 460203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(ports, numPortsReq * sizeof(struct audio_port)); 461203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 462203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 463203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 464203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 465203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 466203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 467203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t getAudioPort(struct audio_port *port) 468203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 469203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (port == NULL) { 470203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 471203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 472203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 473203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 474203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(port, sizeof(struct audio_port)); 475203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); 476203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 477203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 478203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 479203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 480203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(port, sizeof(struct audio_port)); 481203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 482203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 483203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 484203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t createAudioPatch(const struct audio_patch *patch, 485203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t *handle) 486203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 487203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (patch == NULL || handle == NULL) { 488203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 489203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 490203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 491203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 492203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(patch, sizeof(struct audio_patch)); 493203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(handle, sizeof(audio_patch_handle_t)); 494203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); 495203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR || 496203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (status = (status_t)reply.readInt32()) != NO_ERROR) { 497203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 498203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 499203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(handle, sizeof(audio_patch_handle_t)); 500203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 501203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 502203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 503203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t releaseAudioPatch(audio_patch_handle_t handle) 504203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 505203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 506203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 507203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(&handle, sizeof(audio_patch_handle_t)); 508203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); 509203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 510203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 511203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 512203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 513203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 514203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 515203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t listAudioPatches(unsigned int *num_patches, 516203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches, 517203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int *generation) 518203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 519203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (num_patches == NULL || (*num_patches != 0 && patches == NULL) || 520203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent generation == NULL) { 521203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 522203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 523203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 524203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 525203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches; 526203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInt32(numPatchesReq); 527203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); 528203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 529203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 530203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *num_patches = (unsigned int)reply.readInt32(); 531203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 532203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 533203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > *num_patches) { 534203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = *num_patches; 535203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 536203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > 0) { 537203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply.read(patches, numPatchesReq * sizeof(struct audio_patch)); 538203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 539203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent *generation = reply.readInt32(); 540203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 541203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 542203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 543203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 544203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent virtual status_t setAudioPortConfig(const struct audio_port_config *config) 545203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent { 546203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (config == NULL) { 547203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return BAD_VALUE; 548203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 549203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent Parcel data, reply; 550203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 551203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.write(config, sizeof(struct audio_port_config)); 552203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); 553203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status != NO_ERROR) { 554203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status = (status_t)reply.readInt32(); 555203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 556203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return status; 557203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 558b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) 559b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent { 560b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent Parcel data, reply; 561b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); 562b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.writeStrongBinder(client->asBinder()); 563b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent remote()->transact(REGISTER_CLIENT, data, &reply); 564b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent } 565c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; 566c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 567c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService"); 568c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 569c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------- 570c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 571c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 572c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact( 573c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 574c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{ 575e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 576c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_DEVICE_CONNECTION_STATE: { 577c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 578fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 579fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_devices_t>(data.readInt32()); 580fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_dev_state_t state = 581fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_dev_state_t>(data.readInt32()); 582c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 583de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device, 584de070137f11d346fba77605bd76a44c040a618fcEric Laurent state, 585de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 586c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 587c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 588c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 589c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_DEVICE_CONNECTION_STATE: { 590c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 591fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_devices_t device = 592fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast<audio_devices_t> (data.readInt32()); 593c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent const char *device_address = data.readCString(); 594de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device, 595de070137f11d346fba77605bd76a44c040a618fcEric Laurent device_address))); 596c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 597c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 598c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 599c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_PHONE_STATE: { 600c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 60185ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten reply->writeInt32(static_cast <uint32_t>(setPhoneState( 60285ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten (audio_mode_t) data.readInt32()))); 603c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 604c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 605c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 606c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_FORCE_USE: { 607c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 60885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 60985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 610fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_policy_forced_cfg_t config = 611fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_policy_forced_cfg_t>(data.readInt32()); 612c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config))); 613c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 614c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 615c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 616c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_FORCE_USE: { 617c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 61885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>( 61985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten data.readInt32()); 620c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(getForceUse(usage))); 621c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 622c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 623c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 624c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_OUTPUT: { 625c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 626fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 627fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 628c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 62958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 630254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 6310ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent audio_output_flags_t flags = 6320ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent static_cast <audio_output_flags_t>(data.readInt32()); 633b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool hasOffloadInfo = data.readInt32() != 0; 634b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t offloadInfo; 635b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald if (hasOffloadInfo) { 636b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&offloadInfo, sizeof(audio_offload_info_t)); 637b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 638c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t output = getOutput(stream, 639c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 640c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 641254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 642b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald flags, 643b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald hasOffloadInfo ? &offloadInfo : NULL); 644fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(output)); 645c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 646c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 647c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 6485bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi case GET_OUTPUT_FOR_ATTR: { 6495bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 6505bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_attributes_t *attr = (audio_attributes_t *) calloc(1, sizeof(audio_attributes_t)); 6515bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.read(attr, sizeof(audio_attributes_t)); 6525bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi uint32_t samplingRate = data.readInt32(); 6535bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_format_t format = (audio_format_t) data.readInt32(); 6545bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_channel_mask_t channelMask = data.readInt32(); 6555bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_output_flags_t flags = 6565bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi static_cast <audio_output_flags_t>(data.readInt32()); 6575bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi bool hasOffloadInfo = data.readInt32() != 0; 6585bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_offload_info_t offloadInfo; 6595bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi if (hasOffloadInfo) { 6605bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi data.read(&offloadInfo, sizeof(audio_offload_info_t)); 6615bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } 6625bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi audio_io_handle_t output = getOutputForAttr(attr, 6635bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi samplingRate, 6645bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi format, 6655bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi channelMask, 6665bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi flags, 6675bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi hasOffloadInfo ? &offloadInfo : NULL); 6685bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi reply->writeInt32(static_cast <int>(output)); 6695bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi return NO_ERROR; 6705bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi } break; 6715bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi 672c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_OUTPUT: { 673c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 674fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 675ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 676ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 677de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 678de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(startOutput(output, 679ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 680de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 681c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 682c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 683c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 684c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_OUTPUT: { 685c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 686fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 687ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent audio_stream_type_t stream = 688ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent static_cast <audio_stream_type_t>(data.readInt32()); 689de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 690de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <uint32_t>(stopOutput(output, 691ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent stream, 692de070137f11d346fba77605bd76a44c040a618fcEric Laurent session))); 693c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 694c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 695c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 696c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_OUTPUT: { 697c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 698fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32()); 699c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseOutput(output); 700c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 701c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 702c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 703c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_INPUT: { 704c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 705eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten audio_source_t inputSource = (audio_source_t) data.readInt32(); 706c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent uint32_t samplingRate = data.readInt32(); 70758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten audio_format_t format = (audio_format_t) data.readInt32(); 708254af180475346b6186b49c297f340c9c4817511Glenn Kasten audio_channel_mask_t channelMask = data.readInt32(); 7097c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent int audioSession = data.readInt32(); 710c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent audio_io_handle_t input = getInput(inputSource, 711c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent samplingRate, 712c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent format, 713254af180475346b6186b49c297f340c9c4817511Glenn Kasten channelMask, 7147c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audioSession); 715fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent reply->writeInt32(static_cast <int>(input)); 716c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 717c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 718c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 719c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case START_INPUT: { 720c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 721fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 722c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(startInput(input))); 723c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 724c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 725c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 726c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case STOP_INPUT: { 727c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 728fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 729c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(stopInput(input))); 730c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 731c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 732c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 733c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case RELEASE_INPUT: { 734c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 735fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32()); 736c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent releaseInput(input); 737c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 738c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 739c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 740c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case INIT_STREAM_VOLUME: { 741c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 742fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 743fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 744c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMin = data.readInt32(); 745c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int indexMax = data.readInt32(); 746c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax))); 747c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 748c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 749c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 750c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case SET_STREAM_VOLUME: { 751c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 752fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 753fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 754c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index = data.readInt32(); 75583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 75683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, 75783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent index, 75883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent device))); 759c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 760c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 761c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 762c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent case GET_STREAM_VOLUME: { 763c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 764fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 765fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 76683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent audio_devices_t device = static_cast <audio_devices_t>(data.readInt32()); 767c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent int index; 76883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent status_t status = getStreamVolumeIndex(stream, &index, device); 769c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(index); 770c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent reply->writeInt32(static_cast <uint32_t>(status)); 771c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return NO_ERROR; 772c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } break; 773c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 774de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_STRATEGY_FOR_STREAM: { 775de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 776fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 777fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 778de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(getStrategyForStream(stream)); 779de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 780de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 781de070137f11d346fba77605bd76a44c040a618fcEric Laurent 7826b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten case GET_DEVICES_FOR_STREAM: { 7836b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten CHECK_INTERFACE(IAudioPolicyService, data, reply); 784fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin audio_stream_type_t stream = 785fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin static_cast <audio_stream_type_t>(data.readInt32()); 7866b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten reply->writeInt32(static_cast <int>(getDevicesForStream(stream))); 7876b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten return NO_ERROR; 7886b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten } break; 7896b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten 790de070137f11d346fba77605bd76a44c040a618fcEric Laurent case GET_OUTPUT_FOR_EFFECT: { 791de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 792de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 793de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 794de070137f11d346fba77605bd76a44c040a618fcEric Laurent audio_io_handle_t output = getOutputForEffect(&desc); 795de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int>(output)); 796de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 797de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 798de070137f11d346fba77605bd76a44c040a618fcEric Laurent 799de070137f11d346fba77605bd76a44c040a618fcEric Laurent case REGISTER_EFFECT: { 800de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 801de070137f11d346fba77605bd76a44c040a618fcEric Laurent effect_descriptor_t desc; 802de070137f11d346fba77605bd76a44c040a618fcEric Laurent data.read(&desc, sizeof(effect_descriptor_t)); 8037c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent audio_io_handle_t io = data.readInt32(); 804de070137f11d346fba77605bd76a44c040a618fcEric Laurent uint32_t strategy = data.readInt32(); 805de070137f11d346fba77605bd76a44c040a618fcEric Laurent int session = data.readInt32(); 806de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 807de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(registerEffect(&desc, 8087c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent io, 809de070137f11d346fba77605bd76a44c040a618fcEric Laurent strategy, 810de070137f11d346fba77605bd76a44c040a618fcEric Laurent session, 811de070137f11d346fba77605bd76a44c040a618fcEric Laurent id))); 812de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 813de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 814de070137f11d346fba77605bd76a44c040a618fcEric Laurent 815de070137f11d346fba77605bd76a44c040a618fcEric Laurent case UNREGISTER_EFFECT: { 816de070137f11d346fba77605bd76a44c040a618fcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 817de070137f11d346fba77605bd76a44c040a618fcEric Laurent int id = data.readInt32(); 818de070137f11d346fba77605bd76a44c040a618fcEric Laurent reply->writeInt32(static_cast <int32_t>(unregisterEffect(id))); 819de070137f11d346fba77605bd76a44c040a618fcEric Laurent return NO_ERROR; 820de070137f11d346fba77605bd76a44c040a618fcEric Laurent } break; 821de070137f11d346fba77605bd76a44c040a618fcEric Laurent 822db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent case SET_EFFECT_ENABLED: { 823db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 824db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent int id = data.readInt32(); 825db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent bool enabled = static_cast <bool>(data.readInt32()); 826db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled))); 827db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent return NO_ERROR; 828db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent } break; 829db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent 830eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent case IS_STREAM_ACTIVE: { 831eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 832fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 833eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent uint32_t inPastMs = (uint32_t)data.readInt32(); 834ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActive(stream, inPastMs) ); 835eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent return NO_ERROR; 836eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent } break; 837eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent 838272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi case IS_STREAM_ACTIVE_REMOTELY: { 839272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 840272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); 841272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi uint32_t inPastMs = (uint32_t)data.readInt32(); 842ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) ); 843272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi return NO_ERROR; 844272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi } break; 845272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi 846d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi case IS_SOURCE_ACTIVE: { 847d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi CHECK_INTERFACE(IAudioPolicyService, data, reply); 848d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi audio_source_t source = (audio_source_t) data.readInt32(); 849d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi reply->writeInt32( isSourceActive(source)); 850d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi return NO_ERROR; 851d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi } 852d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi 85357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent case QUERY_DEFAULT_PRE_PROCESSING: { 85457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 85557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent int audioSession = data.readInt32(); 85657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t count = data.readInt32(); 85757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent uint32_t retCount = count; 85857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent effect_descriptor_t *descriptors = 85957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)]; 86057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount); 86157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(status); 86257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (status != NO_ERROR && status != NO_MEMORY) { 86357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent retCount = 0; 86457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 86557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->writeInt32(retCount); 86657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount) { 86757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent if (retCount < count) { 86857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent count = retCount; 86957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 87057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent reply->write(descriptors, sizeof(effect_descriptor_t) * count); 87157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 87257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent delete[] descriptors; 87357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent return status; 87457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent } 87557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent 876b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald case IS_OFFLOAD_SUPPORTED: { 877b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald CHECK_INTERFACE(IAudioPolicyService, data, reply); 878b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald audio_offload_info_t info; 879b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald data.read(&info, sizeof(audio_offload_info_t)); 880b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald bool isSupported = isOffloadSupported(info); 881b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald reply->writeInt32(isSupported); 882b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald return NO_ERROR; 883b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald } 884b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald 885203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PORTS: { 886203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 887203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_role_t role = (audio_port_role_t)data.readInt32(); 888203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_port_type_t type = (audio_port_type_t)data.readInt32(); 889203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPortsReq = data.readInt32(); 890203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPorts = numPortsReq; 891203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 892203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port *ports = 893203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_port *)calloc(numPortsReq, sizeof(struct audio_port)); 894203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPorts(role, type, &numPorts, ports, &generation); 895203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 896203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPorts); 897203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 898203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 899203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPortsReq > numPorts) { 900203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPortsReq = numPorts; 901203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 902203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(ports, numPortsReq * sizeof(struct audio_port)); 903203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 904203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 905203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(ports); 906203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 907203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 908203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 909203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case GET_AUDIO_PORT: { 910203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 911203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port port; 912203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&port, sizeof(struct audio_port)); 913203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = getAudioPort(&port); 914203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 915203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 916203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&port, sizeof(struct audio_port)); 917203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 918203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 919203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 920203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 921203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case CREATE_AUDIO_PATCH: { 922203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 923203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch patch; 924203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&patch, sizeof(struct audio_patch)); 925203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 926203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 927203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = createAudioPatch(&patch, &handle); 928203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 929203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 930203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(&handle, sizeof(audio_patch_handle_t)); 931203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 932203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 933203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 934203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 935203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case RELEASE_AUDIO_PATCH: { 936203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 937203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent audio_patch_handle_t handle; 938203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&handle, sizeof(audio_patch_handle_t)); 939203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = releaseAudioPatch(handle); 940203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 941203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 942203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 943203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 944203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case LIST_AUDIO_PATCHES: { 945203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 946203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatchesReq = data.readInt32(); 947203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int numPatches = numPatchesReq; 948203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent unsigned int generation; 949203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_patch *patches = 950203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent (struct audio_patch *)calloc(numPatchesReq, 951203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent sizeof(struct audio_patch)); 952203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = listAudioPatches(&numPatches, patches, &generation); 953203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 954203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(numPatches); 955203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (status == NO_ERROR) { 956203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent if (numPatchesReq > numPatches) { 957203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent numPatchesReq = numPatches; 958203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 959203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); 960203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(generation); 961203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 962203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent free(patches); 963203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 964203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 965203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 966203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent case SET_AUDIO_PORT_CONFIG: { 967203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 968203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent struct audio_port_config config; 969203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent data.read(&config, sizeof(struct audio_port_config)); 970203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent status_t status = setAudioPortConfig(&config); 971203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent reply->writeInt32(status); 972203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent return NO_ERROR; 973203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent } 974b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent case REGISTER_CLIENT: { 975b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent CHECK_INTERFACE(IAudioPolicyService, data, reply); 976b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent sp<IAudioPolicyServiceClient> client = interface_cast<IAudioPolicyServiceClient>( 977b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent data.readStrongBinder()); 978b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent registerClient(client); 979b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent return NO_ERROR; 980b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent } break; 981203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent 982c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent default: 983c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent return BBinder::onTransact(code, data, reply, flags); 984c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent } 985c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent} 986c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 987c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ---------------------------------------------------------------------------- 988c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent 989c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android 990