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

Commit 3df841a1 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioFlinger: fix offload volume on resume

Make sure that new volume is sent to audio effects and HAL
immediately upon resuming playback on direct and offload threads.

Also make sure that only the latest active track on thread controls
volume.

Bug: 30057465
Change-Id: I846958b4aae5abd3740b8a2545b57bd8f3614031
parent 87cbfa8c
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -4878,11 +4878,14 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
            }
        } else if (track->isResumePending()) {
            track->resumeAck();
            if (last && mHwPaused) {
            if (last) {
                mLeftVolFloat = mRightVolFloat = -1.0;
                if (mHwPaused) {
                    doHwResume = true;
                    mHwPaused = false;
                }
            }
        }

        // The first time a track is added we wait
        // for all its buffers to be filled before processing it.
@@ -4906,8 +4909,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep

            if (track->mFillingUpStatus == Track::FS_FILLED) {
                track->mFillingUpStatus = Track::FS_ACTIVE;
                if (last) {
                    // make sure processVolume_l() will apply new volume even if 0
                    mLeftVolFloat = mRightVolFloat = -1.0;
                }
                if (!mHwSupportsPause) {
                    track->resumeAck();
                }
@@ -5460,6 +5465,8 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr
                // enable write to audio HAL
                mSleepTimeUs = 0;

                mLeftVolFloat = mRightVolFloat = -1.0;

                // Do not handle new data in this iteration even if track->framesReady()
                mixerStatus = MIXER_TRACKS_ENABLED;
            }
@@ -5468,9 +5475,11 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr
            ALOGVV("OffloadThread: track %d s=%08x [OK]", track->name(), cblk->mServer);
            if (track->mFillingUpStatus == Track::FS_FILLED) {
                track->mFillingUpStatus = Track::FS_ACTIVE;
                if (last) {
                    // make sure processVolume_l() will apply new volume even if 0
                    mLeftVolFloat = mRightVolFloat = -1.0;
                }
            }

            if (last) {
                sp<Track> previousTrack = mPreviousTrack.promote();