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

Commit 5cff4036 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio flinger: pause direct output when underrunning

If a direct output supports pause, pause the stream
instead of placing it into standby when the audio track
underruns. This will avoid resetting the presented frame count
and preserve A/V sync.

Bug: 21437855.

Change-Id: I598346edb62a1864126acdb1d9a937c82eac2191
parent 4a95e694
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -4443,7 +4443,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
                track->mRetryCount = kMaxTrackRetriesDirect;
                mActiveTrack = t;
                mixerStatus = MIXER_TRACKS_READY;
                if (usesHwAvSync() && mHwPaused) {
                if (mHwPaused) {
                    doHwResume = true;
                    mHwPaused = false;
                }
@@ -4495,7 +4495,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
                    android_atomic_or(CBLK_DISABLED, &cblk->mFlags);
                } else if (last) {
                    mixerStatus = MIXER_TRACKS_ENABLED;
                    if (usesHwAvSync() && !mHwPaused && !mStandby) {
                    if (mHwSupportsPause && !mHwPaused && !mStandby) {
                        doHwPause = true;
                        mHwPaused = true;
                    }
@@ -4609,7 +4609,7 @@ bool AudioFlinger::DirectOutputThread::shouldStandby_l()
                           mTracks[mTracks.size() - 1]->mState == TrackBase::IDLE;
    }

    return !mStandby && !(trackPaused || (usesHwAvSync() && mHwPaused && !trackStopped));
    return !mStandby && !(trackPaused || (mHwPaused && !trackStopped));
}

// getTrackName_l() must be called with ThreadBase::mLock held
@@ -4715,10 +4715,10 @@ void AudioFlinger::DirectOutputThread::cacheParameters_l()
    // no delay on outputs with HW A/V sync
    if (usesHwAvSync()) {
        standbyDelay = 0;
    } else if (audio_is_linear_pcm(mFormat)) {
        standbyDelay = microseconds(activeSleepTime*2);
    } else {
    } else if ((mType == OFFLOAD) && !audio_is_linear_pcm(mFormat)) {
        standbyDelay = kOffloadStandbyDelayNs;
    } else {
        standbyDelay = microseconds(activeSleepTime*2);
    }
}

@@ -4898,7 +4898,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr
        if (track->isPausing()) {
            track->setPaused();
            if (last) {
                if (!mHwPaused) {
                if (mHwSupportsPause && !mHwPaused) {
                    doHwPause = true;
                    mHwPaused = true;
                }