File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,7 @@ class AudioTrack
481481 bool mMarkerReached ;
482482 uint32_t mNewPosition ;
483483 uint32_t mUpdatePeriod ;
484+ bool mFlushed ; // FIXME will be made obsolete by making flush() synchronous
484485 uint32_t mFlags ;
485486 int mSessionId ;
486487 int mAuxEffectId ;
Original file line number Diff line number Diff line change @@ -259,6 +259,7 @@ status_t AudioTrack::set(
259259 mMarkerReached = false ;
260260 mNewPosition = 0 ;
261261 mUpdatePeriod = 0 ;
262+ mFlushed = false ;
262263 mFlags = flags;
263264 AudioSystem::acquireAudioSessionId (mSessionId );
264265
@@ -337,6 +338,7 @@ void AudioTrack::start()
337338 audio_track_cblk_t * cblk = mCblk ;
338339
339340 if (mActive == 0 ) {
341+ mFlushed = false ;
340342 mActive = 1 ;
341343 mNewPosition = cblk->server + mUpdatePeriod ;
342344 cblk->lock .lock ();
@@ -437,6 +439,7 @@ void AudioTrack::flush_l()
437439 mUpdatePeriod = 0 ;
438440
439441 if (!mActive ) {
442+ mFlushed = true ;
440443 mAudioTrack ->flush ();
441444 // Release AudioTrack callback thread in case it was waiting for new buffers
442445 // in AudioTrack::obtainBuffer()
@@ -655,7 +658,7 @@ status_t AudioTrack::getPosition(uint32_t *position)
655658{
656659 if (position == 0 ) return BAD_VALUE;
657660 AutoMutex lock (mLock );
658- *position = mCblk ->server ;
661+ *position = mFlushed ? 0 : mCblk ->server ;
659662
660663 return NO_ERROR;
661664}
You can’t perform that action at this time.
0 commit comments