summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--services/audioflinger/Threads.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index b8c1632..de408a0 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3984,23 +3984,6 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr
sp<Track> l = mLatestActiveTrack.promote();
bool last = l.get() == track;
- if (mPreviousTrack != NULL) {
- if (track != mPreviousTrack) {
- // Flush any data still being written from last track
- mBytesRemaining = 0;
- if (mPausedBytesRemaining) {
- // Last track was paused so we also need to flush saved
- // mixbuffer state and invalidate track so that it will
- // re-submit that unwritten data when it is next resumed
- mPausedBytesRemaining = 0;
- // Invalidate is a bit drastic - would be more efficient
- // to have a flag to tell client that some of the
- // previously written data was lost
- mPreviousTrack->invalidate();
- }
- }
- }
- mPreviousTrack = track;
if (track->isPausing()) {
track->setPaused();
if (last) {
@@ -4048,6 +4031,30 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr
}
if (last) {
+ if (mPreviousTrack != NULL) {
+ if (track != mPreviousTrack) {
+ // Flush any data still being written from last track
+ mBytesRemaining = 0;
+ if (mPausedBytesRemaining) {
+ // Last track was paused so we also need to flush saved
+ // mixbuffer state and invalidate track so that it will
+ // re-submit that unwritten data when it is next resumed
+ mPausedBytesRemaining = 0;
+ // Invalidate is a bit drastic - would be more efficient
+ // to have a flag to tell client that some of the
+ // previously written data was lost
+ mPreviousTrack->invalidate();
+ }
+ // flush data already sent to the DSP if changing audio session as audio
+ // comes from a different source. Also invalidate previous track to force a
+ // seek when resuming.
+ if (mPreviousTrack->sessionId() != track->sessionId()) {
+ mPreviousTrack->invalidate();
+ mFlushPending = true;
+ }
+ }
+ }
+ mPreviousTrack = track;
// reset retry count
track->mRetryCount = kMaxTrackRetriesOffload;
mActiveTrack = t;