summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-07-22 11:52:13 -0700
committerAndy Hung <hunga@google.com>2015-07-22 11:52:13 -0700
commita8d0890ca969ec40fdcf1cfcbeef85c0c379cfaf (patch)
tree19d4d4ec0342472e24d5e242bf68a33c57ccd1c2 /media/libmedia/AudioTrack.cpp
parent805a0c70574676d0fb29aa5e1f23417786b42259 (diff)
downloadframeworks_av-a8d0890ca969ec40fdcf1cfcbeef85c0c379cfaf.zip
frameworks_av-a8d0890ca969ec40fdcf1cfcbeef85c0c379cfaf.tar.gz
frameworks_av-a8d0890ca969ec40fdcf1cfcbeef85c0c379cfaf.tar.bz2
Fix race condition in AudioTrackThread::wake
Bug: 22533684 Change-Id: I2f46770dca44fc9dae41e067d3bec893c42a826e
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r--media/libmedia/AudioTrack.cpp12
1 files changed, 8 insertions, 4 deletions
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();
+ }
}
}