Bug 1378085 P8 - always dispatch VideoOnlySeekCompleted at VideoOnlySeekingState::Exit(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Tue, 04 Jul 2017 17:49:43 +0800
changeset 604569 16e854a000a6c045fbd2312545689ff2da857023
parent 604568 de9cab5baffa89e400cf8ca37625338b85b48de3
child 604680 18fb3a43f51d5d151a93fa9277e6d672a479b743
push id67123
push userbmo:kaku@mozilla.com
push dateThu, 06 Jul 2017 03:57:15 +0000
reviewersjwwang
bugs1378085
milestone56.0a1
Bug 1378085 P8 - always dispatch VideoOnlySeekCompleted at VideoOnlySeekingState::Exit(); r?jwwang MozReview-Commit-ID: A8PzfUpJjao
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1749,23 +1749,20 @@ public:
     // changes.
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekBegin);
 
     return p.forget();
   }
 
   void Exit() override
   {
-    if (mSeekJob.Exists() &&
-        mSeekJob.mTarget.isSome()) {
-      // We are discarding this video-only seek operation now, and we still need
-      // to dispatch an event so that the UI can change in response to the end
-      // of video-only seek.
-      mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
-    }
+    // We are completing or discarding this video-only seek operation now,
+    // dispatch an event so that the UI can change in response to the end
+    // of video-only seek.
+    mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
 
     AccurateSeekingState::Exit();
   }
 
   void HandleAudioDecoded(AudioData* aAudio) override
   {
     MOZ_ASSERT(mDoneAudioSeeking && !mDoneVideoSeeking,
                "Seek shouldn't be finished");
@@ -2496,21 +2493,20 @@ SeekingState::SeekCompleted()
     mMaster->mVideoCompleted = true;
 
     // There might still be a pending audio request when doing video-only or
     // next-frame seek. Discard it so we won't break the invariants of the
     // COMPLETED state by adding audio samples to a finished queue.
     mMaster->mAudioDataRequest.DisconnectIfExists();
   }
 
-  // Cache mTarget for mSeekJob.Resolve() below will reset it.
-  SeekTarget target = mSeekJob.mTarget.ref();
-
   // We want to resolve the seek request prior finishing the first frame
   // to ensure that the seeked event is fired prior loadeded.
+  // Note: SeekJob.Resolve() resets SeekJob.mTarget. Don't use mSeekJob anymore
+  //       hereafter.
   mSeekJob.Resolve(__func__);
 
   // 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();
   }
 
@@ -2521,22 +2517,16 @@ SeekingState::SeekCompleted()
   // request is from the user.
   if (mVisibility == EventVisibility::Observable) {
     // 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);
   }
 
-  // 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...
   SLOG("Seek completed, mCurrentPosition=%" PRId64,
        mMaster->mCurrentPosition.Ref().ToMicroseconds());
 
   if (mMaster->VideoQueue().PeekFront()) {
     mMaster->mMediaSink->Redraw(Info().mVideo);
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
   }