Fix effect volume cache issue.
1. Cache the requested volume instead of the returned volume from
set volume command. The returned value is the one used to indicate
the volume to all other effects in chain.
2. Cache the volume control effect so that there is not need to set the
volume if the volume control effect is not changed.
Bug: 333015116
Test: atest VisualizerTest LoudnessEnhancerTest
Change-Id: Ifda65e6dd7094ba94a1220c66c3a553bb3c067bd
Merged-In: Ifda65e6dd7094ba94a1220c66c3a553bb3c067bd
(cherry picked from commit 4054df254c8aa3698050b06a51d3ba17a71496e5)
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index 43231ff..5dcf8ea 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -1388,9 +1388,9 @@
&size,
pVolume);
if (controller && status == NO_ERROR && size == sizeof(volume)) {
+ mVolume = {*left, *right}; // Cache the value that has been set
*left = volume[0];
*right = volume[1];
- mVolume = {*left, *right};
}
return status;
}
@@ -2625,6 +2625,7 @@
}
return volumeControlIndex.has_value();
}
+ mVolumeControlEffect = volumeControlEffect;
for (int i = 0; i < ctrlIdx; ++i) {
// For all volume control effects before the effect that controls volume, set the volume