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

Unified Diff: media/renderers/video_renderer_impl.cc

Issue 2372863002: Rename VideoRenderer::OnTimeStateChanged to OnTime{Progressing,Stopped} (Closed)
Patch Set: fix some comments Created 4 years, 3 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/renderers/video_renderer_impl.cc
diff --git a/media/renderers/video_renderer_impl.cc b/media/renderers/video_renderer_impl.cc
index c6902976272cad8a0a1d0c3e88d49c994559e292..b8eedb6d682cedc369281fc291cec04a072da7e4 100644
--- a/media/renderers/video_renderer_impl.cc
+++ b/media/renderers/video_renderer_impl.cc
@@ -237,10 +237,8 @@ void VideoRendererImpl::OnVideoFrameStreamInitialized(bool success) {
return;
}
- // We're all good! Consider ourselves flushed. (ThreadMain() should never
- // see us in the kUninitialized state).
- // Since we had an initial Preroll(), we consider ourself flushed, because we
- // have not populated any buffers yet.
+ // We're all good! Consider ourselves flushed because we have not read any
+ // frames yet.
state_ = kFlushed;
algorithm_.reset(new VideoRendererAlgorithm(wall_clock_time_cb_));
@@ -285,41 +283,44 @@ void VideoRendererImpl::SetGpuMemoryBufferVideoForTesting(
gpu_memory_buffer_pool_.swap(gpu_memory_buffer_pool);
}
-void VideoRendererImpl::OnTimeStateChanged(bool time_progressing) {
+void VideoRendererImpl::TimeStartedProgressing() {
DCHECK(task_runner_->BelongsToCurrentThread());
- time_progressing_ = time_progressing;
+ time_progressing_ = true;
- // WARNING: Do not attempt to use |lock_| here as this may be a reentrant call
- // in response to callbacks firing above.
+ if (sink_started_)
+ return;
+
+ // If only an EOS frame came in after a seek, the renderer may not have
+ // received the ended event yet though we've posted it.
+ if (rendered_end_of_stream_)
+ return;
- if (sink_started_ == time_progressing_)
+ // If we have no frames queued, there is a pending buffering state change in
+ // flight and we should ignore the start attempt.
+ if (!algorithm_->frames_queued()) {
+ DCHECK_EQ(buffering_state_, BUFFERING_HAVE_NOTHING);
return;
+ }
+
+ StartSink();
+}
+
+void VideoRendererImpl::TimeStoppedProgressing() {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ time_progressing_ = false;
+
+ if (!sink_started_)
+ return;
+
+ StopSink();
- if (time_progressing_) {
- // If only an EOS frame came in after a seek, the renderer may not have
- // received the ended event yet though we've posted it.
- if (rendered_end_of_stream_)
- return;
-
- // If we have no frames queued, there is a pending buffering state change in
- // flight and we should ignore the start attempt.
- if (!algorithm_->frames_queued()) {
- DCHECK_EQ(buffering_state_, BUFFERING_HAVE_NOTHING);
- return;
- }
-
- StartSink();
- } else {
- StopSink();
-
- // Make sure we expire everything we can if we can't read anymore currently,
- // otherwise playback may hang indefinitely. Note: There are no effective
- // frames queued at this point, otherwise FrameReady() would have canceled
- // the underflow state before reaching this point.
- if (buffering_state_ == BUFFERING_HAVE_NOTHING) {
- base::AutoLock al(lock_);
- RemoveFramesForUnderflowOrBackgroundRendering();
- }
+ // Make sure we expire everything we can if we can't read any more currently,
+ // otherwise playback may hang indefinitely. Note: There are no effective
+ // frames queued at this point, otherwise FrameReady() would have canceled
+ // the underflow state before reaching this point.
+ if (buffering_state_ == BUFFERING_HAVE_NOTHING) {
+ base::AutoLock al(lock_);
+ RemoveFramesForUnderflowOrBackgroundRendering();
}
}
@@ -415,10 +416,7 @@ void VideoRendererImpl::FrameReady(VideoFrameStream::Status status,
if (buffering_state_ == BUFFERING_HAVE_NOTHING && HaveEnoughData_Locked())
TransitionToHaveEnough_Locked();
- // Always request more decoded video if we have capacity. This serves two
- // purposes:
- // 1) Prerolling while paused
- // 2) Keeps decoding going if video rendering thread starts falling behind
+ // Always request more decoded video if we have capacity.
AttemptRead_Locked();
}

Powered by Google App Engine
This is Rietveld 408576698