diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2011-08-25 16:47:23 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2011-08-25 17:33:49 -0700 |
commit | cd07594333cbe8b2c86c6609cce01a74d6cc33f8 (patch) | |
tree | 70b1b94cb811f564e8fe0c6ec348469adaae5f3c /media/libmedia | |
parent | 539a735a82fefb1944aa6135df73dfe9f541566c (diff) | |
download | frameworks_av-cd07594333cbe8b2c86c6609cce01a74d6cc33f8.zip frameworks_av-cd07594333cbe8b2c86c6609cce01a74d6cc33f8.tar.gz frameworks_av-cd07594333cbe8b2c86c6609cce01a74d6cc33f8.tar.bz2 |
Bug 4364249 Play position is 0 after flushing AudioTrack
AudioTrack::stop() is not synchronous, so a stop() followed
by flush(), which is synchronous, will not always report
a playhead position of 0 after being called.
This CL adds a flag to mark a track as flushed, and report the
correct playhead position in this state.
Bug 5217011 has been created to address the real issue in the
future, where flush could be made synchronous, to properly
address bug 4364249.
Change-Id: Icf989d41a6bcd5985bb87764c287f3edb7e26d12
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 3949c39..cecedb5 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -259,6 +259,7 @@ status_t AudioTrack::set( mMarkerReached = false; mNewPosition = 0; mUpdatePeriod = 0; + mFlushed = false; mFlags = flags; AudioSystem::acquireAudioSessionId(mSessionId); @@ -337,6 +338,7 @@ void AudioTrack::start() audio_track_cblk_t* cblk = mCblk; if (mActive == 0) { + mFlushed = false; mActive = 1; mNewPosition = cblk->server + mUpdatePeriod; cblk->lock.lock(); @@ -437,6 +439,7 @@ void AudioTrack::flush_l() mUpdatePeriod = 0; if (!mActive) { + mFlushed = true; mAudioTrack->flush(); // Release AudioTrack callback thread in case it was waiting for new buffers // in AudioTrack::obtainBuffer() @@ -655,7 +658,7 @@ status_t AudioTrack::getPosition(uint32_t *position) { if (position == 0) return BAD_VALUE; AutoMutex lock(mLock); - *position = mCblk->server; + *position = mFlushed ? 0 : mCblk->server; return NO_ERROR; } |