Bug 1316543 - Fix the calculation of VideoSink::mVideoFrameEndTime.
MozReview-Commit-ID: 4p34iXLtQz5
--- 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.