From 0f0631eb55b1f0a7f4b62212b78a3faa0b49919b Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 6 Jul 2015 18:01:25 -0700 Subject: 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 43b4dcc 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 --- services/audioflinger/Threads.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'services/audioflinger/Threads.cpp') diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index d3ea9d8..966fb5c 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -4482,9 +4482,16 @@ void AudioFlinger::DirectOutputThread::onAddNewTrack_l() sp previousTrack = mPreviousTrack.promote(); sp latestTrack = mLatestActiveTrack.promote(); - if (previousTrack != 0 && latestTrack != 0 && - (previousTrack->sessionId() != latestTrack->sessionId())) { - mFlushPending = true; + 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,12 +4584,8 @@ 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()) { - previousTrack->invalidate(); - } + // Invalidate previous track to force a seek when resuming. + previousTrack->invalidate(); } } mPreviousTrack = track; -- cgit v1.1