summaryrefslogtreecommitdiffstats
path: root/services/audioflinger
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-11-12 19:25:43 -0800
committerEric Laurent <elaurent@google.com>2013-11-12 19:32:36 -0800
commit9da3d9573a18ffe08365557c706cf52f09118d1c (patch)
treec30511f753f1b49d5519ba5249316b12f33bb29a /services/audioflinger
parent1b9f9b134e732a48198e51f16424f330cbf03143 (diff)
downloadframeworks_av-9da3d9573a18ffe08365557c706cf52f09118d1c.zip
frameworks_av-9da3d9573a18ffe08365557c706cf52f09118d1c.tar.gz
frameworks_av-9da3d9573a18ffe08365557c706cf52f09118d1c.tar.bz2
audioflinger: fix offload track transition
Make sure that when transitioning from one active offloaded track to the next we flush DSP content if both tracks are not on the same audio session. This happens when switching between two applications playing the same type of content (e.g MP3, stereo, 44.1). In this case, we reuse the same output thread because the track formats are compatible. Bug: 11247103. Change-Id: I2b9031591149adeb70766da5e0d21ff2933a37e8
Diffstat (limited to 'services/audioflinger')
-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;