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

Commit 91b5eb2f authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Merge "MediaPlayer: Permit VolumeShaper operations on gapless playback" into oc-dr1-dev

am: db5beef4

Change-Id: Ifeac95fa06d0160abf2215b84321be4a8823e31b
parents 5c2bdf6a db5beef4
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -2318,6 +2318,33 @@ VolumeShaper::Status MediaPlayerService::AudioOutput::applyVolumeShaper(
            }
        }
    } else {
        // VolumeShapers are not affected when a track moves between players for
        // gapless playback (setNextMediaPlayer).
        // We forward VolumeShaper operations that do not change configuration
        // to the new player so that unducking may occur as expected.
        // Unducking is an idempotent operation, same if applied back-to-back.
        if (configuration->getType() == VolumeShaper::Configuration::TYPE_ID
                && mNextOutput != nullptr) {
            ALOGV("applyVolumeShaper: Attempting to forward missed operation: %s %s",
                    configuration->toString().c_str(), operation->toString().c_str());
            Mutex::Autolock nextLock(mNextOutput->mLock);

            // recycled track should be forwarded from this AudioSink by switchToNextOutput
            sp<AudioTrack> track = mNextOutput->mRecycledTrack;
            if (track != nullptr) {
                ALOGD("Forward VolumeShaper operation to recycled track %p", track.get());
                (void)track->applyVolumeShaper(configuration, operation);
            } else {
                // There is a small chance that the unduck occurs after the next
                // player has already started, but before it is registered to receive
                // the unduck command.
                track = mNextOutput->mTrack;
                if (track != nullptr) {
                    ALOGD("Forward VolumeShaper operation to track %p", track.get());
                    (void)track->applyVolumeShaper(configuration, operation);
                }
            }
        }
        status = mVolumeHandler->applyVolumeShaper(configuration, operation);
    }
    return status;