From 01abf4455d53578cdcd87b095755c9053f1c42c5 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 24 Mar 2015 20:40:40 -0700 Subject: [PATCH] Bug 1136827 - Call OnAudioSinkError on state machine thread. r=jww --- dom/media/AudioSink.cpp | 3 +-- dom/media/MediaDecoderStateMachine.cpp | 3 ++- dom/media/MediaDecoderStateMachine.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dom/media/AudioSink.cpp b/dom/media/AudioSink.cpp index 1304cbbe7a51..76d9c732571c 100644 --- a/dom/media/AudioSink.cpp +++ b/dom/media/AudioSink.cpp @@ -162,8 +162,7 @@ AudioSink::AudioLoop() if (NS_FAILED(InitializeAudioStream())) { NS_WARNING("Initializing AudioStream failed."); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); - mStateMachine->OnAudioSinkError(); + mStateMachine->DispatchOnAudioSinkError(); return; } diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 5f6f034e49f7..1b10661a1e45 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -3455,7 +3455,8 @@ void MediaDecoderStateMachine::OnAudioSinkComplete() void MediaDecoderStateMachine::OnAudioSinkError() { - AssertCurrentThreadInMonitor(); + MOZ_ASSERT(OnStateMachineThread()); + ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); // AudioSink not used with captured streams, so ignore errors in this case. if (mAudioCaptured) { return; diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index a5af50e265e8..6491e1652fbb 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -718,6 +718,11 @@ protected: // Called by the AudioSink to signal errors. void OnAudioSinkError(); + void DispatchOnAudioSinkError() + { + TaskQueue()->Dispatch(NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkError)); + } + // Return true if the video decoder's decode speed can not catch up the // play time. bool NeedToSkipToNextKeyframe();