Bug 1316543 - Fix the calculation of VideoSink::mVideoFrameEndTime. r=cpearce, a=gchang
authorJW Wang <jwwang@mozilla.com>
Thu, 10 Nov 2016 17:12:01 +0800
changeset 358841 b26076fe5428e23672ce1e73257b6ca1b9e78bc7
parent 358840 8117e133c5884b8f1bb2c2786db7b112f3e8260a
child 358842 541e88dd973c25c137eaff8b92f516bd5c0f3832
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, gchang
bugs1316543
milestone51.0
Bug 1316543 - Fix the calculation of VideoSink::mVideoFrameEndTime. r=cpearce, a=gchang MozReview-Commit-ID: 4p34iXLtQz5
dom/media/mediasink/VideoSink.cpp
--- a/dom/media/mediasink/VideoSink.cpp
+++ b/dom/media/mediasink/VideoSink.cpp
@@ -405,36 +405,36 @@ VideoSink::UpdateRenderedVideoFrames()
   MOZ_ASSERT(mAudioSink->IsPlaying(), "should be called while playing.");
 
   // Get the current playback position.
   TimeStamp nowTime;
   const int64_t clockTime = mAudioSink->GetPosition(&nowTime);
   NS_ASSERTION(clockTime >= 0, "Should have positive clock time.");
 
   // Skip frames up to the playback position.
-  int64_t lastDisplayedFrameEndTime = 0;
+  int64_t lastFrameEndTime = 0;
   while (VideoQueue().GetSize() > mMinVideoQueueSize &&
          clockTime >= VideoQueue().PeekFront()->GetEndTime()) {
     RefPtr<MediaData> frame = VideoQueue().PopFront();
+    lastFrameEndTime = frame->GetEndTime();
     if (frame->As<VideoData>()->mSentToCompositor) {
-      lastDisplayedFrameEndTime = frame->GetEndTime();
       mFrameStats.NotifyPresentedFrame();
     } else {
       mFrameStats.NotifyDecodedFrames({ 0, 0, 1 });
       VSINK_LOG_V("discarding video frame mTime=%lld clock_time=%lld",
                   frame->mTime, clockTime);
     }
   }
 
   // The presentation end time of the last video frame displayed is either
   // the end time of the current frame, or if we dropped all frames in the
   // queue, the end time of the last frame we removed from the queue.
   RefPtr<MediaData> currentFrame = VideoQueue().PeekFront();
   mVideoFrameEndTime = std::max(mVideoFrameEndTime,
-    currentFrame ? currentFrame->GetEndTime() : lastDisplayedFrameEndTime);
+    currentFrame ? currentFrame->GetEndTime() : lastFrameEndTime);
 
   MaybeResolveEndPromise();
 
   RenderVideoFrames(mVideoQueueSendToCompositorSize, clockTime, nowTime);
 
   // Get the timestamp of the next frame. Schedule the next update at
   // the start time of the next frame. If we don't have a next frame,
   // we will run render loops again upon incoming frames.