Bug 1193124 - ensure logical position is updated after seek. r=jwwang. draft
authorJW Wang <jwwang@mozilla.com>
Mon, 18 Apr 2016 18:57:47 +0800
changeset 369978 d4f56df4a2f96e13608103545920563e81a1b732
parent 369967 fd655d59f7df4d0f9ca565dbb5c9af830cf7bb8f
child 369979 4c576ca0ad1371a9deb2273a5b9ae1e39243c8d5
push id18967
push usertkuo@mozilla.com
push dateTue, 24 May 2016 03:08:51 +0000
reviewersjwwang
bugs1193124
milestone49.0a1
Bug 1193124 - ensure logical position is updated after seek. r=jwwang. MozReview-Commit-ID: KD4ylXbaDfu
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1246,17 +1246,18 @@ MediaDecoder::OnSeekResolved(SeekResolve
     UnpinForSeek();
     fireEnded = aVal.mAtEnd;
     if (aVal.mAtEnd) {
       ChangeState(PLAY_STATE_ENDED);
     }
     mLogicallySeeking = false;
   }
 
-  UpdateLogicalPosition(aVal.mEventVisibility);
+  // Ensure logical position is updated after seek.
+  UpdateLogicalPositionInternal(aVal.mEventVisibility);
 
   if (aVal.mEventVisibility != MediaDecoderEventVisibility::Suppressed) {
     mOwner->SeekCompleted();
     if (fireEnded) {
       mOwner->PlaybackEnded();
     }
   }
 }
@@ -1297,24 +1298,20 @@ MediaDecoder::ChangeState(PlayState aSta
   }
 
   CancelDormantTimer();
   // Start dormant timer if necessary
   StartDormantTimer();
 }
 
 void
-MediaDecoder::UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisibility)
+MediaDecoder::UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  if (mShuttingDown)
-    return;
-
-  // Per spec, offical position remains stable during pause and seek.
-  if (mPlayState == PLAY_STATE_PAUSED || IsSeeking()) {
+  if (mShuttingDown) {
     return;
   }
 
   double currentPosition = static_cast<double>(CurrentPosition()) / static_cast<double>(USECS_PER_S);
   bool logicalPositionChanged = mLogicalPosition != currentPosition;
   mLogicalPosition = currentPosition;
 
   // Invalidate the frame so any video data is displayed.
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -406,21 +406,25 @@ private:
     MOZ_ASSERT(NS_IsMainThread());
     mIgnoreProgressData = mLogicallySeeking;
   }
 
   // Seeking has started. Inform the element on the main
   // thread.
   void SeekingStarted(MediaDecoderEventVisibility aEventVisibility = MediaDecoderEventVisibility::Observable);
 
-  void UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisibility);
+  void UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility);
   void UpdateLogicalPosition()
   {
     MOZ_ASSERT(NS_IsMainThread());
-    UpdateLogicalPosition(MediaDecoderEventVisibility::Observable);
+    // Per spec, offical position remains stable during pause and seek.
+    if (mPlayState == PLAY_STATE_PAUSED || IsSeeking()) {
+      return;
+    }
+    UpdateLogicalPositionInternal(MediaDecoderEventVisibility::Observable);
   }
 
   // Find the end of the cached data starting at the current decoder
   // position.
   int64_t GetDownloadPosition();
 
   // Notifies the element that decoding has failed.
   void DecodeError();