diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index a034ae78ec64..6e752c01e897 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -2491,9 +2491,10 @@ MediaDecoderStateMachine::ShutdownReader() } void -MediaDecoderStateMachine::FinishShutdown() +MediaDecoderStateMachine::FinishShutdown(bool aSuccess) { MOZ_ASSERT(OnStateMachineThread()); + MOZ_ASSERT(aSuccess); ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); // The reader's listeners hold references to the state machine, diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 1592ab8266ae..32ca577cdc45 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -163,7 +163,7 @@ public: void SetDormant(bool aDormant); void Shutdown(); void ShutdownReader(); - void FinishShutdown(); + void FinishShutdown(bool aSuccess); // Called from the main thread to get the duration. The decoder monitor // must be obtained before calling this. It is in units of microseconds. diff --git a/dom/media/MediaPromise.h b/dom/media/MediaPromise.h index 02934d6dd20e..8578c97190ac 100644 --- a/dom/media/MediaPromise.h +++ b/dom/media/MediaPromise.h @@ -155,23 +155,6 @@ protected: const char* mCallSite; }; - /* - * We create two specializations for invoking Resolve/Reject Methods so as to - * make the resolve/reject value argument "optional" via SFINAE. - */ - - template - static void InvokeCallbackMethod(ThisType* aThisVal, void(ThisType::*aMethod)(ValueType), ValueType aValue) - { - ((*aThisVal).*aMethod)(aValue); - } - - template - static void InvokeCallbackMethod(ThisType* aThisVal, void(ThisType::*aMethod)(), ValueType aValue) - { - ((*aThisVal).*aMethod)(); - } - template class ThenValue : public ThenValueBase @@ -204,12 +187,12 @@ protected: protected: virtual void DoResolve(ResolveValueType aResolveValue) { - InvokeCallbackMethod(mThisVal.get(), mResolveMethod, aResolveValue); + ((*mThisVal).*mResolveMethod)(aResolveValue); } virtual void DoReject(RejectValueType aRejectValue) { - InvokeCallbackMethod(mThisVal.get(), mRejectMethod, aRejectValue); + ((*mThisVal).*mRejectMethod)(aRejectValue); } virtual ~ThenValue() {} diff --git a/dom/media/mediasource/MediaSourceReader.cpp b/dom/media/mediasource/MediaSourceReader.cpp index f52dbdf1afec..c4ae0cc40455 100644 --- a/dom/media/mediasource/MediaSourceReader.cpp +++ b/dom/media/mediasource/MediaSourceReader.cpp @@ -299,13 +299,14 @@ MediaSourceReader::Shutdown() MOZ_ASSERT(mMediaSourceShutdownPromise.IsEmpty()); nsRefPtr p = mMediaSourceShutdownPromise.Ensure(__func__); - ContinueShutdown(); + ContinueShutdown(true); return p; } void -MediaSourceReader::ContinueShutdown() +MediaSourceReader::ContinueShutdown(bool aSuccess) { + MOZ_ASSERT(aSuccess); if (mTrackBuffers.Length()) { mTrackBuffers[0]->Shutdown()->Then(GetTaskQueue(), __func__, this, &MediaSourceReader::ContinueShutdown, diff --git a/dom/media/mediasource/MediaSourceReader.h b/dom/media/mediasource/MediaSourceReader.h index cf0eb6e02bd2..f9020d1f6246 100644 --- a/dom/media/mediasource/MediaSourceReader.h +++ b/dom/media/mediasource/MediaSourceReader.h @@ -180,7 +180,7 @@ private: bool mHasEssentialTrackBuffers; - void ContinueShutdown(); + void ContinueShutdown(bool aSuccess); MediaPromiseHolder mMediaSourceShutdownPromise; #ifdef MOZ_FMP4 nsRefPtr mSharedDecoderManager; diff --git a/dom/media/mediasource/TrackBuffer.cpp b/dom/media/mediasource/TrackBuffer.cpp index 793da5a2e2de..d16c0b059a90 100644 --- a/dom/media/mediasource/TrackBuffer.cpp +++ b/dom/media/mediasource/TrackBuffer.cpp @@ -112,8 +112,9 @@ TrackBuffer::Shutdown() } void -TrackBuffer::ContinueShutdown() +TrackBuffer::ContinueShutdown(bool aSuccess) { + MOZ_ASSERT(aSuccess); ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor()); if (mDecoders.Length()) { mDecoders[0]->GetReader()->Shutdown() diff --git a/dom/media/mediasource/TrackBuffer.h b/dom/media/mediasource/TrackBuffer.h index 79e2930ece68..ef2ee18dd942 100644 --- a/dom/media/mediasource/TrackBuffer.h +++ b/dom/media/mediasource/TrackBuffer.h @@ -160,7 +160,7 @@ private: // Protected by mParentDecoder's monitor. MediaInfo mInfo; - void ContinueShutdown(); + void ContinueShutdown(bool aSuccess); MediaPromiseHolder mShutdownPromise; };