Sometimes no audio output after playing some clips using Files.apk

Sometimes after switching songs in Files, audio driver
enters "PAUSED" state, and no sound anymore.

In normal case, "paused" track will be removed from active tracks,
then audio hal will make this stream enter standby mode.

Actually there are two paths to move paused tracks into standby mode:
1> track underruns twice:
    if (--(track->mRetryCount) <= 0) {  // mRetryCount is 2
        tracksToRemove->add(track);
    } else {
        doHwPause = true;   // pause
    }
Unfortunately, this issue happened exactly in the middle state:
track underrun for the first time, it enters to paused state;
then before it underrun for second time, it is stopped due to MediaPlayer.

2> track is paused and code goes here:
    if (mStandby || !last ||
            track->presentationComplete(framesWritten, audioHALFrames) ||
            track->isPaused() ||
+           track->isStopped()) {
        tracksToRemove->add(track);
    }
But when the issue happens, track is in stopped state,
there is no logic to standby it anymore, so add one.

Change-Id: I70cac1f3d6b065690400f6a2363712d4642a9763
gugelfrei
Jindong 5 years ago committed by fang hui
parent 429f364cc4
commit 32dc26e71c

@ -5733,7 +5733,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
int64_t framesWritten = mBytesWritten / mFrameSize;
if (mStandby || !last ||
track->presentationComplete(framesWritten, audioHALFrames) ||
track->isPaused()) {
track->isPaused() || mHwPaused) {
if (track->isStopping_2()) {
track->mState = TrackBase::STOPPED;
}

Loading…
Cancel
Save