diff options
author | Haynes Mathew George <hgeorge@codeaurora.org> | 2015-12-14 14:22:07 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-01-12 21:39:34 -0800 |
commit | ce12f66789f52ef7d0e155c9eea51d63653bcda7 (patch) | |
tree | a2322102a05136926f0c810a7240ed2aeda3a88e | |
parent | affe0da38bb71cb28c8efa2544ccb74b94faccf2 (diff) | |
download | hardware_qcom_audio-ce12f66789f52ef7d0e155c9eea51d63653bcda7.tar.gz hardware_qcom_audio-ce12f66789f52ef7d0e155c9eea51d63653bcda7.tar.bz2 hardware_qcom_audio-ce12f66789f52ef7d0e155c9eea51d63653bcda7.zip |
policy: Avoid unnecessary set_parameter calls
APM calls a set_parameter on primary output with key fm_volume
whenever a checkAndSetVolume is called. This is done irrespective
of whether the volume values are same of different.
A side effect of doing so is that the FastMixer associated with
the MixerThread will be put into HOT_IDLE unnecessarily which in turn
can cause glitches/breaks in audio.
CRs-Fixed: 948361
Change-Id: I7fd8b7340e6c78ee6d00b41ccf679582338c011a
-rw-r--r-- | policy_hal/AudioPolicyManager.cpp | 14 | ||||
-rw-r--r-- | policy_hal/AudioPolicyManager.h | 1 |
2 files changed, 11 insertions, 4 deletions
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index 829982c7..52ead1bd 100644 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -1226,9 +1226,14 @@ status_t AudioPolicyManagerCustom::checkAndSetVolume(audio_stream_type_t stream, #ifdef FM_POWER_OPT } else if (stream == AUDIO_STREAM_MUSIC && hasPrimaryOutput() && outputDesc == mPrimaryOutput) { - AudioParameter param = AudioParameter(); - param.addFloat(String8("fm_volume"), Volume::DbToAmpl(volumeDb)); - mpClientInterface->setParameters(mPrimaryOutput->mIoHandle, param.toString(), delayMs); + /* Avoid unnecessary set_parameter calls as it puts the primary + outputs FastMixer in HOT_IDLE leading to breaks in audio */ + if (volumeDb != mPrevFMVolumeDb) { + mPrevFMVolumeDb = volumeDb; + AudioParameter param = AudioParameter(); + param.addFloat(String8("fm_volume"), Volume::DbToAmpl(volumeDb)); + mpClientInterface->setParameters(mPrimaryOutput->mIoHandle, param.toString(), delayMs); + } #endif /* FM_POWER_OPT end */ } @@ -1949,7 +1954,8 @@ AudioPolicyManagerCustom::AudioPolicyManagerCustom(AudioPolicyClientInterface *c : AudioPolicyManager(clientInterface), mHdmiAudioDisabled(false), mHdmiAudioEvent(false), - mPrevPhoneState(0) + mPrevPhoneState(0), + mPrevFMVolumeDb(0.0f) { char ssr_enabled[PROPERTY_VALUE_MAX] = {0}; bool prop_ssr_enabled = false; diff --git a/policy_hal/AudioPolicyManager.h b/policy_hal/AudioPolicyManager.h index f70cfb00..4df5e6ba 100644 --- a/policy_hal/AudioPolicyManager.h +++ b/policy_hal/AudioPolicyManager.h @@ -145,6 +145,7 @@ private: // Used for record + playback concurrency bool mIsInputRequestOnProgress; #endif + float mPrevFMVolumeDb; }; }; |