diff options
author | Glenn Kasten <gkasten@google.com> | 2013-10-16 18:07:33 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-16 18:07:33 -0700 |
commit | b2059ff384eee8ffb70a7ec8fc5570405201c734 (patch) | |
tree | 24add894e503e19c39d2f2d395df52e488144e6e /media | |
parent | fc24dc1a2e2ba8d74bfadfadb01d12a542828561 (diff) | |
parent | f8f15b05fe051009945c9042a1a9260280e0feb2 (diff) | |
download | frameworks_av-b2059ff384eee8ffb70a7ec8fc5570405201c734.zip frameworks_av-b2059ff384eee8ffb70a7ec8fc5570405201c734.tar.gz frameworks_av-b2059ff384eee8ffb70a7ec8fc5570405201c734.tar.bz2 |
am f8f15b05: Merge "Fix race condition in AudioTrack::pause followed by start" into klp-dev
* commit 'f8f15b05fe051009945c9042a1a9260280e0feb2':
Fix race condition in AudioTrack::pause followed by start
Diffstat (limited to 'media')
-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; |