Bug 1128069: [MSE] P5. Adjust currentTime to end position in MediaDecoder. r?jwwang draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 08 Aug 2016 13:49:51 +1000
changeset 397767 48268c8af35bd3ccd8a209c61d439ccae89a2bd1
parent 397766 2f7e17d48ede2fb7a21a294bc5d58df51f90de2f
child 397768 78ee6cb120cdbc03a5304caf11ccdda8ab04b44c
push id25391
push userbmo:jyavenard@mozilla.com
push dateMon, 08 Aug 2016 09:33:44 +0000
reviewersjwwang
bugs1128069
milestone51.0a1
Bug 1128069: [MSE] P5. Adjust currentTime to end position in MediaDecoder. r?jwwang The duration in the MediaDecoder is the canonical. It has as such a more up to date value than the mirror. Under some circumstances, the MDSM may have reached the end of media playback before the duration mirror had time to update. So perform the currentTime adjustment in the MediaDecoder instead. MozReview-Commit-ID: 1RFr4mT5LpA
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1359,16 +1359,19 @@ MediaDecoder::ChangeState(PlayState aSta
 
 void
 MediaDecoder::UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!IsShutdown());
 
   double currentPosition = static_cast<double>(CurrentPosition()) / static_cast<double>(USECS_PER_S);
+  if (mPlayState == PLAY_STATE_ENDED) {
+    currentPosition = std::max(currentPosition, mDuration);
+  }
   bool logicalPositionChanged = mLogicalPosition != currentPosition;
   mLogicalPosition = currentPosition;
 
   // Invalidate the frame so any video data is displayed.
   // Do this before the timeupdate event so that if that
   // event runs JavaScript that queries the media size, the
   // frame has reflowed and the size updated beforehand.
   Invalidate();