diff options
author | Eric Laurent <elaurent@google.com> | 2012-03-28 11:27:13 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2012-04-03 20:49:35 -0700 |
commit | 70c236c9290732782d5267935af1475b8d5ae602 (patch) | |
tree | 04c294d811d4da387b1f993a1a0f38f9587c8a7a /include | |
parent | 5ccdf14a85ed66ac54036fb393acc06ea7acfed6 (diff) | |
download | hardware_libhardware_legacy-70c236c9290732782d5267935af1475b8d5ae602.zip hardware_libhardware_legacy-70c236c9290732782d5267935af1475b8d5ae602.tar.gz hardware_libhardware_legacy-70c236c9290732782d5267935af1475b8d5ae602.tar.bz2 |
audio policy: load audio hw modules
Audio hw modules are now loaded according to configuration
data read from audio_policy.conf. They are not loaded anymore
from a hardcoded list in AudiFlinger.
Output and input streams are opened on the hw module by which
they are exposed.
Also removed obsolete "acoustics" flags for input streams.
Change-Id: I8dc658cc83890d3ac7d5e36c372a03732aa5b0c4
Diffstat (limited to 'include')
-rw-r--r-- | include/hardware_legacy/AudioPolicyInterface.h | 30 | ||||
-rw-r--r-- | include/hardware_legacy/AudioPolicyManagerBase.h | 62 |
2 files changed, 62 insertions, 30 deletions
diff --git a/include/hardware_legacy/AudioPolicyInterface.h b/include/hardware_legacy/AudioPolicyInterface.h index 0344c3b..fd1b179 100644 --- a/include/hardware_legacy/AudioPolicyInterface.h +++ b/include/hardware_legacy/AudioPolicyInterface.h @@ -170,6 +170,13 @@ public: virtual ~AudioPolicyClientInterface() {} // + // Audio HW module functions + // + + // loads a HW module. + virtual audio_module_handle_t loadHwModule(const char *name) = 0; + + // // Audio output Control functions // @@ -177,12 +184,13 @@ public: // in case the audio policy manager has no specific requirements for the output being opened. // When the function returns, the parameter values reflect the actual values used by the audio hardware output stream. // The audio policy manager can check if the proposed parameters are suitable or not and act accordingly. - virtual audio_io_handle_t openOutput(uint32_t *pDevices, - uint32_t *pSamplingRate, - uint32_t *pFormat, - uint32_t *pChannels, - uint32_t *pLatencyMs, - AudioSystem::output_flags flags) = 0; + virtual audio_io_handle_t openOutput(audio_module_handle_t module, + audio_devices_t *pDevices, + uint32_t *pSamplingRate, + audio_format_t *pFormat, + audio_channel_mask_t *pChannelMask, + uint32_t *pLatencyMs, + audio_policy_output_flags_t flags) = 0; // creates a special output that is duplicated to the two outputs passed as arguments. The duplication is performed by // a special mixer thread in the AudioFlinger. virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, audio_io_handle_t output2) = 0; @@ -199,11 +207,11 @@ public: // // opens an audio input - virtual audio_io_handle_t openInput(uint32_t *pDevices, - uint32_t *pSamplingRate, - uint32_t *pFormat, - uint32_t *pChannels, - audio_in_acoustics_t acoustics) = 0; + virtual audio_io_handle_t openInput(audio_module_handle_t module, + audio_devices_t *pDevices, + uint32_t *pSamplingRate, + audio_format_t *pFormat, + audio_channel_mask_t *pChannelMask) = 0; // closes an audio input virtual status_t closeInput(audio_io_handle_t input) = 0; // diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h index bc614f2..6f6451b 100644 --- a/include/hardware_legacy/AudioPolicyManagerBase.h +++ b/include/hardware_legacy/AudioPolicyManagerBase.h @@ -169,6 +169,21 @@ protected: DEVICE_CATEGORY_CNT }; + class IOProfile; + + class HwModule { + public: + HwModule(const char *name); + ~HwModule(); + + void dump(int fd); + + const char *const mName; // base name of the audio HW module (primary, a2dp ...) + audio_module_handle_t mHandle; + Vector <IOProfile *> mOutputProfiles; // output profiles exposed by this module + Vector <IOProfile *> mInputProfiles; // input profiles exposed by this module + }; + // the IOProfile class describes the capabilities of an output or input stream. // It is currently assumed that all combination of listed parameters are supported. // It is used by the policy manager to determine if an output or input is suitable for @@ -176,10 +191,16 @@ protected: // to/from it. class IOProfile { - public: - IOProfile(const char *module); + public: + IOProfile(HwModule *module); ~IOProfile(); + bool isCompatibleProfile(audio_devices_t device, + uint32_t samplingRate, + uint32_t format, + uint32_t channelMask, + audio_policy_output_flags_t flags) const; + void dump(int fd); Vector <uint32_t> mSamplingRates; // supported sampling rates @@ -189,8 +210,7 @@ protected: // routed to) audio_policy_output_flags_t mFlags; // attribute flags (e.g primary output, // direct output...). For outputs only. - char *mModuleName; // base name of the audio HW module exposing this I/O stream - // (primary, a2dp ...) + HwModule *mModule; // audio HW module exposing this I/O stream }; // default volume curve @@ -225,10 +245,10 @@ protected: audio_io_handle_t mId; // output handle uint32_t mSamplingRate; // - uint32_t mFormat; // - uint32_t mChannels; // output configuration + audio_format_t mFormat; // + audio_channel_mask_t mChannelMask; // output configuration uint32_t mLatency; // - AudioSystem::output_flags mFlags; // + audio_policy_output_flags_t mFlags; // audio_devices_t mDevice; // current device this output is routed to uint32_t mRefCount[AudioSystem::NUM_STREAM_TYPES]; // number of streams of each type using this output nsecs_t mStopTime[AudioSystem::NUM_STREAM_TYPES]; @@ -251,9 +271,8 @@ protected: status_t dump(int fd); uint32_t mSamplingRate; // - uint32_t mFormat; // input configuration - uint32_t mChannels; // - AudioSystem::audio_in_acoustics mAcoustics; // + audio_format_t mFormat; // input configuration + audio_channel_mask_t mChannelMask; // audio_devices_t mDevice; // current device this input is routed to uint32_t mRefCount; // number of AudioRecord clients using this output int mInputSource; // input source selected by application (mediarecorder.h) @@ -395,12 +414,12 @@ protected: // true if current platform requires a specific output to be opened for this particular // set of parameters. This function is called by getOutput() and is implemented by platform // specific audio policy manager. - virtual bool needsDirectOuput(AudioSystem::stream_type stream, - uint32_t samplingRate, - uint32_t format, - uint32_t channels, - AudioSystem::output_flags flags, - uint32_t device); + virtual bool needsDirectOuput(audio_stream_type_t stream, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_policy_output_flags_t flags, + audio_devices_t device); virtual uint32_t getMaxEffectsCpuLoad(); virtual uint32_t getMaxEffectsMemory(); @@ -431,7 +450,11 @@ protected: uint32_t samplingRate, uint32_t format, uint32_t channelMask); - + audio_module_handle_t getModuleForDirectoutput(audio_devices_t device, + uint32_t samplingRate, + uint32_t format, + uint32_t channelMask, + audio_policy_output_flags_t flags); // // Audio policy configuration file parsing (audio_policy.conf) // @@ -444,8 +467,8 @@ protected: void loadFormats(char *name, IOProfile *profile); void loadOutChannels(char *name, IOProfile *profile); void loadInChannels(char *name, IOProfile *profile); - status_t loadOutput(cnode *root, const char *module); - status_t loadInput(cnode *root, const char *module); + status_t loadOutput(cnode *root, HwModule *module); + status_t loadInput(cnode *root, HwModule *module); void loadHwModule(cnode *root); void loadHwModules(cnode *root); void loadGlobalConfig(cnode *root); @@ -481,6 +504,7 @@ protected: audio_devices_t mDefaultOutputDevice; // output device selected by default at boot time // (must be in mAttachedOutputDevices) + Vector <HwModule *> mHwModules; Vector <IOProfile *> mOutputProfiles; // output profiles loaded from audio_policy.conf Vector <IOProfile *> mInputProfiles; // input profiles loaded from audio_policy.conf |