Home | History | Annotate | Download | only in media
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_AUDIOSYSTEM_H_
     18 #define ANDROID_AUDIOSYSTEM_H_
     19 
     20 #include <sys/types.h>
     21 
     22 #include <media/AudioPolicy.h>
     23 #include <media/AudioProductStrategy.h>
     24 #include <media/AudioVolumeGroup.h>
     25 #include <media/AudioIoDescriptor.h>
     26 #include <media/IAudioFlingerClient.h>
     27 #include <media/IAudioPolicyServiceClient.h>
     28 #include <media/MicrophoneInfo.h>
     29 #include <system/audio.h>
     30 #include <system/audio_effect.h>
     31 #include <system/audio_policy.h>
     32 #include <utils/Errors.h>
     33 #include <utils/Mutex.h>
     34 #include <vector>
     35 
     36 namespace android {
     37 
     38 typedef void (*audio_error_callback)(status_t err);
     39 typedef void (*dynamic_policy_callback)(int event, String8 regId, int val);
     40 typedef void (*record_config_callback)(int event,
     41                                        const record_client_info_t *clientInfo,
     42                                        const audio_config_base_t *clientConfig,
     43                                        std::vector<effect_descriptor_t> clientEffects,
     44                                        const audio_config_base_t *deviceConfig,
     45                                        std::vector<effect_descriptor_t> effects,
     46                                        audio_patch_handle_t patchHandle,
     47                                        audio_source_t source);
     48 
     49 class IAudioFlinger;
     50 class IAudioPolicyService;
     51 class String8;
     52 
     53 class AudioSystem
     54 {
     55 public:
     56 
     57     // FIXME Declare in binder opcode order, similarly to IAudioFlinger.h and IAudioFlinger.cpp
     58 
     59     /* These are static methods to control the system-wide AudioFlinger
     60      * only privileged processes can have access to them
     61      */
     62 
     63     // mute/unmute microphone
     64     static status_t muteMicrophone(bool state);
     65     static status_t isMicrophoneMuted(bool *state);
     66 
     67     // set/get master volume
     68     static status_t setMasterVolume(float value);
     69     static status_t getMasterVolume(float* volume);
     70 
     71     // mute/unmute audio outputs
     72     static status_t setMasterMute(bool mute);
     73     static status_t getMasterMute(bool* mute);
     74 
     75     // set/get stream volume on specified output
     76     static status_t setStreamVolume(audio_stream_type_t stream, float value,
     77                                     audio_io_handle_t output);
     78     static status_t getStreamVolume(audio_stream_type_t stream, float* volume,
     79                                     audio_io_handle_t output);
     80 
     81     // mute/unmute stream
     82     static status_t setStreamMute(audio_stream_type_t stream, bool mute);
     83     static status_t getStreamMute(audio_stream_type_t stream, bool* mute);
     84 
     85     // set audio mode in audio hardware
     86     static status_t setMode(audio_mode_t mode);
     87 
     88     // returns true in *state if tracks are active on the specified stream or have been active
     89     // in the past inPastMs milliseconds
     90     static status_t isStreamActive(audio_stream_type_t stream, bool *state, uint32_t inPastMs);
     91     // returns true in *state if tracks are active for what qualifies as remote playback
     92     // on the specified stream or have been active in the past inPastMs milliseconds. Remote
     93     // playback isn't mutually exclusive with local playback.
     94     static status_t isStreamActiveRemotely(audio_stream_type_t stream, bool *state,
     95             uint32_t inPastMs);
     96     // returns true in *state if a recorder is currently recording with the specified source
     97     static status_t isSourceActive(audio_source_t source, bool *state);
     98 
     99     // set/get audio hardware parameters. The function accepts a list of parameters
    100     // key value pairs in the form: key1=value1;key2=value2;...
    101     // Some keys are reserved for standard parameters (See AudioParameter class).
    102     // The versions with audio_io_handle_t are intended for internal media framework use only.
    103     static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs);
    104     static String8  getParameters(audio_io_handle_t ioHandle, const String8& keys);
    105     // The versions without audio_io_handle_t are intended for JNI.
    106     static status_t setParameters(const String8& keyValuePairs);
    107     static String8  getParameters(const String8& keys);
    108 
    109     static void setErrorCallback(audio_error_callback cb);
    110     static void setDynPolicyCallback(dynamic_policy_callback cb);
    111     static void setRecordConfigCallback(record_config_callback);
    112 
    113     // helper function to obtain AudioFlinger service handle
    114     static const sp<IAudioFlinger> get_audio_flinger();
    115 
    116     static float linearToLog(int volume);
    117     static int logToLinear(float volume);
    118     static size_t calculateMinFrameCount(
    119             uint32_t afLatencyMs, uint32_t afFrameCount, uint32_t afSampleRate,
    120             uint32_t sampleRate, float speed /*, uint32_t notificationsPerBufferReq*/);
    121 
    122     // Returned samplingRate and frameCount output values are guaranteed
    123     // to be non-zero if status == NO_ERROR
    124     // FIXME This API assumes a route, and so should be deprecated.
    125     static status_t getOutputSamplingRate(uint32_t* samplingRate,
    126             audio_stream_type_t stream);
    127     // FIXME This API assumes a route, and so should be deprecated.
    128     static status_t getOutputFrameCount(size_t* frameCount,
    129             audio_stream_type_t stream);
    130     // FIXME This API assumes a route, and so should be deprecated.
    131     static status_t getOutputLatency(uint32_t* latency,
    132             audio_stream_type_t stream);
    133     // returns the audio HAL sample rate
    134     static status_t getSamplingRate(audio_io_handle_t ioHandle,
    135                                           uint32_t* samplingRate);
    136     // For output threads with a fast mixer, returns the number of frames per normal mixer buffer.
    137     // For output threads without a fast mixer, or for input, this is same as getFrameCountHAL().
    138     static status_t getFrameCount(audio_io_handle_t ioHandle,
    139                                   size_t* frameCount);
    140     // returns the audio output latency in ms. Corresponds to
    141     // audio_stream_out->get_latency()
    142     static status_t getLatency(audio_io_handle_t output,
    143                                uint32_t* latency);
    144 
    145     // return status NO_ERROR implies *buffSize > 0
    146     // FIXME This API assumes a route, and so should deprecated.
    147     static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
    148         audio_channel_mask_t channelMask, size_t* buffSize);
    149 
    150     static status_t setVoiceVolume(float volume);
    151 
    152     // return the number of audio frames written by AudioFlinger to audio HAL and
    153     // audio dsp to DAC since the specified output has exited standby.
    154     // returned status (from utils/Errors.h) can be:
    155     // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data
    156     // - INVALID_OPERATION: Not supported on current hardware platform
    157     // - BAD_VALUE: invalid parameter
    158     // NOTE: this feature is not supported on all hardware platforms and it is
    159     // necessary to check returned status before using the returned values.
    160     static status_t getRenderPosition(audio_io_handle_t output,
    161                                       uint32_t *halFrames,
    162                                       uint32_t *dspFrames);
    163 
    164     // return the number of input frames lost by HAL implementation, or 0 if the handle is invalid
    165     static uint32_t getInputFramesLost(audio_io_handle_t ioHandle);
    166 
    167     // Allocate a new unique ID for use as an audio session ID or I/O handle.
    168     // If unable to contact AudioFlinger, returns AUDIO_UNIQUE_ID_ALLOCATE instead.
    169     // FIXME If AudioFlinger were to ever exhaust the unique ID namespace,
    170     //       this method could fail by returning either a reserved ID like AUDIO_UNIQUE_ID_ALLOCATE
    171     //       or an unspecified existing unique ID.
    172     static audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use);
    173 
    174     static void acquireAudioSessionId(audio_session_t audioSession, pid_t pid);
    175     static void releaseAudioSessionId(audio_session_t audioSession, pid_t pid);
    176 
    177     // Get the HW synchronization source used for an audio session.
    178     // Return a valid source or AUDIO_HW_SYNC_INVALID if an error occurs
    179     // or no HW sync source is used.
    180     static audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId);
    181 
    182     // Indicate JAVA services are ready (scheduling, power management ...)
    183     static status_t systemReady();
    184 
    185     // Returns the number of frames per audio HAL buffer.
    186     // Corresponds to audio_stream->get_buffer_size()/audio_stream_in_frame_size() for input.
    187     // See also getFrameCount().
    188     static status_t getFrameCountHAL(audio_io_handle_t ioHandle,
    189                                      size_t* frameCount);
    190 
    191     // Events used to synchronize actions between audio sessions.
    192     // For instance SYNC_EVENT_PRESENTATION_COMPLETE can be used to delay recording start until
    193     // playback is complete on another audio session.
    194     // See definitions in MediaSyncEvent.java
    195     enum sync_event_t {
    196         SYNC_EVENT_SAME = -1,             // used internally to indicate restart with same event
    197         SYNC_EVENT_NONE = 0,
    198         SYNC_EVENT_PRESENTATION_COMPLETE,
    199 
    200         //
    201         // Define new events here: SYNC_EVENT_START, SYNC_EVENT_STOP, SYNC_EVENT_TIME ...
    202         //
    203         SYNC_EVENT_CNT,
    204     };
    205 
    206     // Timeout for synchronous record start. Prevents from blocking the record thread forever
    207     // if the trigger event is not fired.
    208     static const uint32_t kSyncRecordStartTimeOutMs = 30000;
    209 
    210     //
    211     // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
    212     //
    213     static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state,
    214                                              const char *device_address, const char *device_name,
    215                                              audio_format_t encodedFormat);
    216     static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
    217                                                                 const char *device_address);
    218     static status_t handleDeviceConfigChange(audio_devices_t device,
    219                                              const char *device_address,
    220                                              const char *device_name,
    221                                              audio_format_t encodedFormat);
    222     static status_t setPhoneState(audio_mode_t state);
    223     static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
    224     static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
    225 
    226     static status_t getOutputForAttr(audio_attributes_t *attr,
    227                                      audio_io_handle_t *output,
    228                                      audio_session_t session,
    229                                      audio_stream_type_t *stream,
    230                                      pid_t pid,
    231                                      uid_t uid,
    232                                      const audio_config_t *config,
    233                                      audio_output_flags_t flags,
    234                                      audio_port_handle_t *selectedDeviceId,
    235                                      audio_port_handle_t *portId,
    236                                      std::vector<audio_io_handle_t> *secondaryOutputs);
    237     static status_t startOutput(audio_port_handle_t portId);
    238     static status_t stopOutput(audio_port_handle_t portId);
    239     static void releaseOutput(audio_port_handle_t portId);
    240 
    241     // Client must successfully hand off the handle reference to AudioFlinger via createRecord(),
    242     // or release it with releaseInput().
    243     static status_t getInputForAttr(const audio_attributes_t *attr,
    244                                     audio_io_handle_t *input,
    245                                     audio_unique_id_t riid,
    246                                     audio_session_t session,
    247                                     pid_t pid,
    248                                     uid_t uid,
    249                                     const String16& opPackageName,
    250                                     const audio_config_base_t *config,
    251                                     audio_input_flags_t flags,
    252                                     audio_port_handle_t *selectedDeviceId,
    253                                     audio_port_handle_t *portId);
    254 
    255     static status_t startInput(audio_port_handle_t portId);
    256     static status_t stopInput(audio_port_handle_t portId);
    257     static void releaseInput(audio_port_handle_t portId);
    258     static status_t initStreamVolume(audio_stream_type_t stream,
    259                                       int indexMin,
    260                                       int indexMax);
    261     static status_t setStreamVolumeIndex(audio_stream_type_t stream,
    262                                          int index,
    263                                          audio_devices_t device);
    264     static status_t getStreamVolumeIndex(audio_stream_type_t stream,
    265                                          int *index,
    266                                          audio_devices_t device);
    267 
    268     static status_t setVolumeIndexForAttributes(const audio_attributes_t &attr,
    269                                                 int index,
    270                                                 audio_devices_t device);
    271     static status_t getVolumeIndexForAttributes(const audio_attributes_t &attr,
    272                                                 int &index,
    273                                                 audio_devices_t device);
    274 
    275     static status_t getMaxVolumeIndexForAttributes(const audio_attributes_t &attr, int &index);
    276 
    277     static status_t getMinVolumeIndexForAttributes(const audio_attributes_t &attr, int &index);
    278 
    279     static uint32_t getStrategyForStream(audio_stream_type_t stream);
    280     static audio_devices_t getDevicesForStream(audio_stream_type_t stream);
    281 
    282     static audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc);
    283     static status_t registerEffect(const effect_descriptor_t *desc,
    284                                     audio_io_handle_t io,
    285                                     uint32_t strategy,
    286                                     audio_session_t session,
    287                                     int id);
    288     static status_t unregisterEffect(int id);
    289     static status_t setEffectEnabled(int id, bool enabled);
    290     static status_t moveEffectsToIo(const std::vector<int>& ids, audio_io_handle_t io);
    291 
    292     // clear stream to output mapping cache (gStreamOutputMap)
    293     // and output configuration cache (gOutputs)
    294     static void clearAudioConfigCache();
    295 
    296     static const sp<IAudioPolicyService> get_audio_policy_service();
    297 
    298     // helpers for android.media.AudioManager.getProperty(), see description there for meaning
    299     static uint32_t getPrimaryOutputSamplingRate();
    300     static size_t getPrimaryOutputFrameCount();
    301 
    302     static status_t setLowRamDevice(bool isLowRamDevice, int64_t totalMemory);
    303 
    304     static status_t setAllowedCapturePolicy(uid_t uid, audio_flags_mask_t flags);
    305 
    306     // Check if hw offload is possible for given format, stream type, sample rate,
    307     // bit rate, duration, video and streaming or offload property is enabled
    308     static bool isOffloadSupported(const audio_offload_info_t& info);
    309 
    310     // check presence of audio flinger service.
    311     // returns NO_ERROR if binding to service succeeds, DEAD_OBJECT otherwise
    312     static status_t checkAudioFlinger();
    313 
    314     /* List available audio ports and their attributes */
    315     static status_t listAudioPorts(audio_port_role_t role,
    316                                    audio_port_type_t type,
    317                                    unsigned int *num_ports,
    318                                    struct audio_port *ports,
    319                                    unsigned int *generation);
    320 
    321     /* Get attributes for a given audio port */
    322     static status_t getAudioPort(struct audio_port *port);
    323 
    324     /* Create an audio patch between several source and sink ports */
    325     static status_t createAudioPatch(const struct audio_patch *patch,
    326                                        audio_patch_handle_t *handle);
    327 
    328     /* Release an audio patch */
    329     static status_t releaseAudioPatch(audio_patch_handle_t handle);
    330 
    331     /* List existing audio patches */
    332     static status_t listAudioPatches(unsigned int *num_patches,
    333                                       struct audio_patch *patches,
    334                                       unsigned int *generation);
    335     /* Set audio port configuration */
    336     static status_t setAudioPortConfig(const struct audio_port_config *config);
    337 
    338 
    339     static status_t acquireSoundTriggerSession(audio_session_t *session,
    340                                            audio_io_handle_t *ioHandle,
    341                                            audio_devices_t *device);
    342     static status_t releaseSoundTriggerSession(audio_session_t session);
    343 
    344     static audio_mode_t getPhoneState();
    345 
    346     static status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration);
    347 
    348     static status_t setUidDeviceAffinities(uid_t uid, const Vector<AudioDeviceTypeAddr>& devices);
    349 
    350     static status_t removeUidDeviceAffinities(uid_t uid);
    351 
    352     static status_t startAudioSource(const struct audio_port_config *source,
    353                                      const audio_attributes_t *attributes,
    354                                      audio_port_handle_t *portId);
    355     static status_t stopAudioSource(audio_port_handle_t portId);
    356 
    357     static status_t setMasterMono(bool mono);
    358     static status_t getMasterMono(bool *mono);
    359 
    360     static status_t setMasterBalance(float balance);
    361     static status_t getMasterBalance(float *balance);
    362 
    363     static float    getStreamVolumeDB(
    364             audio_stream_type_t stream, int index, audio_devices_t device);
    365 
    366     static status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
    367 
    368     static status_t getHwOffloadEncodingFormatsSupportedForA2DP(
    369                                     std::vector<audio_format_t> *formats);
    370 
    371     // numSurroundFormats holds the maximum number of formats and bool value allowed in the array.
    372     // When numSurroundFormats is 0, surroundFormats and surroundFormatsEnabled will not be
    373     // populated. The actual number of surround formats should be returned at numSurroundFormats.
    374     static status_t getSurroundFormats(unsigned int *numSurroundFormats,
    375                                        audio_format_t *surroundFormats,
    376                                        bool *surroundFormatsEnabled,
    377                                        bool reported);
    378     static status_t setSurroundFormatEnabled(audio_format_t audioFormat, bool enabled);
    379 
    380     static status_t setAssistantUid(uid_t uid);
    381     static status_t setA11yServicesUids(const std::vector<uid_t>& uids);
    382 
    383     static bool     isHapticPlaybackSupported();
    384 
    385     static status_t listAudioProductStrategies(AudioProductStrategyVector &strategies);
    386     static status_t getProductStrategyFromAudioAttributes(const AudioAttributes &aa,
    387                                                         product_strategy_t &productStrategy);
    388 
    389     static audio_attributes_t streamTypeToAttributes(audio_stream_type_t stream);
    390     static audio_stream_type_t attributesToStreamType(const audio_attributes_t &attr);
    391 
    392     static status_t listAudioVolumeGroups(AudioVolumeGroupVector &groups);
    393 
    394     static status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa,
    395                                                       volume_group_t &volumeGroup);
    396 
    397     static status_t setRttEnabled(bool enabled);
    398 
    399     // ----------------------------------------------------------------------------
    400 
    401     class AudioVolumeGroupCallback : public RefBase
    402     {
    403     public:
    404 
    405         AudioVolumeGroupCallback() {}
    406         virtual ~AudioVolumeGroupCallback() {}
    407 
    408         virtual void onAudioVolumeGroupChanged(volume_group_t group, int flags) = 0;
    409         virtual void onServiceDied() = 0;
    410 
    411     };
    412 
    413     static status_t addAudioVolumeGroupCallback(const sp<AudioVolumeGroupCallback>& callback);
    414     static status_t removeAudioVolumeGroupCallback(const sp<AudioVolumeGroupCallback>& callback);
    415 
    416     class AudioPortCallback : public RefBase
    417     {
    418     public:
    419 
    420                 AudioPortCallback() {}
    421         virtual ~AudioPortCallback() {}
    422 
    423         virtual void onAudioPortListUpdate() = 0;
    424         virtual void onAudioPatchListUpdate() = 0;
    425         virtual void onServiceDied() = 0;
    426 
    427     };
    428 
    429     static status_t addAudioPortCallback(const sp<AudioPortCallback>& callback);
    430     static status_t removeAudioPortCallback(const sp<AudioPortCallback>& callback);
    431 
    432     class AudioDeviceCallback : public RefBase
    433     {
    434     public:
    435 
    436                 AudioDeviceCallback() {}
    437         virtual ~AudioDeviceCallback() {}
    438 
    439         virtual void onAudioDeviceUpdate(audio_io_handle_t audioIo,
    440                                          audio_port_handle_t deviceId) = 0;
    441     };
    442 
    443     static status_t addAudioDeviceCallback(const wp<AudioDeviceCallback>& callback,
    444                                            audio_io_handle_t audioIo,
    445                                            audio_port_handle_t portId);
    446     static status_t removeAudioDeviceCallback(const wp<AudioDeviceCallback>& callback,
    447                                               audio_io_handle_t audioIo,
    448                                               audio_port_handle_t portId);
    449 
    450     static audio_port_handle_t getDeviceIdForIo(audio_io_handle_t audioIo);
    451 
    452 private:
    453 
    454     class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient
    455     {
    456     public:
    457         AudioFlingerClient() :
    458             mInBuffSize(0), mInSamplingRate(0),
    459             mInFormat(AUDIO_FORMAT_DEFAULT), mInChannelMask(AUDIO_CHANNEL_NONE) {
    460         }
    461 
    462         void clearIoCache();
    463         status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
    464                                     audio_channel_mask_t channelMask, size_t* buffSize);
    465         sp<AudioIoDescriptor> getIoDescriptor(audio_io_handle_t ioHandle);
    466 
    467         // DeathRecipient
    468         virtual void binderDied(const wp<IBinder>& who);
    469 
    470         // IAudioFlingerClient
    471 
    472         // indicate a change in the configuration of an output or input: keeps the cached
    473         // values for output/input parameters up-to-date in client process
    474         virtual void ioConfigChanged(audio_io_config_event event,
    475                                      const sp<AudioIoDescriptor>& ioDesc);
    476 
    477 
    478         status_t addAudioDeviceCallback(const wp<AudioDeviceCallback>& callback,
    479                                                audio_io_handle_t audioIo,
    480                                                audio_port_handle_t portId);
    481         status_t removeAudioDeviceCallback(const wp<AudioDeviceCallback>& callback,
    482                                            audio_io_handle_t audioIo,
    483                                            audio_port_handle_t portId);
    484 
    485         audio_port_handle_t getDeviceIdForIo(audio_io_handle_t audioIo);
    486 
    487     private:
    488         Mutex                               mLock;
    489         DefaultKeyedVector<audio_io_handle_t, sp<AudioIoDescriptor> >   mIoDescriptors;
    490 
    491         std::map<audio_io_handle_t, std::map<audio_port_handle_t, wp<AudioDeviceCallback>>>
    492                 mAudioDeviceCallbacks;
    493         // cached values for recording getInputBufferSize() queries
    494         size_t                              mInBuffSize;    // zero indicates cache is invalid
    495         uint32_t                            mInSamplingRate;
    496         audio_format_t                      mInFormat;
    497         audio_channel_mask_t                mInChannelMask;
    498         sp<AudioIoDescriptor> getIoDescriptor_l(audio_io_handle_t ioHandle);
    499     };
    500 
    501     class AudioPolicyServiceClient: public IBinder::DeathRecipient,
    502                                     public BnAudioPolicyServiceClient
    503     {
    504     public:
    505         AudioPolicyServiceClient() {
    506         }
    507 
    508         int addAudioPortCallback(const sp<AudioPortCallback>& callback);
    509         int removeAudioPortCallback(const sp<AudioPortCallback>& callback);
    510         bool isAudioPortCbEnabled() const { return (mAudioPortCallbacks.size() != 0); }
    511 
    512         int addAudioVolumeGroupCallback(const sp<AudioVolumeGroupCallback>& callback);
    513         int removeAudioVolumeGroupCallback(const sp<AudioVolumeGroupCallback>& callback);
    514         bool isAudioVolumeGroupCbEnabled() const { return (mAudioVolumeGroupCallback.size() != 0); }
    515 
    516         // DeathRecipient
    517         virtual void binderDied(const wp<IBinder>& who);
    518 
    519         // IAudioPolicyServiceClient
    520         virtual void onAudioPortListUpdate();
    521         virtual void onAudioPatchListUpdate();
    522         virtual void onAudioVolumeGroupChanged(volume_group_t group, int flags);
    523         virtual void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state);
    524         virtual void onRecordingConfigurationUpdate(int event,
    525                                                     const record_client_info_t *clientInfo,
    526                                                     const audio_config_base_t *clientConfig,
    527                                                     std::vector<effect_descriptor_t> clientEffects,
    528                                                     const audio_config_base_t *deviceConfig,
    529                                                     std::vector<effect_descriptor_t> effects,
    530                                                     audio_patch_handle_t patchHandle,
    531                                                     audio_source_t source);
    532 
    533     private:
    534         Mutex                               mLock;
    535         Vector <sp <AudioPortCallback> >    mAudioPortCallbacks;
    536         Vector <sp <AudioVolumeGroupCallback> > mAudioVolumeGroupCallback;
    537     };
    538 
    539     static audio_io_handle_t getOutput(audio_stream_type_t stream);
    540     static const sp<AudioFlingerClient> getAudioFlingerClient();
    541     static sp<AudioIoDescriptor> getIoDescriptor(audio_io_handle_t ioHandle);
    542 
    543     static sp<AudioFlingerClient> gAudioFlingerClient;
    544     static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient;
    545     friend class AudioFlingerClient;
    546     friend class AudioPolicyServiceClient;
    547 
    548     static Mutex gLock;      // protects gAudioFlinger and gAudioErrorCallback,
    549     static Mutex gLockAPS;   // protects gAudioPolicyService and gAudioPolicyServiceClient
    550     static sp<IAudioFlinger> gAudioFlinger;
    551     static audio_error_callback gAudioErrorCallback;
    552     static dynamic_policy_callback gDynPolicyCallback;
    553     static record_config_callback gRecordConfigCallback;
    554 
    555     static size_t gInBuffSize;
    556     // previous parameters for recording buffer size queries
    557     static uint32_t gPrevInSamplingRate;
    558     static audio_format_t gPrevInFormat;
    559     static audio_channel_mask_t gPrevInChannelMask;
    560 
    561     static sp<IAudioPolicyService> gAudioPolicyService;
    562 };
    563 
    564 };  // namespace android
    565 
    566 #endif  /*ANDROID_AUDIOSYSTEM_H_*/
    567