diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index b659751e0285..6c5489320a21 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -791,15 +791,7 @@ public: ResetMDSM(); - // Do the seek. - mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration()) - ->Then(OwnerThread(), __func__, - [this] (const SeekTaskResolveValue& aValue) { - OnSeekTaskResolved(aValue); - }, - [this] (const SeekTaskRejectValue& aValue) { - OnSeekTaskRejected(aValue); - })); + DoSeek(); return mSeekJob.mPromise.Ensure(__func__); } @@ -860,8 +852,10 @@ public: protected: SeekJob mSeekJob; RefPtr mSeekTask; + MozPromiseRequestHolder mSeekTaskRequest; + + void SeekCompleted(); -private: void OnSeekTaskResolved(const SeekTaskResolveValue& aValue) { mSeekTaskRequest.Complete(); @@ -904,13 +898,12 @@ private: mMaster->DecodeError(aValue.mError); } - void SeekCompleted(); - +private: virtual void CreateSeekTask() = 0; virtual void ResetMDSM() = 0; - MozPromiseRequestHolder mSeekTaskRequest; + virtual void DoSeek() = 0; }; class MediaDecoderStateMachine::AccurateSeekingState @@ -944,6 +937,18 @@ private: mMaster->Reset(); } } + + void DoSeek() override + { + mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration()) + ->Then(OwnerThread(), __func__, + [this] (const SeekTaskResolveValue& aValue) { + OnSeekTaskResolved(aValue); + }, + [this] (const SeekTaskRejectValue& aValue) { + OnSeekTaskRejected(aValue); + })); + } }; class MediaDecoderStateMachine::NextFrameSeekingState @@ -974,10 +979,20 @@ private: { // Do nothing. } + + void DoSeek() override + { + mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration()) + ->Then(OwnerThread(), __func__, + [this] (const SeekTaskResolveValue& aValue) { + OnSeekTaskResolved(aValue); + }, + [this] (const SeekTaskRejectValue& aValue) { + OnSeekTaskRejected(aValue); + })); + } }; - - /** * Purpose: stop playback until enough data is decoded to continue playback. *