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

Commit 0f0631eb authored by Eric Laurent's avatar Eric Laurent
Browse files

audioflinger: flush HAL when transitioning to next direct track

Send flush command to the audio HAL when transtioning to
next track on direct output thread, even if both tracks are in the
same audio session.

Commit 43b4dcc6 to fix issue 21145353 did only flush the HAL if the
audio session was different for the new track because the logic was
copied from the offload thread.

Bug: 22019044.
Change-Id: I89b217580023ed7449a58e9bf3dc068ce7a84487
parent 065f6572
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -4482,10 +4482,17 @@ void AudioFlinger::DirectOutputThread::onAddNewTrack_l()
    sp<Track> previousTrack = mPreviousTrack.promote();
    sp<Track> latestTrack = mLatestActiveTrack.promote();

    if (previousTrack != 0 && latestTrack != 0 &&
        (previousTrack->sessionId() != latestTrack->sessionId())) {
    if (previousTrack != 0 && latestTrack != 0) {
        if (mType == DIRECT) {
            if (previousTrack.get() != latestTrack.get()) {
                mFlushPending = true;
            }
        } else /* mType == OFFLOAD */ {
            if (previousTrack->sessionId() != latestTrack->sessionId()) {
                mFlushPending = true;
            }
        }
    }
    PlaybackThread::onAddNewTrack_l();
}

@@ -4577,14 +4584,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
                    if (track != previousTrack.get()) {
                        // Flush any data still being written from last track
                        mBytesRemaining = 0;
                        // flush data already sent if changing audio session as audio
                        // comes from a different source. Also invalidate previous track to force a
                        // seek when resuming.
                        if (previousTrack->sessionId() != track->sessionId()) {
                        // Invalidate previous track to force a seek when resuming.
                        previousTrack->invalidate();
                    }
                }
                }
                mPreviousTrack = track;

                // reset retry count