Reset effect chain volume whenever the volume controller effect stopped
so the correct volume can be apply to the new volume controller
Bug: 347866898
Flag: EXEMPT bugfix
Test: repro steps in b/34786689
Test: atest CtsMediaAudioTestCases
Change-Id: I38187906f74c7cabc564d1aa01426257a0d90ba6
(cherry picked from commit f62fbceee74181ff59727d1bc708bcf41cb95667)
Merged-In: I38187906f74c7cabc564d1aa01426257a0d90ba6
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index d9a9a9c..e85329d 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -617,10 +617,11 @@
}
+// return true if any effect started or stopped
bool EffectModule::updateState_l() {
audio_utils::lock_guard _l(mutex());
- bool started = false;
+ bool startedOrStopped = false;
switch (mState) {
case RESTART:
reset_l();
@@ -635,7 +636,7 @@
}
if (start_ll() == NO_ERROR) {
mState = ACTIVE;
- started = true;
+ startedOrStopped = true;
} else {
mState = IDLE;
}
@@ -655,6 +656,7 @@
// turn off sequence.
if (--mDisableWaitCnt == 0) {
reset_l();
+ startedOrStopped = true;
mState = IDLE;
}
break;
@@ -669,7 +671,7 @@
break;
}
- return started;
+ return startedOrStopped;
}
void EffectModule::process()
@@ -2305,6 +2307,9 @@
}
bool doResetVolume = false;
for (size_t i = 0; i < size; i++) {
+ // reset volume when any effect just started or stopped.
+ // resetVolume_l will check if the volume controller effect in the chain needs update and
+ // apply the correct volume
doResetVolume = mEffects[i]->updateState_l() || doResetVolume;
}
if (doResetVolume) {
@@ -2658,6 +2663,9 @@
true /* effect chain volume controller */);
mNewLeftVolume = newLeft;
mNewRightVolume = newRight;
+ ALOGD("%s sessionId %d volume controller effect %s set (%d, %d), ret (%d, %d)", __func__,
+ mSessionId, mEffects[ctrlIdx]->desc().name, mLeftVolume, mRightVolume, newLeft,
+ newRight);
}
// then indicate volume to all other effects in chain.
// Pass altered volume to effects before volume controller