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
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index 19f95e2..7dc5bd0 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;
}
@@ -2628,6 +2628,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