Index: media/renderers/audio_renderer_impl.cc |
diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc |
index 25f4ef34d83c294bfddd2ee7543e81672291036f..e1ca2c180019981e552671922c43b00b980ff224 100644 |
--- a/media/renderers/audio_renderer_impl.cc |
+++ b/media/renderers/audio_renderer_impl.cc |
@@ -337,21 +337,21 @@ void AudioRendererImpl::Initialize(DemuxerStream* stream, |
DCHECK(stream); |
DCHECK_EQ(stream->type(), DemuxerStream::AUDIO); |
DCHECK(!init_cb.is_null()); |
+ |
+ base::AutoLock auto_lock(lock_); |
DCHECK(state_ == kUninitialized || state_ == kFlushed); |
DCHECK(sink_.get()); |
// If we are re-initializing playback (e.g. switching media tracks), stop the |
// sink first. |
if (state_ == kFlushed) { |
- sink_->Stop(); |
- audio_clock_.reset(); |
+ // Release the lock while we are stopping the sink to avoid deadlock if the |
+ // sink needs to wait for the current Render to finish. |
+ auto* sink = sink_.get(); |
+ base::AutoUnlock auto_unlock(lock_); |
+ sink->Stop(); |
} |
- // Trying to track down AudioClock crash, http://crbug.com/674856. |
- // AudioRenderImpl should only be initialized once to avoid destroying |
- // AudioClock while the audio thread is still using it. |
- CHECK_EQ(audio_clock_.get(), nullptr); |
- |
state_ = kInitializing; |
client_ = client; |