diff options
author | Diogo Ferreira <defer@cyngn.com> | 2014-11-24 17:33:32 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2014-11-25 23:29:03 +0000 |
commit | 1cd20a0bfb5e409f431850929996941a14ed0ffa (patch) | |
tree | 2522b87ce66a169ac0d61b44eba9a188352c845c | |
parent | 4ff3a171c7aa3a7a5e8007947ebacc9a3fa8f449 (diff) | |
download | android_hardware_libhardware_legacy-stable/cm-11.0-XNG2S.tar.gz android_hardware_libhardware_legacy-stable/cm-11.0-XNG2S.tar.bz2 android_hardware_libhardware_legacy-stable/cm-11.0-XNG2S.zip |
mediatek: Check whether a previous strategy is active using a delay for output-switching casesstable/cm-11.0-XNG3Cstable/cm-11.0-XNG2Scm-11.0
In the mediatek stack the flow for changing between speaker and headset in the FM
application operates via forcing the media strategy to output to the speaker.
The default behavior for the policy on force-use cases is to simply go reassign
devices according to whatever strategy is active. Unfortunately, for the case of
media, and in the specific case of forced routing, the check for streams on the
current strategy simply ignored whether the stream was playing in the recent past.
We previously solved this by ignoring the check for the recent past but this
causes the media stream to be active at all times. This patch changes the behavior
slightly and now we check whether the stream was actually running when evaluating
the creation of new devices for media strategies.
Change-Id: I6b2ca9ce3c3f905c6c29cc31026d6643b0de434e
-rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index 82075cd..bb19830 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -17,9 +17,9 @@ */ #define LOG_TAG "AudioPolicyManagerBase" -#define LOG_NDEBUG 0 +//#define LOG_NDEBUG 0 -#define VERY_VERBOSE_LOGGING +//#define VERY_VERBOSE_LOGGING #ifdef VERY_VERBOSE_LOGGING #define ALOGVV ALOGV #else @@ -2328,7 +2328,11 @@ audio_devices_t AudioPolicyManagerBase::getNewDevice(audio_io_handle_t output, b device = getDeviceForStrategy(STRATEGY_SONIFICATION, fromCache); } else if (outputDesc->isStrategyActive(STRATEGY_SONIFICATION_RESPECTFUL)) { device = getDeviceForStrategy(STRATEGY_SONIFICATION_RESPECTFUL, fromCache); - } else if (outputDesc->isStrategyActive(STRATEGY_MEDIA)) { + } else if (outputDesc->isStrategyActive(STRATEGY_MEDIA) +#ifdef MTK_HARDWARE + || outputDesc->isStrategyActive(STRATEGY_MEDIA, SONIFICATION_HEADSET_MUSIC_DELAY) +#endif + ) { device = getDeviceForStrategy(STRATEGY_MEDIA, fromCache); } else if (outputDesc->isStrategyActive(STRATEGY_DTMF)) { device = getDeviceForStrategy(STRATEGY_DTMF, fromCache); @@ -3471,19 +3475,13 @@ bool AudioPolicyManagerBase::AudioOutputDescriptor::isStreamActive(AudioSystem:: if (mRefCount[stream] != 0) { return true; } -#ifndef MTK_HARDWARE if (inPastMs == 0) { return false; } -#endif if (sysTime == 0) { sysTime = systemTime(); } -#ifdef MTK_HARDWARE - if (ns2ms(sysTime - mStopTime[stream])) { -#else if (ns2ms(sysTime - mStopTime[stream]) < inPastMs) { -#endif return true; } return false; |