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
201ab85ec401801ef9a9184650d0f5a1639b45eeb9Glenn Kasten#include <hardware/audio_effect.h>
21baac183f3808d7b68f184647a97bd381620415feEric Laurent#include <media/AudioPolicy.h>
221ab85ec401801ef9a9184650d0f5a1639b45eeb9Glenn Kasten#include <media/IAudioFlingerClient.h>
23b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent#include <media/IAudioPolicyServiceClient.h>
2464760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h>
257394a4f358fa9908a9f0a7c954b65c399f4268e6Dima Zavin#include <system/audio_policy.h>
261ab85ec401801ef9a9184650d0f5a1639b45eeb9Glenn Kasten#include <utils/Errors.h>
271ab85ec401801ef9a9184650d0f5a1639b45eeb9Glenn Kasten#include <utils/Mutex.h>
28db5cb14318bb24cd6ea14ff7ceea0d5e1f83d903Dima Zavin
2989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectnamespace android {
3089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
3189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projecttypedef void (*audio_error_callback)(status_t err);
32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
331ab85ec401801ef9a9184650d0f5a1639b45eeb9Glenn Kastenclass IAudioFlinger;
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
5872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    static status_t setStreamVolume(audio_stream_type_t stream, float value,
5972ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten                                    audio_io_handle_t output);
6072ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    static status_t getStreamVolume(audio_stream_type_t stream, float* volume,
6172ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten                                    audio_io_handle_t output);
62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // mute/unmute stream
64fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    static status_t setStreamMute(audio_stream_type_t stream, bool mute);
65fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    static status_t getStreamMute(audio_stream_type_t stream, bool* mute);
6689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
67f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    // set audio mode in audio hardware
68f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    static status_t setMode(audio_mode_t mode);
6989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
70272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    // returns true in *state if tracks are active on the specified stream or have been active
71eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    // in the past inPastMs milliseconds
726a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten    static status_t isStreamActive(audio_stream_type_t stream, bool *state, uint32_t inPastMs);
73272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    // returns true in *state if tracks are active for what qualifies as remote playback
74272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    // on the specified stream or have been active in the past inPastMs milliseconds. Remote
75272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    // playback isn't mutually exclusive with local playback.
76272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    static status_t isStreamActiveRemotely(audio_stream_type_t stream, bool *state,
776a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten            uint32_t inPastMs);
78d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    // returns true in *state if a recorder is currently recording with the specified source
79d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    static status_t isSourceActive(audio_source_t source, bool *state);
8089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // set/get audio hardware parameters. The function accepts a list of parameters
82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // key value pairs in the form: key1=value1;key2=value2;...
83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // Some keys are reserved for standard parameters (See AudioParameter class).
84c23885ebb142b9da31543789ecc3f7cf7111bc67Glenn Kasten    // The versions with audio_io_handle_t are intended for internal media framework use only.
85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs);
86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static String8  getParameters(audio_io_handle_t ioHandle, const String8& keys);
87c23885ebb142b9da31543789ecc3f7cf7111bc67Glenn Kasten    // The versions without audio_io_handle_t are intended for JNI.
88c23885ebb142b9da31543789ecc3f7cf7111bc67Glenn Kasten    static status_t setParameters(const String8& keyValuePairs);
89c23885ebb142b9da31543789ecc3f7cf7111bc67Glenn Kasten    static String8  getParameters(const String8& keys);
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
9189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static void setErrorCallback(audio_error_callback cb);
9289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
9389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // helper function to obtain AudioFlinger service handle
940ebd5f95b68a3a5c9e5509f21938c9e51e74d71bEric Laurent    static const sp<IAudioFlinger> get_audio_flinger();
9589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
9689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static float linearToLog(int volume);
9789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static int logToLinear(float volume);
9889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
99f94006ca0f30c27868c284e553f57bf467ae92bcGlenn Kasten    // Returned samplingRate and frameCount output values are guaranteed
100f94006ca0f30c27868c284e553f57bf467ae92bcGlenn Kasten    // to be non-zero if status == NO_ERROR
1013b16c766d1ae2cfd8487e8ffb2b23936fc0a8e17Glenn Kasten    static status_t getOutputSamplingRate(uint32_t* samplingRate,
1026a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten            audio_stream_type_t stream);
103e33054eb968cbf8ccaee1b0ff0301403902deed6Glenn Kasten    static status_t getOutputFrameCount(size_t* frameCount,
1046a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten            audio_stream_type_t stream);
10585ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    static status_t getOutputLatency(uint32_t* latency,
1066a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten            audio_stream_type_t stream);
1071a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent    static status_t getSamplingRate(audio_io_handle_t output,
1083b16c766d1ae2cfd8487e8ffb2b23936fc0a8e17Glenn Kasten                                          uint32_t* samplingRate);
1091a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent    // returns the number of frames per audio HAL write buffer. Corresponds to
110665470b36f202bcc8ee2f7417f68fd2608dd07c1Eric Laurent    // audio_stream->get_buffer_size()/audio_stream_out_frame_size()
1111a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent    static status_t getFrameCount(audio_io_handle_t output,
112e33054eb968cbf8ccaee1b0ff0301403902deed6Glenn Kasten                                  size_t* frameCount);
1131a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent    // returns the audio output stream latency in ms. Corresponds to
1141a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent    // audio_stream_out->get_latency()
1151a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent    static status_t getLatency(audio_io_handle_t output,
1161a9ed11a472493cac7f6dfcbfac2064526a493edEric Laurent                               uint32_t* latency);
117c813985abd8ba61e999b3505f6a332574f87a1beAndreas Huber
118b42f318d9733f88c7eb9bedfd33b086b8ea5dff5Glenn Kasten    // return status NO_ERROR implies *buffSize > 0
119dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten    static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
120dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten        audio_channel_mask_t channelMask, size_t* buffSize);
12189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
122f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent    static status_t setVoiceVolume(float volume);
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
124342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // return the number of audio frames written by AudioFlinger to audio HAL and
1250ed19594452c901c3c8665d06610fffe46895d06Glenn Kasten    // audio dsp to DAC since the specified output I/O handle has exited standby.
126342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // returned status (from utils/Errors.h) can be:
127342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data
128342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // - INVALID_OPERATION: Not supported on current hardware platform
129342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // - BAD_VALUE: invalid parameter
130342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // NOTE: this feature is not supported on all hardware platforms and it is
131342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    // necessary to check returned status before using the returned values.
132ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    static status_t getRenderPosition(audio_io_handle_t output,
133377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT                                      uint32_t *halFrames,
1340ed19594452c901c3c8665d06610fffe46895d06Glenn Kasten                                      uint32_t *dspFrames);
135342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent
136bf04a5d7f287fc712e0ed91849dc85c90c1e182dGlenn Kasten    // return the number of input frames lost by HAL implementation, or 0 if the handle is invalid
1375f972c031d4061f4f037c9fda1ea4bd9b6a756cdGlenn Kasten    static uint32_t getInputFramesLost(audio_io_handle_t ioHandle);
138be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent
139de3f8392fbf380ba6f09d009b00d7172477389a2Eric Laurent    // Allocate a new unique ID for use as an audio session ID or I/O handle.
140de3f8392fbf380ba6f09d009b00d7172477389a2Eric Laurent    // If unable to contact AudioFlinger, returns AUDIO_UNIQUE_ID_ALLOCATE instead.
141de3f8392fbf380ba6f09d009b00d7172477389a2Eric Laurent    // FIXME If AudioFlinger were to ever exhaust the unique ID namespace,
142de3f8392fbf380ba6f09d009b00d7172477389a2Eric Laurent    //       this method could fail by returning either AUDIO_UNIQUE_ID_ALLOCATE
143de3f8392fbf380ba6f09d009b00d7172477389a2Eric Laurent    //       or an unspecified existing unique ID.
144de3f8392fbf380ba6f09d009b00d7172477389a2Eric Laurent    static audio_unique_id_t newAudioUniqueId();
14585d109a4b0eddd76a8c5cee170bc2bcc99d00118Glenn Kasten
146d457c970c8d08519cd77280a90b61ae1e342cfe3Marco Nelissen    static void acquireAudioSessionId(int audioSession, pid_t pid);
147d457c970c8d08519cd77280a90b61ae1e342cfe3Marco Nelissen    static void releaseAudioSessionId(int audioSession, pid_t pid);
148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
14993c3d41bdb15e39dac0faea9c5b60f1637cd477cEric Laurent    // Get the HW synchronization source used for an audio session.
15093c3d41bdb15e39dac0faea9c5b60f1637cd477cEric Laurent    // Return a valid source or AUDIO_HW_SYNC_INVALID if an error occurs
15193c3d41bdb15e39dac0faea9c5b60f1637cd477cEric Laurent    // or no HW sync source is used.
15293c3d41bdb15e39dac0faea9c5b60f1637cd477cEric Laurent    static audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId);
15393c3d41bdb15e39dac0faea9c5b60f1637cd477cEric Laurent
154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // types of io configuration change events received with ioConfigChanged()
155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    enum io_config_event {
156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OUTPUT_OPENED,
157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OUTPUT_CLOSED,
158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OUTPUT_CONFIG_CHANGED,
159c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        INPUT_OPENED,
160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        INPUT_CLOSED,
161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        INPUT_CONFIG_CHANGED,
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        STREAM_CONFIG_CHANGED,
163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        NUM_CONFIG_EVENTS
164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    };
165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
16685ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    // audio output descriptor used to cache output configurations in client process to avoid
16785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    // frequent calls through IAudioFlinger
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    class OutputDescriptor {
169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    public:
170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        OutputDescriptor()
1716d238e5ecb4c4266bc865a067072a30187e55f97Glenn Kasten        : samplingRate(0), format(AUDIO_FORMAT_DEFAULT), channelMask(0), frameCount(0), latency(0)
1726d238e5ecb4c4266bc865a067072a30187e55f97Glenn Kasten            {}
173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t samplingRate;
175eced2daaa6c91a3731eef978ce65c6ec319c5e6aGlenn Kasten        audio_format_t format;
176fad226abd12435dbcd232f7de396f1a097b2bd5fGlenn Kasten        audio_channel_mask_t channelMask;
177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        size_t frameCount;
178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t latency;
179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    };
180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
181a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent    // Events used to synchronize actions between audio sessions.
18285ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    // For instance SYNC_EVENT_PRESENTATION_COMPLETE can be used to delay recording start until
18385ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    // playback is complete on another audio session.
184a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent    // See definitions in MediaSyncEvent.java
185a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent    enum sync_event_t {
186a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        SYNC_EVENT_SAME = -1,             // used internally to indicate restart with same event
187a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        SYNC_EVENT_NONE = 0,
188a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        SYNC_EVENT_PRESENTATION_COMPLETE,
189a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent
190a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        //
191a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        // Define new events here: SYNC_EVENT_START, SYNC_EVENT_STOP, SYNC_EVENT_TIME ...
192a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        //
193a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent        SYNC_EVENT_CNT,
194a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent    };
195a011e35b22f95f558d81dc9c94b68b1465c4661dEric Laurent
1962986460984580833161bdaabc7f17da1005a8961Eric Laurent    // Timeout for synchronous record start. Prevents from blocking the record thread forever
1972986460984580833161bdaabc7f17da1005a8961Eric Laurent    // if the trigger event is not fired.
1982986460984580833161bdaabc7f17da1005a8961Eric Laurent    static const uint32_t kSyncRecordStartTimeOutMs = 30000;
1992986460984580833161bdaabc7f17da1005a8961Eric Laurent
200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    //
201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    //
20385ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state,
20485ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                                                const char *device_address);
20585ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
20685ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                                                                const char *device_address);
207f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    static status_t setPhoneState(audio_mode_t state);
208fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
209fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
210d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten
211d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten    // Client must successfully hand off the handle reference to AudioFlinger via createTrack(),
212d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten    // or release it with releaseOutput().
213fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static audio_io_handle_t getOutput(audio_stream_type_t stream,
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate = 0,
21558f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                        audio_format_t format = AUDIO_FORMAT_DEFAULT,
216254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                        audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO,
217ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
218ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        const audio_offload_info_t *offloadInfo = NULL);
219e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent    static status_t getOutputForAttr(const audio_attributes_t *attr,
220e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_io_handle_t *output,
221e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_session_t session,
222e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_stream_type_t *stream,
2235bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                                        uint32_t samplingRate = 0,
2245bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                                        audio_format_t format = AUDIO_FORMAT_DEFAULT,
2255bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                                        audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO,
2265bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
2275bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                                        const audio_offload_info_t *offloadInfo = NULL);
228de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t startOutput(audio_io_handle_t output,
229fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
230e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                audio_session_t session);
231de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t stopOutput(audio_io_handle_t output,
232fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                               audio_stream_type_t stream,
233e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                               audio_session_t session);
234e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent    static void releaseOutput(audio_io_handle_t output,
235e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                              audio_stream_type_t stream,
236e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                              audio_session_t session);
237d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten
238d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten    // Client must successfully hand off the handle reference to AudioFlinger via openRecord(),
239d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten    // or release it with releaseInput().
240caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent    static status_t getInputForAttr(const audio_attributes_t *attr,
241caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                    audio_io_handle_t *input,
242caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                    audio_session_t session,
2436a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten                                    uint32_t samplingRate,
2446a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten                                    audio_format_t format,
2456a5e79733c760d7555aacec53c8bd21e8516c0a1Glenn Kasten                                    audio_channel_mask_t channelMask,
246caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                    audio_input_flags_t flags);
247d631d962a831de8b7614b14d7368eae60c816893Glenn Kasten
2484dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent    static status_t startInput(audio_io_handle_t input,
2494dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent                               audio_session_t session);
2504dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent    static status_t stopInput(audio_io_handle_t input,
2514dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent                              audio_session_t session);
2524dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent    static void releaseInput(audio_io_handle_t input,
2534dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent                             audio_session_t session);
254fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static status_t initStreamVolume(audio_stream_type_t stream,
255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                      int indexMin,
256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                      int indexMax);
25783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    static status_t setStreamVolumeIndex(audio_stream_type_t stream,
25883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                         int index,
25983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                         audio_devices_t device);
26083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    static status_t getStreamVolumeIndex(audio_stream_type_t stream,
26183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                         int *index,
26283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                         audio_devices_t device);
263c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
264fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    static uint32_t getStrategyForStream(audio_stream_type_t stream);
2656374252107fd6539397598195ea6defd5870fafbEric Laurent    static audio_devices_t getDevicesForStream(audio_stream_type_t stream);
266de070137f11d346fba77605bd76a44c040a618fcEric Laurent
26758e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    static audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc);
26858e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    static status_t registerEffect(const effect_descriptor_t *desc,
2697c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    audio_io_handle_t io,
270de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    uint32_t strategy,
271de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    int session,
272de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    int id);
273de070137f11d346fba77605bd76a44c040a618fcEric Laurent    static status_t unregisterEffect(int id);
274db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    static status_t setEffectEnabled(int id, bool enabled);
275de070137f11d346fba77605bd76a44c040a618fcEric Laurent
2769f6530f53ae9eda43f4e7c1cb30d2379db00aa00Eric Laurent    // clear stream to output mapping cache (gStreamOutputMap)
2779f6530f53ae9eda43f4e7c1cb30d2379db00aa00Eric Laurent    // and output configuration cache (gOutputs)
2789f6530f53ae9eda43f4e7c1cb30d2379db00aa00Eric Laurent    static void clearAudioConfigCache();
2799f6530f53ae9eda43f4e7c1cb30d2379db00aa00Eric Laurent
2800ebd5f95b68a3a5c9e5509f21938c9e51e74d71bEric Laurent    static const sp<IAudioPolicyService> get_audio_policy_service();
281c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
282cc0f1cfb69ce8b8985fc2c0984847a06a13ad22dGlenn Kasten    // helpers for android.media.AudioManager.getProperty(), see description there for meaning
2833b16c766d1ae2cfd8487e8ffb2b23936fc0a8e17Glenn Kasten    static uint32_t getPrimaryOutputSamplingRate();
284e33054eb968cbf8ccaee1b0ff0301403902deed6Glenn Kasten    static size_t getPrimaryOutputFrameCount();
285cc0f1cfb69ce8b8985fc2c0984847a06a13ad22dGlenn Kasten
2864182c4e2a07e2441fcd5c22eaff0ddfe7f826f61Glenn Kasten    static status_t setLowRamDevice(bool isLowRamDevice);
2874182c4e2a07e2441fcd5c22eaff0ddfe7f826f61Glenn Kasten
288ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    // Check if hw offload is possible for given format, stream type, sample rate,
289ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    // bit rate, duration, video and streaming or offload property is enabled
290ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    static bool isOffloadSupported(const audio_offload_info_t& info);
291ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald
29246291616486979986cba3ab83e894728ef53063fEric Laurent    // check presence of audio flinger service.
29346291616486979986cba3ab83e894728ef53063fEric Laurent    // returns NO_ERROR if binding to service succeeds, DEAD_OBJECT otherwise
29446291616486979986cba3ab83e894728ef53063fEric Laurent    static status_t checkAudioFlinger();
295203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
296203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* List available audio ports and their attributes */
297203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    static status_t listAudioPorts(audio_port_role_t role,
298203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                   audio_port_type_t type,
299203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                   unsigned int *num_ports,
300203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                   struct audio_port *ports,
301203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                   unsigned int *generation);
302203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
303203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Get attributes for a given audio port */
304203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    static status_t getAudioPort(struct audio_port *port);
305203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
306203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Create an audio patch between several source and sink ports */
307203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    static status_t createAudioPatch(const struct audio_patch *patch,
308203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                       audio_patch_handle_t *handle);
309203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
310203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Release an audio patch */
311203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    static status_t releaseAudioPatch(audio_patch_handle_t handle);
312203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
313203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* List existing audio patches */
314203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    static status_t listAudioPatches(unsigned int *num_patches,
315203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                      struct audio_patch *patches,
316203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                      unsigned int *generation);
317203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Set audio port configuration */
318203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    static status_t setAudioPortConfig(const struct audio_port_config *config);
319203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
320df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent
321df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent    static status_t acquireSoundTriggerSession(audio_session_t *session,
322df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent                                           audio_io_handle_t *ioHandle,
323df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent                                           audio_devices_t *device);
324df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent    static status_t releaseSoundTriggerSession(audio_session_t session);
325df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent
326bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent    static audio_mode_t getPhoneState();
327bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent
328baac183f3808d7b68f184647a97bd381620415feEric Laurent    static status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration);
329baac183f3808d7b68f184647a97bd381620415feEric Laurent
33089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // ----------------------------------------------------------------------------
33189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
332b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    class AudioPortCallback : public RefBase
333b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    {
334b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    public:
335b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
336b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent                AudioPortCallback() {}
337b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        virtual ~AudioPortCallback() {}
338b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
339b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        virtual void onAudioPortListUpdate() = 0;
340b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        virtual void onAudioPatchListUpdate() = 0;
341b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        virtual void onServiceDied() = 0;
342b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
343b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    };
344b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
345b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    static void setAudioPortCallback(sp<AudioPortCallback> callBack);
346b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
34789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectprivate:
34889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
34989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient
35089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
35189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    public:
352c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        AudioFlingerClient() {
35389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        }
354c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
35589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        // DeathRecipient
35689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void binderDied(const wp<IBinder>& who);
357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
35889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        // IAudioFlingerClient
359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        // indicate a change in the configuration of an output or input: keeps the cached
361b81cc8c6f3eec9edb255ea99b6a6f243585b1e38Glenn Kasten        // values for output/input parameters up-to-date in client process
362b81cc8c6f3eec9edb255ea99b6a6f243585b1e38Glenn Kasten        virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2);
36389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    };
36489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
365b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    class AudioPolicyServiceClient: public IBinder::DeathRecipient,
366b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent                                    public BnAudioPolicyServiceClient
367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    public:
369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        AudioPolicyServiceClient() {
370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        }
37189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        // DeathRecipient
373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        virtual void binderDied(const wp<IBinder>& who);
374b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
375b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        // IAudioPolicyServiceClient
376b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        virtual void onAudioPortListUpdate();
377b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        virtual void onAudioPatchListUpdate();
378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    };
379c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
380c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static sp<AudioFlingerClient> gAudioFlingerClient;
381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient;
38289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    friend class AudioFlingerClient;
383c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    friend class AudioPolicyServiceClient;
38489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
385f6778fd0c72ab54328f0e9f5ecf0017b73e99dd8Eric Laurent    static Mutex gLock;      // protects gAudioFlinger and gAudioErrorCallback,
386f6778fd0c72ab54328f0e9f5ecf0017b73e99dd8Eric Laurent    static Mutex gLockCache; // protects gOutputs, gPrevInSamplingRate, gPrevInFormat,
387f6778fd0c72ab54328f0e9f5ecf0017b73e99dd8Eric Laurent                             // gPrevInChannelMask and gInBuffSize
388f6778fd0c72ab54328f0e9f5ecf0017b73e99dd8Eric Laurent    static Mutex gLockAPS;   // protects gAudioPolicyService and gAudioPolicyServiceClient
389f6778fd0c72ab54328f0e9f5ecf0017b73e99dd8Eric Laurent    static Mutex gLockAPC;   // protects gAudioPortCallback
39089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static sp<IAudioFlinger> gAudioFlinger;
39189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static audio_error_callback gAudioErrorCallback;
392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
39389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static size_t gInBuffSize;
39489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // previous parameters for recording buffer size queries
39589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static uint32_t gPrevInSamplingRate;
39658f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten    static audio_format_t gPrevInFormat;
397dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten    static audio_channel_mask_t gPrevInChannelMask;
39889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static sp<IAudioPolicyService> gAudioPolicyService;
400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
4019f6530f53ae9eda43f4e7c1cb30d2379db00aa00Eric Laurent    // list of output descriptors containing cached parameters
4029f6530f53ae9eda43f4e7c1cb30d2379db00aa00Eric Laurent    // (sampling rate, framecount, channel count...)
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs;
404b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent
405b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    static sp<AudioPortCallback> gAudioPortCallback;
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
407c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
40889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project};  // namespace android
40989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
41089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#endif  /*ANDROID_AUDIOSYSTEM_H_*/
411