summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-10-16 15:12:32 -0700
committerEric Laurent <elaurent@google.com>2013-10-16 15:12:32 -0700
commitcc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0 (patch)
treea446f08a1adaf31ef5dddc491c620209176b67aa /media/libmedia/AudioTrack.cpp
parent014e7fa2e90827d911c37bb0ce4d2e10e14d0bb3 (diff)
downloadframeworks_av-cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0.zip
frameworks_av-cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0.tar.gz
frameworks_av-cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0.tar.bz2
AudioTrack: fix head position after restore
The head position transfered to the new track by restoreTrack_l() must take into account the frames that are dropped from the old track to avoid a non recoverable offset in the playback head position returned to applications. Bug: 11230062. Change-Id: I51143a08b95e8f264ed709ae2054360315f2b8b1
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r--media/libmedia/AudioTrack.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 37d50cf..507f9bc 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1662,7 +1662,9 @@ status_t AudioTrack::restoreTrack_l(const char *from)
// if the new IAudioTrack is created, createTrack_l() will modify the
// following member variables: mAudioTrack, mCblkMemory and mCblk.
// It will also delete the strong references on previous IAudioTrack and IMemory
- size_t position = mProxy->getPosition();
+
+ // take the frames that will be lost by track recreation into account in saved position
+ size_t position = mProxy->getPosition() + mProxy->getFramesFilled();
mNewPosition = position + mUpdatePeriod;
size_t bufferPosition = mStaticProxy != NULL ? mStaticProxy->getBufferPosition() : 0;
result = createTrack_l(mStreamType,