diff options
author | Andy Hung <hunga@google.com> | 2015-07-22 11:40:26 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-07-22 11:47:00 -0700 |
commit | 805a0c70574676d0fb29aa5e1f23417786b42259 (patch) | |
tree | 71afcbf497eea9c463b060490deaa617cabcde3d | |
parent | 17d0efd17fbb2573adcde8dcbe77726f622817da (diff) | |
download | frameworks_av-805a0c70574676d0fb29aa5e1f23417786b42259.zip frameworks_av-805a0c70574676d0fb29aa5e1f23417786b42259.tar.gz frameworks_av-805a0c70574676d0fb29aa5e1f23417786b42259.tar.bz2 |
Fix race condition in AudioRecordThread::wake
Bug: 22533684
Change-Id: Iba73d633b088dbc84159ed692019da39cc8e2233
-rw-r--r-- | media/libmedia/AudioRecord.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 3868f13..011b31f 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -1235,11 +1235,15 @@ void AudioRecord::AudioRecordThread::resume() void AudioRecord::AudioRecordThread::wake() { AutoMutex _l(mMyLock); - if (!mPaused && mPausedInt && mPausedNs > 0) { - // audio record 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 record is active and internally paused with timeout. + mPausedInt = false; + mMyCond.signal(); + } } } |