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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 2837303003: Fix the crash due to AudioRendererImpl::audio_clock_ being null (Closed)
Patch Set: Safer fix + rebase Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..24af1fa904b19af0e5882e24aada5a5694f6daa4 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -337,13 +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();
+ // 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();
+ }
audio_clock_.reset();
DaleCurtis 2017/05/17 00:15:52 Instead just delete the CHECK below seems like tha
servolk 2017/05/17 00:23:31 Sure, we can probably do this. But I believe that
servolk 2017/05/17 00:27:12 Done (removed the explicit audio_clock_.reset() he
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698