diff options
author | Eric Laurent <elaurent@google.com> | 2010-07-13 05:01:51 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2010-07-20 09:31:47 -0700 |
commit | d2b227e76033d8c44b71d2982028a63436d3fe84 (patch) | |
tree | 42f4a00f4c7a2d55e2593ccc352808dcf5068bbb /include | |
parent | 0df071ad05d1c1dae6b6aaa6122146fa679c7a12 (diff) | |
download | hardware_libhardware_legacy-d2b227e76033d8c44b71d2982028a63436d3fe84.zip hardware_libhardware_legacy-d2b227e76033d8c44b71d2982028a63436d3fe84.tar.gz hardware_libhardware_legacy-d2b227e76033d8c44b71d2982028a63436d3fe84.tar.bz2 |
Audio policy manager changes for audio effects
Added methods for audio effects management by audio policy manager.
- control of total CPU load and memory used by effect engines
- selection of output stream for global effects
- added audio session id in parameter list for startOutput() and stopOutput().
this is not used in default audio policy manager implementation.
Change-Id: I3467e64035387cc5272266b1318a5ed788958374
Diffstat (limited to 'include')
-rw-r--r-- | include/hardware_legacy/AudioPolicyInterface.h | 26 | ||||
-rw-r--r-- | include/hardware_legacy/AudioPolicyManagerBase.h | 53 |
2 files changed, 70 insertions, 9 deletions
diff --git a/include/hardware_legacy/AudioPolicyInterface.h b/include/hardware_legacy/AudioPolicyInterface.h index bd3c4b1..fe0bdec 100644 --- a/include/hardware_legacy/AudioPolicyInterface.h +++ b/include/hardware_legacy/AudioPolicyInterface.h @@ -91,9 +91,13 @@ public: uint32_t channels = 0, AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_INDIRECT) = 0; // indicates to the audio policy manager that the output starts being used by corresponding stream. - virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream) = 0; + virtual status_t startOutput(audio_io_handle_t output, + AudioSystem::stream_type stream, + int session = 0) = 0; // indicates to the audio policy manager that the output stops being used by corresponding stream. - virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream) = 0; + virtual status_t stopOutput(audio_io_handle_t output, + AudioSystem::stream_type stream, + int session = 0) = 0; // releases the output. virtual void releaseOutput(audio_io_handle_t output) = 0; @@ -124,6 +128,18 @@ public: // retreive current volume index for the specified stream virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0; + // return the strategy corresponding to a given stream type + virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; + + // Audio effect management + virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0; + virtual status_t registerEffect(effect_descriptor_t *desc, + audio_io_handle_t output, + uint32_t strategy, + int session, + int id) = 0; + virtual status_t unregisterEffect(int id) = 0; + //dump state virtual status_t dump(int fd) = 0; }; @@ -195,6 +211,12 @@ public: // set down link audio volume. virtual status_t setVoiceVolume(float volume, int delayMs = 0) = 0; + + // move effect to the specified output + virtual status_t moveEffects(int session, + audio_io_handle_t srcOutput, + audio_io_handle_t dstOutput) = 0; + }; extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface); diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h index f7d8ef8..c702d4e 100644 --- a/include/hardware_legacy/AudioPolicyManagerBase.h +++ b/include/hardware_legacy/AudioPolicyManagerBase.h @@ -44,7 +44,7 @@ namespace android { // ---------------------------------------------------------------------------- // AudioPolicyManagerBase implements audio policy manager behavior common to all platforms. // Each platform must implement an AudioPolicyManager class derived from AudioPolicyManagerBase -// and override methods for which the platfrom specific behavior differs from the implementation +// and override methods for which the platform specific behavior differs from the implementation // in AudioPolicyManagerBase. Even if no specific behavior is required, the AudioPolicyManager // class must be implemented as well as the class factory function createAudioPolicyManager() // and provided in a shared library libaudiopolicy.so. @@ -72,12 +72,17 @@ public: virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage); virtual void setSystemProperty(const char* property, const char* value); virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream, - uint32_t samplingRate, - uint32_t format, - uint32_t channels, - AudioSystem::output_flags flags); - virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream); - virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream); + uint32_t samplingRate = 0, + uint32_t format = AudioSystem::FORMAT_DEFAULT, + uint32_t channels = 0, + AudioSystem::output_flags flags = + AudioSystem::OUTPUT_FLAG_INDIRECT); + virtual status_t startOutput(audio_io_handle_t output, + AudioSystem::stream_type stream, + int session = 0); + virtual status_t stopOutput(audio_io_handle_t output, + AudioSystem::stream_type stream, + int session = 0); virtual void releaseOutput(audio_io_handle_t output); virtual audio_io_handle_t getInput(int inputSource, uint32_t samplingRate, @@ -95,6 +100,17 @@ public: virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index); virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index); + // return the strategy corresponding to a given stream type + virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream); + + virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); + virtual status_t registerEffect(effect_descriptor_t *desc, + audio_io_handle_t output, + uint32_t strategy, + int session, + int id); + virtual status_t unregisterEffect(int id); + virtual status_t dump(int fd); protected: @@ -170,6 +186,19 @@ protected: bool mCanBeMuted; // true is the stream can be muted }; + // stream descriptor used for volume control + class EffectDescriptor + { + public: + + status_t dump(int fd); + + int mOutput; // output the effect is attached to + routing_strategy mStrategy; // routing strategy the effect is associated to + int mSession; // audio session the effect is on + effect_descriptor_t mDesc; // effect descriptor + }; + void addOutput(audio_io_handle_t id, AudioOutputDescriptor *outputDesc); // return the strategy corresponding to a given stream type @@ -245,6 +274,8 @@ protected: uint32_t channels, AudioSystem::output_flags flags, uint32_t device); + virtual uint32_t getMaxEffectsCpuLoad(); + virtual uint32_t getMaxEffectsMemory(); #ifdef AUDIO_POLICY_TEST virtual bool threadLoop(); void exit(); @@ -271,6 +302,14 @@ protected: bool mLimitRingtoneVolume; // limit ringtone volume to music volume if headset connected uint32_t mDeviceForStrategy[NUM_STRATEGIES]; + // Maximum CPU load allocated to audio effects in 0.1 MIPS (ARMv5TE, 0 WS memory) units + static const uint32_t MAX_EFFECTS_CPU_LOAD = 1000; + // Maximum memory allocated to audio effects in KB + static const uint32_t MAX_EFFECTS_MEMORY = 512; + uint32_t mTotalEffectsCpuLoad; // current CPU load used by effects + uint32_t mTotalEffectsMemory; // current memory used by effects + KeyedVector<int, EffectDescriptor *> mEffects; // list of registered audio effects + #ifdef AUDIO_POLICY_TEST Mutex mLock; Condition mWaitWorkCV; |