From a8d0890ca969ec40fdcf1cfcbeef85c0c379cfaf Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 22 Jul 2015 11:52:13 -0700 Subject: Fix race condition in AudioTrackThread::wake Bug: 22533684 Change-Id: I2f46770dca44fc9dae41e067d3bec893c42a826e --- media/libmedia/AudioTrack.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'media/libmedia/AudioTrack.cpp') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index ab720c6..9b40d45 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -2551,11 +2551,15 @@ void AudioTrack::AudioTrackThread::resume() void AudioTrack::AudioTrackThread::wake() { AutoMutex _l(mMyLock); - if (!mPaused && mPausedInt && mPausedNs > 0) { - // audio track is active and internally paused with timeout. + if (!mPaused) { + // wake() might be called while servicing a callback - ignore the next + // pause time and call processAudioBuffer. mIgnoreNextPausedInt = true; - mPausedInt = false; - mMyCond.signal(); + if (mPausedInt && mPausedNs > 0) { + // audio track is active and internally paused with timeout. + mPausedInt = false; + mMyCond.signal(); + } } } -- cgit v1.1