diff options
author | Zach Jang <zachjang@google.com> | 2015-10-27 01:29:23 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-10-27 01:29:23 +0000 |
commit | cda487148602325701ffd7f595ca096a182f380c (patch) | |
tree | a0f68c2e9124f969f42217042a2f37ce036d98e2 /services | |
parent | be6f10c049086453cc53b8e50c5d497bb5b3ae05 (diff) | |
parent | 75c82b50951b21190f710a638c6a26ff7ee6d86d (diff) | |
download | frameworks_av-cda487148602325701ffd7f595ca096a182f380c.zip frameworks_av-cda487148602325701ffd7f595ca096a182f380c.tar.gz frameworks_av-cda487148602325701ffd7f595ca096a182f380c.tar.bz2 |
Merge "Revert "AudioPolicyService: fix race in AudioCommandThread"" into mnc-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/audiopolicy/service/AudioPolicyService.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp index c77cc45..eefff3d 100644 --- a/services/audiopolicy/service/AudioPolicyService.cpp +++ b/services/audiopolicy/service/AudioPolicyService.cpp @@ -577,28 +577,22 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() } } waitTime = INT64_MAX; - // release mLock before releasing strong reference on the service as - // AudioPolicyService destructor calls AudioCommandThread::exit() which - // acquires mLock. - mLock.unlock(); - svc.clear(); - mLock.lock(); } else { waitTime = mAudioCommands[0]->mTime - curTime; break; } } - - // release delayed commands wake lock if the queue is empty - if (mAudioCommands.isEmpty()) { + // release mLock before releasing strong reference on the service as + // AudioPolicyService destructor calls AudioCommandThread::exit() which acquires mLock. + mLock.unlock(); + svc.clear(); + mLock.lock(); + if (!exitPending() && (mAudioCommands.isEmpty() || waitTime != INT64_MAX)) { + // release delayed commands wake lock release_wake_lock(mName.string()); - } - - // At this stage we have either an empty command queue or the first command in the queue - // has a finite delay. So unless we are exiting it is safe to wait. - if (!exitPending()) { ALOGV("AudioCommandThread() going to sleep"); mWaitWorkCV.waitRelative(mLock, waitTime); + ALOGV("AudioCommandThread() waking up"); } } // release delayed commands wake lock before quitting @@ -1009,8 +1003,6 @@ void AudioPolicyService::AudioCommandThread::exit() requestExit(); mWaitWorkCV.signal(); } - // Note that we can call it from the thread loop if all other references have been released - // but it will safely return WOULD_BLOCK in this case requestExitAndWait(); } |