Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eda0965e authored by jiabin's avatar jiabin
Browse files

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 4054df25)
parent b0b34366
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1387,9 +1387,9 @@ status_t EffectModule::setVolumeInternal(
                                                &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;
}
@@ -2623,6 +2623,7 @@ bool EffectChain::setVolume_l(uint32_t* left, uint32_t* right, bool force) {
        }
        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