AudioSystem.h revision b81cc8c6f3eec9edb255ea99b6a6f243585b1e38
196675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell/* 296675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * Copyright (C) 2008 The Android Open Source Project 396675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * 496675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 596675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * you may not use this file except in compliance with the License. 696675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * You may obtain a copy of the License at 796675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * 896675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * http://www.apache.org/licenses/LICENSE-2.0 996675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * 1096675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * Unless required by applicable law or agreed to in writing, software 1196675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * distributed under the License is distributed on an "AS IS" BASIS, 1296675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1396675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * See the License for the specific language governing permissions and 1496675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell * limitations under the License. 1596675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell */ 1696675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 1796675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell#ifndef ANDROID_AUDIOSYSTEM_H_ 18d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell#define ANDROID_AUDIOSYSTEM_H_ 19d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell 2096675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell#include <utils/RefBase.h> 218028dd32a4a04154050220dd0693583d5b750330Adam Powell#include <utils/threads.h> 22367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell#include <media/IAudioFlinger.h> 2396675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 246b336f835d637853800b94689375a03f337139a4Adam Powell#include <system/audio.h> 25cf78b3e5101349fdddbde14b3a55140f9562ae66Adam Powell#include <system/audio_policy.h> 26640a66eac612b850b5dabd3b93bd94f83ed2d567Adam Powell 277ade1be822ed05a143b059319dccd5e9f623b56dAdam Powell/* XXX: Should be include by all the users instead */ 287bc3ca0dc52be52ecad1c0de8c62a6a4bf8141caAdam Powell#include <media/AudioParameter.h> 2996675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 3096675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powellnamespace android { 3196675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 3296675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powelltypedef void (*audio_error_callback)(status_t err); 3396675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 3496675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powellclass IAudioPolicyService; 3596675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powellclass String8; 3696675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 3735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powellclass AudioSystem 38be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell{ 3935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powellpublic: 4096675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 417ade1be822ed05a143b059319dccd5e9f623b56dAdam Powell /* These are static methods to control the system-wide AudioFlinger 428028dd32a4a04154050220dd0693583d5b750330Adam Powell * only privileged processes can have access to them 43696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell */ 44640a66eac612b850b5dabd3b93bd94f83ed2d567Adam Powell 4589b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell // mute/unmute microphone 4635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t muteMicrophone(bool state); 47be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static status_t isMicrophoneMuted(bool *state); 4835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 49367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell // set/get master volume 508515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell static status_t setMasterVolume(float value); 5196675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell static status_t getMasterVolume(float* volume); 5296675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 5396675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell // mute/unmute audio outputs 5496675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell static status_t setMasterMute(bool mute); 5596675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell static status_t getMasterMute(bool* mute); 5696675b1df3969f2d313b68f60ed9fa36805db8ceAdam Powell 57f16888f1e849b0bc0b9c17e5f833c4e2cd54c382Adam Powell // set/get stream volume on specified output 58be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static status_t setStreamVolume(audio_stream_type_t stream, float value, 59be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell audio_io_handle_t output); 60be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static status_t getStreamVolume(audio_stream_type_t stream, float* volume, 61367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell audio_io_handle_t output); 62367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell 63367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell // mute/unmute stream 64367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell static status_t setStreamMute(audio_stream_type_t stream, bool mute); 65367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell static status_t getStreamMute(audio_stream_type_t stream, bool* mute); 66773b1b97fc0f01efc8cf1e17a1250a9b654b1b85Adam Powell 67773b1b97fc0f01efc8cf1e17a1250a9b654b1b85Adam Powell // set audio mode in audio hardware 68696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell static status_t setMode(audio_mode_t mode); 69696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell 70696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell // returns true in *state if tracks are active on the specified stream or has been active 71696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell // in the past inPastMs milliseconds 7235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t isStreamActive(audio_stream_type_t stream, bool *state, uint32_t inPastMs = 0); 7335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 7435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // set/get audio hardware parameters. The function accepts a list of parameters 7535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // key value pairs in the form: key1=value1;key2=value2;... 76d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell // Some keys are reserved for standard parameters (See AudioParameter class). 77d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs); 78d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell static String8 getParameters(audio_io_handle_t ioHandle, const String8& keys); 79d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell 80d5c81db1e78e98f3e0a1a5cf206865c3056294c4Adam Powell static void setErrorCallback(audio_error_callback cb); 816c6f575423d6718c3ff322224c1520901ce881e1Adam Powell 82773b1b97fc0f01efc8cf1e17a1250a9b654b1b85Adam Powell // helper function to obtain AudioFlinger service handle 838515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell static const sp<IAudioFlinger>& get_audio_flinger(); 84696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell 856c6f575423d6718c3ff322224c1520901ce881e1Adam Powell static float linearToLog(int volume); 86696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell static int logToLinear(float volume); 87696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell 88696cba573e651b0e4f18a4718627c8ccecb3bda0Adam Powell static status_t getOutputSamplingRate(int* samplingRate, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); 896c6f575423d6718c3ff322224c1520901ce881e1Adam Powell static status_t getOutputFrameCount(int* frameCount, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); 90773b1b97fc0f01efc8cf1e17a1250a9b654b1b85Adam Powell static status_t getOutputLatency(uint32_t* latency, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); 91773b1b97fc0f01efc8cf1e17a1250a9b654b1b85Adam Powell 928515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell // DEPRECATED 93640a66eac612b850b5dabd3b93bd94f83ed2d567Adam Powell static status_t getOutputSamplingRate(int* samplingRate, int stream = AUDIO_STREAM_DEFAULT); 9435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 9589b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell // DEPRECATED 9635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t getOutputFrameCount(int* frameCount, int stream = AUDIO_STREAM_DEFAULT); 9789b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell 9889b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell static bool routedToA2dpOutput(audio_stream_type_t streamType); 9989b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell 10089b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount, 10189b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell size_t* buffSize); 10289b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell 10389b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell static status_t setVoiceVolume(float volume); 10489b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell 10589b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell // return the number of audio frames written by AudioFlinger to audio HAL and 10689b09da7b3b1e69264d9ec710c66eb2f891b313eAdam Powell // audio dsp to DAC since the output on which the specified stream is playing 107640a66eac612b850b5dabd3b93bd94f83ed2d567Adam Powell // has exited standby. 108640a66eac612b850b5dabd3b93bd94f83ed2d567Adam Powell // returned status (from utils/Errors.h) can be: 10935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data 11035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // - INVALID_OPERATION: Not supported on current hardware platform 11135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // - BAD_VALUE: invalid parameter 11235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // NOTE: this feature is not supported on all hardware platforms and it is 11375d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell // necessary to check returned status before using the returned values. 11475d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); 11575d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell 11675d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell static unsigned int getInputFramesLost(audio_io_handle_t ioHandle); 11775d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell 11875d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell static int newAudioSessionId(); 11975d022af1f24cf2d8a7551183ea5bbe943d25d21Adam Powell static void acquireAudioSessionId(int audioSession); 12035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static void releaseAudioSessionId(int audioSession); 12135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 12235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // types of io configuration change events received with ioConfigChanged() 12335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell enum io_config_event { 12435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell OUTPUT_OPENED, 12535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell OUTPUT_CLOSED, 12635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell OUTPUT_CONFIG_CHANGED, 12735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell INPUT_OPENED, 12835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell INPUT_CLOSED, 12935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell INPUT_CONFIG_CHANGED, 13035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell STREAM_CONFIG_CHANGED, 13135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell NUM_CONFIG_EVENTS 13235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell }; 133367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell 134367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell // audio output descriptor used to cache output configurations in client process to avoid frequent calls 135367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell // through IAudioFlinger 136367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell class OutputDescriptor { 137367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell public: 13835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell OutputDescriptor() 13935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell : samplingRate(0), format(AUDIO_FORMAT_DEFAULT), channels(0), frameCount(0), latency(0) {} 14035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 14135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell uint32_t samplingRate; 14235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int32_t format; 1433bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell int32_t channels; 1443bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell size_t frameCount; 1453bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell uint32_t latency; 1463bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell }; 1473bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell 1483bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell // 1493bb421d5b85a8a99c408d16e4f80163a53bc0505Adam Powell // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions) 15035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // 15135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); 15235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address); 15335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t setPhoneState(audio_mode_t state); 15435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); 155160bb7fa60e8ece654e6ce999b6c16af50ee7357Adam Powell static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); 15614b7e2c1688914ba8b6854738981337d7c0653beAdam Powell static audio_io_handle_t getOutput(audio_stream_type_t stream, 15714b7e2c1688914ba8b6854738981337d7c0653beAdam Powell uint32_t samplingRate = 0, 15835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell audio_format_t format = AUDIO_FORMAT_DEFAULT, 15914b7e2c1688914ba8b6854738981337d7c0653beAdam Powell uint32_t channels = AUDIO_CHANNEL_OUT_STEREO, 16014b7e2c1688914ba8b6854738981337d7c0653beAdam Powell audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_NONE); 16135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t startOutput(audio_io_handle_t output, 16235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell audio_stream_type_t stream, 16335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int session = 0); 16435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t stopOutput(audio_io_handle_t output, 16514b7e2c1688914ba8b6854738981337d7c0653beAdam Powell audio_stream_type_t stream, 16614b7e2c1688914ba8b6854738981337d7c0653beAdam Powell int session = 0); 167be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static void releaseOutput(audio_io_handle_t output); 16814b7e2c1688914ba8b6854738981337d7c0653beAdam Powell static audio_io_handle_t getInput(audio_source_t inputSource, 16914b7e2c1688914ba8b6854738981337d7c0653beAdam Powell uint32_t samplingRate = 0, 170be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell audio_format_t format = AUDIO_FORMAT_DEFAULT, 171be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell uint32_t channels = AUDIO_CHANNEL_IN_MONO, 172be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0, 173be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell int sessionId = 0); 174be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static status_t startInput(audio_io_handle_t input); 175be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static status_t stopInput(audio_io_handle_t input); 17635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static void releaseInput(audio_io_handle_t input); 17735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t initStreamVolume(audio_stream_type_t stream, 17835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int indexMin, 17935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int indexMax); 180160bb7fa60e8ece654e6ce999b6c16af50ee7357Adam Powell static status_t setStreamVolumeIndex(audio_stream_type_t stream, 18114b7e2c1688914ba8b6854738981337d7c0653beAdam Powell int index, 18214b7e2c1688914ba8b6854738981337d7c0653beAdam Powell audio_devices_t device); 183be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static status_t getStreamVolumeIndex(audio_stream_type_t stream, 18435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int *index, 18535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell audio_devices_t device); 18635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 18735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static uint32_t getStrategyForStream(audio_stream_type_t stream); 18835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static uint32_t getDevicesForStream(audio_stream_type_t stream); 189367ee326058bbee6fc179b8b1eb2174fe7ba8f45Adam Powell 19035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); 19135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t registerEffect(effect_descriptor_t *desc, 192160bb7fa60e8ece654e6ce999b6c16af50ee7357Adam Powell audio_io_handle_t io, 19314b7e2c1688914ba8b6854738981337d7c0653beAdam Powell uint32_t strategy, 19435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int session, 19535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell int id); 19635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static status_t unregisterEffect(int id); 19714b7e2c1688914ba8b6854738981337d7c0653beAdam Powell static status_t setEffectEnabled(int id, bool enabled); 19835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 19935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // clear stream to output mapping cache (gStreamOutputMap) 200be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell // and output configuration cache (gOutputs) 201be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static void clearAudioConfigCache(); 202be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell 203be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static const sp<IAudioPolicyService>& get_audio_policy_service(); 20435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 20535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // ---------------------------------------------------------------------------- 20635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 20735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powellprivate: 208160bb7fa60e8ece654e6ce999b6c16af50ee7357Adam Powell 20935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient 21035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell { 21135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell public: 21235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell AudioFlingerClient() { 21335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell } 21435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 21535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // DeathRecipient 21635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell virtual void binderDied(const wp<IBinder>& who); 217160bb7fa60e8ece654e6ce999b6c16af50ee7357Adam Powell 21835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // IAudioFlingerClient 21935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 22035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // indicate a change in the configuration of an output or input: keeps the cached 22135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // values for output/input parameters up-to-date in client process 22235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2); 22335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell }; 22435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 22535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell class AudioPolicyServiceClient: public IBinder::DeathRecipient 22635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell { 22735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell public: 22835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell AudioPolicyServiceClient() { 22935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell } 23035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 23114b7e2c1688914ba8b6854738981337d7c0653beAdam Powell // DeathRecipient 23235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell virtual void binderDied(const wp<IBinder>& who); 233be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell }; 23435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 235be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static sp<AudioFlingerClient> gAudioFlingerClient; 236be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient; 237be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell friend class AudioFlingerClient; 238be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell friend class AudioPolicyServiceClient; 23935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 24035aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static Mutex gLock; 241be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static sp<IAudioFlinger> gAudioFlinger; 242be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static audio_error_callback gAudioErrorCallback; 243be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell 244be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static size_t gInBuffSize; 245be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell // previous parameters for recording buffer size queries 246be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static uint32_t gPrevInSamplingRate; 247be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static audio_format_t gPrevInFormat; 248be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static int gPrevInChannelCount; 249be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell 250be3c329ebec083e5ff933bab6b6c501519ad2bffAdam Powell static sp<IAudioPolicyService> gAudioPolicyService; 25135aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 25235aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // mapping between stream types and outputs 25335aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static DefaultKeyedVector<audio_stream_type_t, audio_io_handle_t> gStreamOutputMap; 25435aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // list of output descriptors containing cached parameters 25535aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell // (sampling rate, framecount, channel count...) 25635aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs; 25735aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell}; 25835aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell 25935aecd5884a5ccfe380903e39f30f468315e8f92Adam Powell}; // namespace android 26014b7e2c1688914ba8b6854738981337d7c0653beAdam Powell 26114b7e2c1688914ba8b6854738981337d7c0653beAdam Powell#endif /*ANDROID_AUDIOSYSTEM_H_*/ 26214b7e2c1688914ba8b6854738981337d7c0653beAdam Powell