Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1183)

Unified Diff: ppapi/shared_impl/ppb_audio_shared.cc

Issue 19678028: PAPI: Fix bug in RunWhileLocked, add support for params (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unlock when joining the audio thread so that we don't deadlock if it makes pepper calls. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/ppb_core_proxy.cc ('k') | ppapi/shared_impl/proxy_lock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/ppb_audio_shared.cc
diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc
index f6d0cac029942b44d91fc56e0715304c481a1693..c52ea555848b9fd2d9f25ce021e0ad3bdfe7aa07 100644
--- a/ppapi/shared_impl/ppb_audio_shared.cc
+++ b/ppapi/shared_impl/ppb_audio_shared.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "media/audio/shared_memory_util.h"
#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/proxy_lock.h"
// Hard coded values from PepperPlatformAudioOutputImpl.
// TODO(dalecurtis): PPAPI shouldn't hard code these values for all clients.
@@ -128,12 +129,20 @@ void PPB_Audio_Shared::StartThread() {
void PPB_Audio_Shared::StopThread() {
#if !defined(OS_NACL)
if (audio_thread_.get()) {
- audio_thread_->Join();
+ // In general, the audio thread should not do Pepper calls, but it might
+ // anyway (for example, our Audio test does CallOnMainThread). If it did
+ // a pepper call which acquires the lock (most of them do), and we try to
+ // shut down the thread and Join it while holding the lock, we would
+ // deadlock. So we give up the lock here so that the thread at least _can_
+ // make Pepper calls without causing deadlock.
+ CallWhileUnlocked(base::Bind(&base::DelegateSimpleThread::Join,
+ base::Unretained(audio_thread_.get())));
audio_thread_.reset();
}
#else
if (thread_active_) {
- int result = thread_functions.thread_join(thread_id_);
+ // See comment above about why we unlock here.
+ int result = CallWhileUnlocked(thread_functions.thread_join, thread_id_);
DCHECK_EQ(0, result);
thread_active_ = false;
}
« no previous file with comments | « ppapi/proxy/ppb_core_proxy.cc ('k') | ppapi/shared_impl/proxy_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698