diff options
author | Glenn Kasten <gkasten@google.com> | 2013-10-16 18:12:55 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-16 18:12:55 -0700 |
commit | abe0948c7b9aa32dceb82cebbfca52beb782754b (patch) | |
tree | a9018d0695d2a0221b8ce5e2dca84eb6bdec92e1 | |
parent | 85b56a702f155cda9b945bcbadaa89e0f9ecc4a8 (diff) | |
parent | b2059ff384eee8ffb70a7ec8fc5570405201c734 (diff) | |
download | frameworks_av-abe0948c7b9aa32dceb82cebbfca52beb782754b.zip frameworks_av-abe0948c7b9aa32dceb82cebbfca52beb782754b.tar.gz frameworks_av-abe0948c7b9aa32dceb82cebbfca52beb782754b.tar.bz2 |
am b2059ff3: am f8f15b05: Merge "Fix race condition in AudioTrack::pause followed by start" into klp-dev
* commit 'b2059ff384eee8ffb70a7ec8fc5570405201c734':
Fix race condition in AudioTrack::pause followed by start
-rw-r--r-- | include/media/AudioTrack.h | 1 | ||||
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 15 |
2 files changed, 9 insertions, 7 deletions
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index f863e35..e5cf896 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -612,6 +612,7 @@ protected: bool mPaused; // whether thread is requested to pause at next loop entry bool mPausedInt; // whether thread internally requests pause nsecs_t mPausedNs; // if mPausedInt then associated timeout, otherwise ignored + bool mIgnoreNextPausedInt; // whether to ignore next mPausedInt request }; // body of AudioTrackThread::threadLoop() diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 643159f..a50ed1f 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1786,7 +1786,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) { } @@ -1803,6 +1804,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); @@ -1837,12 +1842,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() @@ -1854,6 +1854,7 @@ void AudioTrack::AudioTrackThread::pause() void AudioTrack::AudioTrackThread::resume() { AutoMutex _l(mMyLock); + mIgnoreNextPausedInt = true; if (mPaused || mPausedInt) { mPaused = false; mPausedInt = false; |