Index: content/renderer/media/audio_renderer_impl.cc |
diff --git a/content/renderer/media/audio_renderer_impl.cc b/content/renderer/media/audio_renderer_impl.cc |
index ac6aca0f271b6364f12c111a24386fe27a3274a8..2aaa12f99593476422ae2bd737699c81d4800cdf 100644 |
--- a/content/renderer/media/audio_renderer_impl.cc |
+++ b/content/renderer/media/audio_renderer_impl.cc |
@@ -98,18 +98,28 @@ bool AudioRendererImpl::OnInitialize(int bits_per_channel, |
} |
void AudioRendererImpl::OnStop() { |
- base::AutoLock auto_lock(lock_); |
- if (stopped_) |
- return; |
- stopped_ = true; |
- |
- ChildProcess::current()->io_message_loop()->PostTask( |
- FROM_HERE, |
- NewRunnableMethod(this, &AudioRendererImpl::DestroyTask)); |
+ // Since joining with the audio thread can acquire lock_, we make sure to |
+ // Join() with it not under lock. |
+ base::DelegateSimpleThread* audio_thread = NULL; |
+ base::SyncSocket* socket = NULL; |
+ { |
+ base::AutoLock auto_lock(lock_); |
+ if (stopped_) |
+ return; |
+ stopped_ = true; |
+ DCHECK_EQ(!audio_thread_.get(), !socket_.get()); |
+ if (audio_thread_.get()) { |
+ audio_thread = audio_thread_.get(); |
+ socket = socket_.get(); |
+ } |
+ ChildProcess::current()->io_message_loop()->PostTask( |
+ FROM_HERE, |
+ NewRunnableMethod(this, &AudioRendererImpl::DestroyTask)); |
+ } |
- if (audio_thread_.get()) { |
- socket_->Close(); |
- audio_thread_->Join(); |
+ if (audio_thread) { |
+ CHECK(socket->Close()); |
acolwell GONE FROM CHROMIUM
2011/10/07 15:50:47
Does this need to happen outside of the lock?
Ami GONE FROM CHROMIUM
2011/10/07 16:44:47
Done.
|
+ audio_thread->Join(); |
} |
} |
@@ -455,6 +465,7 @@ void AudioRendererImpl::WillDestroyCurrentMessageLoop() { |
// Our audio thread runs here. We receive requests for more data and send it |
// on this thread. |
void AudioRendererImpl::Run() { |
+ DCHECK_EQ(kLowLatency, latency_type_); |
audio_thread_->SetThreadPriority(base::kThreadPriority_RealtimeAudio); |
int bytes; |