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

Commit a02a495c authored by Raj Goparaju's avatar Raj Goparaju
Browse files

Ensure smoother transitions during fade in

When fading in, it is possible that a fade out operation is
already in progress. Applying a new volume shaper could
adversly impact  the transition (like sudden volume change)
or could also be ignored (if same operation type).

Prevent and ensure a smoother transition by replacing and
joining any existing fade out volume shaper.

Bug: 307354764
Test: atest -c FadeOutManager FadeConfigurations
Change-Id: If2412af84a2ab0e6090e9743591f8ef951c8952b
parent 8b064457
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -373,6 +373,7 @@ public final class FadeOutManager {
            mFadedPlayers.clear();
        }

        @GuardedBy("mLock")
        void fadeInPlayer(@NonNull AudioPlaybackConfiguration apc,
                @Nullable VolumeShaper.Configuration config) {
            int piid = Integer.valueOf(apc.getPlayerInterfaceId());
@@ -385,10 +386,16 @@ public final class FadeOutManager {
                return;
            }

            VolumeShaper.Operation operation = VolumeShaper.Operation.REVERSE;
            if (config != null) {
                // replace and join the volumeshapers with (possibly) in progress fade out operation
                // for a smoother fade in
                operation = new VolumeShaper.Operation.Builder()
                        .replace(mFadedPlayers.get(piid).getId(), /* join= */ true).build();
            }
            mFadedPlayers.remove(piid);
            if (apc.getPlayerProxy() != null) {
                applyVolumeShaperInternal(apc, piid, config,
                        config != null ? PLAY_CREATE_IF_NEEDED : VolumeShaper.Operation.REVERSE);
                applyVolumeShaperInternal(apc, piid, config, operation);
            } else {
                if (DEBUG) {
                    Slog.v(TAG, "Error fading in player piid:" + piid
@@ -397,6 +404,7 @@ public final class FadeOutManager {
            }
        }

        @GuardedBy("mLock")
        void clear() {
            if (mFadedPlayers.size() > 0) {
                if (DEBUG) {