Bug 1374189 - Call NotifyPresentedFrame when resolve the mEndPromiseHolder promise. r=jwwang
MozReview-Commit-ID: Le4VER7kK2Y
--- a/dom/media/mediasink/VideoSink.cpp
+++ b/dom/media/mediasink/VideoSink.cpp
@@ -454,22 +454,22 @@ VideoSink::UpdateRenderedVideoFrames()
// 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<VideoData> currentFrame = VideoQueue().PeekFront();
mVideoFrameEndTime = std::max(mVideoFrameEndTime,
currentFrame ? currentFrame->GetEndTime() : lastFrameEndTime);
- MaybeResolveEndPromise();
-
RenderVideoFrames(
mVideoQueueSendToCompositorSize,
clockTime.ToMicroseconds(), nowTime);
+ MaybeResolveEndPromise();
+
// 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.
nsTArray<RefPtr<VideoData>> frames;
VideoQueue().GetFirstElements(2, &frames);
if (frames.Length() < 2) {
return;
}
@@ -491,16 +491,21 @@ VideoSink::UpdateRenderedVideoFrames()
void
VideoSink::MaybeResolveEndPromise()
{
AssertOwnerThread();
// All frames are rendered, Let's resolve the promise.
if (VideoQueue().IsFinished() &&
VideoQueue().GetSize() <= 1 &&
!mVideoSinkEndRequest.Exists()) {
+ if (VideoQueue().GetSize() == 1) {
+ // Remove the last frame since we have sent it to compositor.
+ RefPtr<VideoData> frame = VideoQueue().PopFront();
+ mFrameStats.NotifyPresentedFrame();
+ }
mEndPromiseHolder.ResolveIfExists(true, __func__);
}
}
nsCString
VideoSink::GetDebugInfo()
{
AssertOwnerThread();