Bug 1367701 P1 - add a virtual Transit() method and remove SeekJob:mTransition; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Thu, 25 May 2017 15:09:10 +0800
changeset 360791 b504b337357238d3b2f59a014bdced1866087e2e
parent 360790 653150c581ff7f954f2f766ef2171b3e21415b1a
child 360792 c057839d5db2c71b42efdfb67cb838a07585e64f
push id31902
push userryanvm@gmail.com
push dateFri, 26 May 2017 19:43:26 +0000
treeherdermozilla-central@ba1a33add29d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1367701
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367701 P1 - add a virtual Transit() method and remove SeekJob:mTransition; r=jwwang MozReview-Commit-ID: L0HnYfTdL57
dom/media/MediaDecoderStateMachine.cpp
dom/media/SeekJob.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1020,16 +1020,18 @@ public:
     // We set mVideoDecodeSuspended to false in Enter().
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
 protected:
   SeekJob mSeekJob;
 
   virtual void DoSeek() = 0;
+  // Transition to the next state (defined by the subclass) when seek is completed.
+  virtual void GoToNextState() { SetState<DecodingState>(); }
   void SeekCompleted();
   virtual TimeUnit CalculateNewCurrentTime() const = 0;
 };
 
 class MediaDecoderStateMachine::AccurateSeekingState
   : public MediaDecoderStateMachine::SeekingState
 {
 public:
@@ -1728,22 +1730,18 @@ public:
   {
   }
 
   RefPtr<MediaDecoder::SeekPromise> Enter(SeekJob&& aCurrentSeekJob,
                                           SeekJob&& aFutureSeekJob)
   {
     mFutureSeekJob = Move(aFutureSeekJob);
 
-    SeekJob seekJob(Move(aCurrentSeekJob));
-    // Ensure that we don't transition to DecodingState once this seek
-    // completes.
-    seekJob.mTransition = false;
-
-    AccurateSeekingState::Enter(Move(seekJob), EventVisibility::Suppressed)
+    AccurateSeekingState::Enter(Move(aCurrentSeekJob),
+                                EventVisibility::Suppressed)
       ->Then(OwnerThread(),
              __func__,
              [this]() {
                mAccurateSeekRequest.Complete();
                SetState<NextFrameSeekingState>(Move(mFutureSeekJob),
                                                EventVisibility::Observable);
              },
              [this]() { mAccurateSeekRequest.Complete(); })
@@ -1756,16 +1754,19 @@ public:
     mAccurateSeekRequest.DisconnectIfExists();
     mFutureSeekJob.RejectIfExists(__func__);
     AccurateSeekingState::Exit();
   }
 
 private:
   MozPromiseRequestHolder<MediaDecoder::SeekPromise> mAccurateSeekRequest;
   SeekJob mFutureSeekJob;
+
+  // We don't want to transition to DecodingState once this seek completes.
+  void GoToNextState() override { // No transition after seek completed. }
 };
 
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget)
 {
   if (aTarget.IsNextFrame()) {
     // NextFrameSeekingState doesn't reset the decoder unlike
     // AccurateSeekingState. So we first must come out of dormant by seeking to
@@ -2530,19 +2531,17 @@ SeekingState::SeekCompleted()
   SLOG("Seek completed, mCurrentPosition=%" PRId64,
        mMaster->mCurrentPosition.Ref().ToMicroseconds());
 
   if (mMaster->VideoQueue().PeekFront()) {
     mMaster->mMediaSink->Redraw(Info().mVideo);
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
   }
 
-  if (mSeekJob.mTransition) {
-    SetState<DecodingState>();
-  }
+  GoToNextState();
 }
 
 void
 MediaDecoderStateMachine::
 BufferingState::DispatchDecodeTasksIfNeeded()
 {
   if (mMaster->IsAudioDecoding()
       && !mMaster->HaveEnoughDecodedAudio()
--- a/dom/media/SeekJob.h
+++ b/dom/media/SeekJob.h
@@ -22,14 +22,13 @@ struct SeekJob
   ~SeekJob();
 
   bool Exists() const;
   void Resolve(const char* aCallSite);
   void RejectIfExists(const char* aCallSite);
 
   Maybe<SeekTarget> mTarget;
   MozPromiseHolder<MediaDecoder::SeekPromise> mPromise;
-  bool mTransition = true;
 };
 
 } // namespace mozilla
 
 #endif /* SEEK_JOB_H */