Bug 1378085 P8 - don't update playback position in video-only seeking; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Tue, 04 Jul 2017 17:35:06 +0800
changeset 603951 065954b2c8b2eef4d3b24315a6c91bfa1d4d80c6
parent 603950 7aae6dc52718e4b64eac0c22c1741316ddda9444
child 603952 3cfcdc7cf57e04a66f4a2ad1b61c1eaa6b7dd32b
push id66912
push userbmo:kaku@mozilla.com
push dateWed, 05 Jul 2017 02:39:22 +0000
reviewersjwwang
bugs1378085
milestone56.0a1
Bug 1378085 P8 - don't update playback position in video-only seeking; r?jwwang MozReview-Commit-ID: JPsZ4L8b3g
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -970,17 +970,17 @@ public:
       mMaster->mOnPlaybackEvent.Notify(MediaEventType::ExitVideoSuspend);
       Reader()->SetVideoBlankDecode(false);
     }
 
     NotifyVideoOnlySeekBegin();
 
     StopPlayback();
 
-    mMaster->UpdatePlaybackPositionInternal(mSeekJob.mTarget->GetTime());
+    UpdatePlaybackPosition(mSeekJob.mTarget->GetTime());
 
     if (aVisibility == EventVisibility::Observable) {
       mMaster->mOnPlaybackEvent.Notify(MediaEventType::SeekStarted);
       // We want dormant actions to be transparent to the user.
       // So we only notify the change when the seek request is from the user.
       mMaster->UpdateNextFrameStatus(
         MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING);
     }
@@ -1021,16 +1021,20 @@ protected:
 
   virtual void NotifyVideoOnlySeekBegin() {}
   virtual void StopPlayback() { mMaster->StopPlayback(); }
   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;
+  virtual void UpdatePlaybackPosition(const TimeUnit& aTime)
+  {
+    mMaster->UpdatePlaybackPositionInternal(aTime);
+  }
 };
 
 class MediaDecoderStateMachine::AccurateSeekingState
   : public MediaDecoderStateMachine::SeekingState
 {
 public:
   explicit AccurateSeekingState(Master* aPtr) : SeekingState(aPtr) { }
 
@@ -1804,16 +1808,19 @@ private:
   // changes.
   void NotifyVideoOnlySeekBegin() override
   {
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekBegin);
   }
 
   // Don't stop playback for a video-only seek since audio is playing.
   void StopPlayback() override { }
+
+  // Don't update the media time since we did not stop the playback.
+  void UpdatePlaybackPosition(const TimeUnit&) override { }
 };
 
 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
@@ -2517,22 +2524,20 @@ SeekingState::SeekCompleted()
 
   // Notify FirstFrameLoaded now if we haven't since we've decoded some data
   // for readyState to transition to HAVE_CURRENT_DATA and fire 'loadeddata'.
   if (!mMaster->mSentFirstFrameLoadedEvent) {
     mMaster->FinishDecodeFirstFrame();
   }
 
   // Ensure timestamps are up to date.
-  if (!target.IsVideoOnly()) {
-    // Don't update playback position for video-only seek.
-    // Otherwise we might have |newCurrentTime > mMediaSink->GetPosition()|
-    // and fail the assertion in GetClock() since we didn't stop MediaSink.
-    mMaster->UpdatePlaybackPositionInternal(newCurrentTime);
-  }
+  // Don't update playback position for video-only seek.
+  // Otherwise we might have |newCurrentTime > mMediaSink->GetPosition()|
+  // and fail the assertion in GetClock() since we didn't stop MediaSink.
+  UpdatePlaybackPosition(newCurrentTime);
 
   // Dispatch an event so that the UI can change in response to the end of
   // video-only seek
   if (target.IsVideoOnly()) {
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
   }
 
   // Try to decode another frame to detect if we're at the end...