From 805a0c70574676d0fb29aa5e1f23417786b42259 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 22 Jul 2015 11:40:26 -0700 Subject: Fix race condition in AudioRecordThread::wake Bug: 22533684 Change-Id: Iba73d633b088dbc84159ed692019da39cc8e2233 --- media/libmedia/AudioRecord.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'media/libmedia/AudioRecord.cpp') 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(); + } } } -- cgit v1.1