AudioSystem.h revision db7c079f284f6e91266f6653ae0ec198b1c5006e
189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project/*
289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *
489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * you may not use this file except in compliance with the License.
689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * You may obtain a copy of the License at
789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *
889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *
1089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
1189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
1289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * See the License for the specific language governing permissions and
1489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project * limitations under the License.
1589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project */
1689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
1789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#ifndef ANDROID_AUDIOSYSTEM_H_
1889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#define ANDROID_AUDIOSYSTEM_H_
1989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
2089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <utils/RefBase.h>
2189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <utils/threads.h>
2289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <media/IAudioFlinger.h>
2389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
2464760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h>
257394a4f358fa9908a9f0a7c954b65c399f4268e6Dima Zavin#include <system/audio_policy.h>
26fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin
27db5cb14318bb24cd6ea14ff7ceea0d5e1f83d903Dima Zavin/* XXX: Should be include by all the users instead */
28db5cb14318bb24cd6ea14ff7ceea0d5e1f83d903Dima Zavin#include <media/AudioParameter.h>
29db5cb14318bb24cd6ea14ff7ceea0d5e1f83d903Dima Zavin
3089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectnamespace android {
3189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
3289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projecttypedef void (*audio_error_callback)(status_t err);
33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass IAudioPolicyService;
35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass String8;
3689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
3789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass AudioSystem
3889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project{
3989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectpublic:
4089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
4189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    /* These are static methods to control the system-wide AudioFlinger
4289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project     * only privileged processes can have access to them
4389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project     */
4489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // mute/unmute microphone
4689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t muteMicrophone(bool state);
4789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t isMicrophoneMuted(bool *state);
4889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
49c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // set/get master volume
5089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t setMasterVolume(float value);
5189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t getMasterVolume(float* volume);
524bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten
53c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // mute/unmute audio outputs
54c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t setMasterMute(bool mute);
5589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t getMasterMute(bool* mute);
5689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
57c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // set/get stream volume on specified output
58fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent    static status_t setStreamVolume(int stream, float value, int output);
59fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent    static status_t getStreamVolume(int stream, float* volume, int output);
60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // mute/unmute stream
6289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t setStreamMute(int stream, bool mute);
6389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t getStreamMute(int stream, bool* mute);
6489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
65fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    // set audio mode in audio hardware (see audio_mode_t)
6689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static status_t setMode(int mode);
6789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
68eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    // returns true in *state if tracks are active on the specified stream or has been active
69eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    // in the past inPastMs milliseconds
70eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    static status_t isStreamActive(int stream, bool *state, uint32_t inPastMs = 0);
7189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // set/get audio hardware parameters. The function accepts a list of parameters
73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // key value pairs in the form: key1=value1;key2=value2;...
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // Some keys are reserved for standard parameters (See AudioParameter class).
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs);
76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static String8  getParameters(audio_io_handle_t ioHandle, const String8& keys);
77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
7889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static void setErrorCallback(audio_error_callback cb);
7989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
8089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // helper function to obtain AudioFlinger service handle
8189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static const sp<IAudioFlinger>& get_audio_flinger();
8289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
8389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static float linearToLog(int volume);
8489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static int logToLinear(float volume);
8589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
86fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t getOutputSamplingRate(int* samplingRate, int stream = AUDIO_STREAM_DEFAULT);
87fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t getOutputFrameCount(int* frameCount, int stream = AUDIO_STREAM_DEFAULT);
88fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t getOutputLatency(uint32_t* latency, int stream = AUDIO_STREAM_DEFAULT);
8989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
9089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static bool routedToA2dpOutput(int streamType);
91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount,
9389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        size_t* buffSize);
9489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
95f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent    static status_t setVoiceVolume(float volume);
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
97342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // return the number of audio frames written by AudioFlinger to audio HAL and
984bcae82f9b07d1a39956c45a6f5bec0b696c4dd1Glenn Kasten    // audio dsp to DAC since the output on which the specified stream is playing
99342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // has exited standby.
100342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // returned status (from utils/Errors.h) can be:
101342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data
102342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // - INVALID_OPERATION: Not supported on current hardware platform
103342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // - BAD_VALUE: invalid parameter
104342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // NOTE: this feature is not supported on all hardware platforms and it is
105342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // necessary to check returned status before using the returned values.
106fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = AUDIO_STREAM_DEFAULT);
107342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent
10805bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent    static unsigned int  getInputFramesLost(audio_io_handle_t ioHandle);
109be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent
110be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    static int newAudioSessionId();
1113a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    static void acquireAudioSessionId(int audioSession);
1123a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    static void releaseAudioSessionId(int audioSession);
113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // types of io configuration change events received with ioConfigChanged()
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    enum io_config_event {
116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OUTPUT_OPENED,
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OUTPUT_CLOSED,
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OUTPUT_CONFIG_CHANGED,
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        INPUT_OPENED,
120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        INPUT_CLOSED,
121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        INPUT_CONFIG_CHANGED,
122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        STREAM_CONFIG_CHANGED,
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        NUM_CONFIG_EVENTS
124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    };
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // audio output descritor used to cache output configurations in client process to avoid frequent calls
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // through IAudioFlinger
128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    class OutputDescriptor {
129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    public:
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OutputDescriptor()
131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : samplingRate(0), format(0), channels(0), frameCount(0), latency(0)  {}
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t samplingRate;
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int32_t format;
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int32_t channels;
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        size_t frameCount;
137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t latency;
138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    };
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    //
141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    //
143fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address);
144fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address);
145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t setPhoneState(int state);
146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t setRingerMode(uint32_t mode, uint32_t mask);
147fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
148fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
149fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static audio_io_handle_t getOutput(audio_stream_type_t stream,
150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate = 0,
151fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        uint32_t format = AUDIO_FORMAT_DEFAULT,
152fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        uint32_t channels = AUDIO_CHANNEL_OUT_STEREO,
153fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_INDIRECT);
154de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t startOutput(audio_io_handle_t output,
155fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
156de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                int session = 0);
157de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t stopOutput(audio_io_handle_t output,
158fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                               audio_stream_type_t stream,
159de070137f11d346fba77605bd76a44c040a618fcEric Laurent                               int session = 0);
160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static void releaseOutput(audio_io_handle_t output);
161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static audio_io_handle_t getInput(int inputSource,
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate = 0,
163fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    uint32_t format = AUDIO_FORMAT_DEFAULT,
164fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    uint32_t channels = AUDIO_CHANNEL_IN_MONO,
1657c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0,
1667c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    int sessionId = 0);
167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t startInput(audio_io_handle_t input);
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t stopInput(audio_io_handle_t input);
169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static void releaseInput(audio_io_handle_t input);
170fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t initStreamVolume(audio_stream_type_t stream,
171c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                      int indexMin,
172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                      int indexMax);
173fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t setStreamVolumeIndex(audio_stream_type_t stream, int index);
174fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index);
175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
176fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static uint32_t getStrategyForStream(audio_stream_type_t stream);
177fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static uint32_t getDevicesForStream(audio_stream_type_t stream);
178de070137f11d346fba77605bd76a44c040a618fcEric Laurent
179de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
180de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t registerEffect(effect_descriptor_t *desc,
1817c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    audio_io_handle_t io,
182de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    uint32_t strategy,
183de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    int session,
184de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    int id);
185de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t unregisterEffect(int id);
186db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    static status_t setEffectEnabled(int id, bool enabled);
187de070137f11d346fba77605bd76a44c040a618fcEric Laurent
188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static const sp<IAudioPolicyService>& get_audio_policy_service();
189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
19089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // ----------------------------------------------------------------------------
19189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
19289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectprivate:
19389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
19489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient
19589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
19689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    public:
197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        AudioFlingerClient() {
19889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        }
199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
20089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        // DeathRecipient
20189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void binderDied(const wp<IBinder>& who);
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
20389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        // IAudioFlingerClient
204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        // indicate a change in the configuration of an output or input: keeps the cached
206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        // values for output/input parameters upto date in client process
207fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        virtual void ioConfigChanged(int event, int ioHandle, void *param2);
20889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    };
20989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    class AudioPolicyServiceClient: public IBinder::DeathRecipient
211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    public:
213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        AudioPolicyServiceClient() {
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        }
21589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        // DeathRecipient
217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        virtual void binderDied(const wp<IBinder>& who);
218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    };
219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static sp<AudioFlingerClient> gAudioFlingerClient;
221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient;
22289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    friend class AudioFlingerClient;
223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    friend class AudioPolicyServiceClient;
22489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
22589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static Mutex gLock;
22689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static sp<IAudioFlinger> gAudioFlinger;
22789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static audio_error_callback gAudioErrorCallback;
228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
22989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static size_t gInBuffSize;
23089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // previous parameters for recording buffer size queries
23189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static uint32_t gPrevInSamplingRate;
23289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static int gPrevInFormat;
23389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static int gPrevInChannelCount;
23489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static sp<IAudioPolicyService> gAudioPolicyService;
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // mapping between stream types and outputs
238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static DefaultKeyedVector<int, audio_io_handle_t> gStreamOutputMap;
239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // list of output descritor containing cached parameters (sampling rate, framecount, channel count...)
240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs;
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
24389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project};  // namespace android
24489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
24589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#endif  /*ANDROID_AUDIOSYSTEM_H_*/
246