diff options
author | Glenn Kasten <gkasten@google.com> | 2013-10-17 00:59:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-10-17 00:59:33 +0000 |
commit | f8f15b05fe051009945c9042a1a9260280e0feb2 (patch) | |
tree | 28fd5dede6b2aae34a9b3b987049f3331ace5037 /media/libmedia | |
parent | 787c0d04ac4f9c938a1311f8e30d9d7ac2b8a6da (diff) | |
parent | 598de6c701e989385eeffa7c5dfd61f0459a2631 (diff) | |
download | frameworks_av-f8f15b05fe051009945c9042a1a9260280e0feb2.zip frameworks_av-f8f15b05fe051009945c9042a1a9260280e0feb2.tar.gz frameworks_av-f8f15b05fe051009945c9042a1a9260280e0feb2.tar.bz2 |
Merge "Fix race condition in AudioTrack::pause followed by start" into klp-dev
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 507f9bc..fe5cd9e 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1787,7 +1787,8 @@ void AudioTrack::DeathNotifier::binderDied(const wp<IBinder>& who) // ========================================================================= AudioTrack::AudioTrackThread::AudioTrackThread(AudioTrack& receiver, bool bCanCallJava) - : Thread(bCanCallJava), mReceiver(receiver), mPaused(true), mPausedInt(false), mPausedNs(0LL) + : Thread(bCanCallJava), mReceiver(receiver), mPaused(true), mPausedInt(false), mPausedNs(0LL), + mIgnoreNextPausedInt(false) { } @@ -1804,6 +1805,10 @@ bool AudioTrack::AudioTrackThread::threadLoop() // caller will check for exitPending() return true; } + if (mIgnoreNextPausedInt) { + mIgnoreNextPausedInt = false; + mPausedInt = false; + } if (mPausedInt) { if (mPausedNs > 0) { (void) mMyCond.waitRelative(mMyLock, mPausedNs); @@ -1838,12 +1843,7 @@ void AudioTrack::AudioTrackThread::requestExit() { // must be in this order to avoid a race condition Thread::requestExit(); - AutoMutex _l(mMyLock); - if (mPaused || mPausedInt) { - mPaused = false; - mPausedInt = false; - mMyCond.signal(); - } + resume(); } void AudioTrack::AudioTrackThread::pause() @@ -1855,6 +1855,7 @@ void AudioTrack::AudioTrackThread::pause() void AudioTrack::AudioTrackThread::resume() { AutoMutex _l(mMyLock); + mIgnoreNextPausedInt = true; if (mPaused || mPausedInt) { mPaused = false; mPausedInt = false; |