Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: media/filters/video_renderer_impl.cc

Issue 475863002: VideoRendererImpl: Delay report of BUFFERING_HAVE_NOTHING. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/video_renderer_impl.cc
diff --git a/media/filters/video_renderer_impl.cc b/media/filters/video_renderer_impl.cc
index 73419c677dff2952c1718678fc66d079bd262de2..25099ca0f84a7a06a6761af150cc01c17f022b4d 100644
--- a/media/filters/video_renderer_impl.cc
+++ b/media/filters/video_renderer_impl.cc
@@ -39,6 +39,7 @@ VideoRendererImpl::VideoRendererImpl(
buffering_state_(BUFFERING_HAVE_NOTHING),
paint_cb_(paint_cb),
last_timestamp_(kNoTimestamp()),
+ last_painted_timestamp_(kNoTimestamp()),
frames_decoded_(0),
frames_dropped_(0),
is_shutting_down_(false),
@@ -184,6 +185,11 @@ void VideoRendererImpl::ThreadMain() {
const base::TimeDelta kIdleTimeDelta =
base::TimeDelta::FromMilliseconds(10);
+ // If we have no frames and haven't painted any frame for certain amount of
+ // time, declare BUFFERING_HAVE_NOTHING.
+ const base::TimeDelta kTimeToDeclareHaveNothing =
+ base::TimeDelta::FromSeconds(3);
+
for (;;) {
base::AutoLock auto_lock(lock_);
@@ -197,6 +203,8 @@ void VideoRendererImpl::ThreadMain() {
continue;
}
+ base::TimeDelta now = get_time_cb_.Run();
scherkus (not reviewing) 2014/08/22 01:40:59 did we mean to use *media* time instead of wall cl
+
// Remain idle until we have the next frame ready for rendering.
if (ready_frames_.empty()) {
if (received_end_of_stream_) {
@@ -204,7 +212,8 @@ void VideoRendererImpl::ThreadMain() {
rendered_end_of_stream_ = true;
task_runner_->PostTask(FROM_HERE, ended_cb_);
}
- } else {
+ } else if (last_painted_timestamp_ != kNoTimestamp() &&
+ now - last_painted_timestamp_ >= kTimeToDeclareHaveNothing) {
buffering_state_ = BUFFERING_HAVE_NOTHING;
task_runner_->PostTask(
FROM_HERE, base::Bind(buffering_state_cb_, BUFFERING_HAVE_NOTHING));
@@ -214,7 +223,6 @@ void VideoRendererImpl::ThreadMain() {
continue;
}
- base::TimeDelta now = get_time_cb_.Run();
base::TimeDelta target_paint_timestamp = ready_frames_.front()->timestamp();
base::TimeDelta latest_paint_timestamp;
@@ -258,6 +266,7 @@ void VideoRendererImpl::PaintNextReadyFrame_Locked() {
frames_decoded_++;
last_timestamp_ = next_frame->timestamp();
+ last_painted_timestamp_ = next_frame->timestamp();
paint_cb_.Run(next_frame);
@@ -443,6 +452,7 @@ void VideoRendererImpl::OnVideoFrameStreamResetDone() {
state_ = kFlushed;
last_timestamp_ = kNoTimestamp();
+ last_painted_timestamp_ = kNoTimestamp();
base::ResetAndReturn(&flush_cb_).Run();
}

Powered by Google App Engine
This is Rietveld 408576698