Index: content/renderer/media/webmediaplayer_ms_compositor.cc |
diff --git a/content/renderer/media/webmediaplayer_ms_compositor.cc b/content/renderer/media/webmediaplayer_ms_compositor.cc |
index 7bd992de607e8b0921affac52f3cc1a0716db05c..6448c0ea3b1530672d7586250b198cadc6e54e7b 100644 |
--- a/content/renderer/media/webmediaplayer_ms_compositor.cc |
+++ b/content/renderer/media/webmediaplayer_ms_compositor.cc |
@@ -185,6 +185,7 @@ void WebMediaPlayerMSCompositor::EnqueueFrame( |
base::AutoLock auto_lock(current_frame_lock_); |
++total_frame_count_; |
+ // With algorithm off, just let |current_frame_| hold the incoming |frame|. |
if (!rendering_frame_buffer_) { |
SetCurrentFrame(frame); |
return; |
@@ -200,6 +201,9 @@ void WebMediaPlayerMSCompositor::EnqueueFrame( |
return; |
} |
+ // If we detect a bad frame without |render_time|, we switch off algorithm, |
+ // because without |render_time|, algorithm cannot work. |
+ // In general, this should not happen. |
base::TimeTicks render_time; |
if (!frame->metadata()->GetTimeTicks( |
media::VideoFrameMetadata::REFERENCE_TIME, &render_time)) { |
@@ -211,20 +215,19 @@ void WebMediaPlayerMSCompositor::EnqueueFrame( |
return; |
} |
- timestamps_to_clock_times_[frame->timestamp()] = render_time; |
- |
- rendering_frame_buffer_->EnqueueFrame(frame); |
- |
+ // This block considers the case that vsyncs stops rendering frames. |
DaleCurtis
2016/03/09 21:54:01
"The code below handles the case where UpdateCurre
qiangchen
2016/03/09 22:46:40
Done.
|
+ // A probable cause is that the tab is inactive. |
+ // Nevertheless we still have to let old frames go. |
const base::TimeTicks now = base::TimeTicks::Now(); |
- if (now <= last_deadline_max_) |
- return; |
- |
- // This shows vsyncs stops rendering frames. A probable cause is that the |
- // tab is not in the front. But we still have to let old frames go. |
- const base::TimeTicks deadline_max = |
- std::max(now, last_deadline_max_ + last_render_length_); |
+ if (now > last_deadline_max_ && current_frame_) { |
+ dropped_frame_count_ += rendering_frame_buffer_->frames_queued() - 1; |
DaleCurtis
2016/03/09 21:54:01
Add a comment explaining why the -1.
qiangchen
2016/03/09 22:46:40
Done.
|
+ rendering_frame_buffer_->Reset(); |
+ timestamps_to_clock_times_.clear(); |
+ SetCurrentFrame(frame); |
+ } |
- Render(deadline_max - last_render_length_, deadline_max); |
+ timestamps_to_clock_times_[frame->timestamp()] = render_time; |
+ rendering_frame_buffer_->EnqueueFrame(frame); |
} |
bool WebMediaPlayerMSCompositor::UpdateCurrentFrame( |