From 82666af5b11a610b3c47377654fbd98447cdaa1a Mon Sep 17 00:00:00 2001 From: Alastor Wu Date: Mon, 15 Dec 2014 09:22:15 +0800 Subject: [PATCH] Bug 1100803 - Re-create a decoded media stream if necessary. r=roc --- dom/media/MediaDecoder.cpp | 8 ++++++++ dom/media/MediaDecoder.h | 3 +++ dom/media/MediaDecoderStateMachine.cpp | 4 +--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index dc25fecf81b1..e42ae7e0acc0 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -266,6 +266,14 @@ MediaDecoder::DecodedStreamGraphListener::NotifyEvent(MediaStreamGraph* aGraph, aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } + +void MediaDecoder::RecreateDecodedStreamIfNecessary(int64_t aStartTimeUSecs) +{ + if (mInitialAudioCaptured) { + RecreateDecodedStream(aStartTimeUSecs); + } +} + void MediaDecoder::DestroyDecodedStream() { MOZ_ASSERT(NS_IsMainThread()); diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index ebfb4a617d04..d61603a4e5df 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -851,6 +851,9 @@ class MediaDecoder : public nsIObserver, // The decoder monitor must be held. bool IsLogicallyPlaying(); + // Re-create a decoded stream if audio being captured + void RecreateDecodedStreamIfNecessary(int64_t aStartTimeUSecs); + #ifdef MOZ_EME // This takes the decoder monitor. virtual nsresult SetCDMProxy(CDMProxy* aProxy) MOZ_OVERRIDE; diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 984c9d85ac26..fc261341e225 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1624,9 +1624,7 @@ MediaDecoderStateMachine::StartSeek(const SeekTarget& aTarget) DECODER_LOG("Changed state to SEEKING (to %lld)", mSeekTarget.mTime); SetState(DECODER_STATE_SEEKING); - if (mDecoder->GetDecodedStream()) { - mDecoder->RecreateDecodedStream(seekTime - mStartTime); - } + mDecoder->RecreateDecodedStreamIfNecessary(seekTime - mStartTime); ScheduleStateMachine(); }