diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index 5792fa129896..d25be066e6bc 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -283,6 +283,7 @@ double MediaDecoder::GetDuration() int64_t MediaDecoder::GetMediaDuration() { + NS_ENSURE_TRUE(GetStateMachine(), -1); return GetStateMachine()->GetDuration(); } @@ -429,6 +430,7 @@ nsresult MediaDecoder::Load(MediaResource* aResource, nsresult MediaDecoder::InitializeStateMachine(MediaDecoder* aCloneDonor) { MOZ_ASSERT(NS_IsMainThread()); + NS_ASSERTION(mDecoderStateMachine, "Cannot initialize null state machine!"); MediaDecoder* cloneDonor = static_cast(aCloneDonor); if (NS_FAILED(mDecoderStateMachine->Init(cloneDonor ? @@ -968,6 +970,7 @@ void MediaDecoder::NotifyPrincipalChanged() void MediaDecoder::NotifyBytesConsumed(int64_t aBytes) { + NS_ENSURE_TRUE(mDecoderStateMachine, ); ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); MOZ_ASSERT(OnStateMachineThread() || mDecoderStateMachine->OnDecodeThread()); if (!mIgnoreProgressData) { @@ -1199,6 +1202,7 @@ void MediaDecoder::SetDuration(double aDuration) void MediaDecoder::SetMediaDuration(int64_t aDuration) { + NS_ENSURE_TRUE(GetStateMachine(), ); GetStateMachine()->SetDuration(aDuration); } @@ -1229,6 +1233,7 @@ bool MediaDecoder::IsTransportSeekable() bool MediaDecoder::IsMediaSeekable() { + NS_ENSURE_TRUE(GetStateMachine(), false); ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); MOZ_ASSERT(OnDecodeThread() || NS_IsMainThread()); return mMediaSeekable; @@ -1265,6 +1270,7 @@ void MediaDecoder::SetFragmentEndTime(double aTime) void MediaDecoder::SetMediaEndTime(int64_t aTime) { + NS_ENSURE_TRUE(GetStateMachine(), ); GetStateMachine()->SetMediaEndTime(aTime); } @@ -1367,6 +1373,7 @@ void MediaDecoder::SetPreservesPitch(bool aPreservesPitch) } bool MediaDecoder::OnDecodeThread() const { + NS_ENSURE_TRUE(mDecoderStateMachine, false); return mDecoderStateMachine->OnDecodeThread(); } @@ -1426,10 +1433,12 @@ MediaDecoderStateMachine* MediaDecoder::GetStateMachine() const { } bool MediaDecoder::IsShutdown() const { + NS_ENSURE_TRUE(GetStateMachine(), true); return GetStateMachine()->IsShutdown(); } int64_t MediaDecoder::GetEndMediaTime() const { + NS_ENSURE_TRUE(GetStateMachine(), -1); return GetStateMachine()->GetEndMediaTime(); } diff --git a/content/media/dash/DASHRepDecoder.cpp b/content/media/dash/DASHRepDecoder.cpp index b913446d7f47..d18a96c55488 100644 --- a/content/media/dash/DASHRepDecoder.cpp +++ b/content/media/dash/DASHRepDecoder.cpp @@ -473,7 +473,14 @@ ReentrantMonitor& DASHRepDecoder::GetReentrantMonitor() { NS_ASSERTION(mMainDecoder, "Can't get monitor if main decoder is null!"); - return mMainDecoder->GetReentrantMonitor(); + if (mMainDecoder) { + return mMainDecoder->GetReentrantMonitor(); + } else { + // XXX If mMainDecoder is gone, most likely we're past shutdown and + // a waiting function has been wakened. Just return this decoder's own + // monitor and let the function complete. + return MediaDecoder::GetReentrantMonitor(); + } } mozilla::layers::ImageContainer*