diff options
author | dalecurtis <dalecurtis@chromium.org> | 2015-06-11 13:17:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-11 20:18:00 +0000 |
commit | 944417a342cd2bb848503252527c8af951eb94da (patch) | |
tree | 933862fdc3d9189a7284e96c94602b974ebb0e28 /media | |
parent | fe6d900263c3559e0e3dfb1cd3446254ed013a73 (diff) | |
download | chromium_src-944417a342cd2bb848503252527c8af951eb94da.zip chromium_src-944417a342cd2bb848503252527c8af951eb94da.tar.gz chromium_src-944417a342cd2bb848503252527c8af951eb94da.tar.bz2 |
Don't update frame statistics when the frame queue is empty.
This will overflow the -1 iterator in the for loop there. As a
consequence of this change, we won't update frame statistics when
there's only 1 frame in the queue either. Which is fine, all
methods which need this information up to date make their own
calls to update the frame statistics.
BUG=498885,498525
TEST=new unittests
Review URL: https://codereview.chromium.org/1178993002
Cr-Commit-Position: refs/heads/master@{#334025}
Diffstat (limited to 'media')
-rw-r--r-- | media/filters/video_renderer_algorithm.cc | 2 | ||||
-rw-r--r-- | media/filters/video_renderer_algorithm_unittest.cc | 3 | ||||
-rw-r--r-- | media/renderers/video_renderer_impl_unittest.cc | 32 |
3 files changed, 36 insertions, 1 deletions
diff --git a/media/filters/video_renderer_algorithm.cc b/media/filters/video_renderer_algorithm.cc index 233c130..bbb4864 100644 --- a/media/filters/video_renderer_algorithm.cc +++ b/media/filters/video_renderer_algorithm.cc @@ -246,10 +246,10 @@ size_t VideoRendererAlgorithm::RemoveExpiredFrames(base::TimeTicks deadline) { if (deadline > last_deadline_max_) last_deadline_max_ = deadline; - UpdateFrameStatistics(); if (frame_queue_.size() < 2) return 0; + UpdateFrameStatistics(); DCHECK_GT(average_frame_duration_, base::TimeDelta()); // Finds and removes all frames which are too old to be used; I.e., the end of diff --git a/media/filters/video_renderer_algorithm_unittest.cc b/media/filters/video_renderer_algorithm_unittest.cc index fcdedd6..9f2a033 100644 --- a/media/filters/video_renderer_algorithm_unittest.cc +++ b/media/filters/video_renderer_algorithm_unittest.cc @@ -1038,6 +1038,9 @@ TEST_F(VideoRendererAlgorithmTest, CadenceCalculations) { TEST_F(VideoRendererAlgorithmTest, RemoveExpiredFrames) { TickGenerator tg(tick_clock_->NowTicks(), 50); + // Removing expired frames before anything is enqueued should do nothing. + ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); + algorithm_.EnqueueFrame(CreateFrame(tg.interval(0))); ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); diff --git a/media/renderers/video_renderer_impl_unittest.cc b/media/renderers/video_renderer_impl_unittest.cc index 75c599e..67cc312 100644 --- a/media/renderers/video_renderer_impl_unittest.cc +++ b/media/renderers/video_renderer_impl_unittest.cc @@ -716,6 +716,38 @@ TEST_P(VideoRendererImplTest, RenderingStartedThenStopped) { Destroy(); } +TEST_P(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { + // This test is only for the new rendering path. + if (!GetParam()) + return; + + Initialize(); + QueueFrames("0 30 60 90"); + + WaitableMessageLoopEvent event; + EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); + EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) + .WillOnce(RunClosure(event.GetClosure())); + StartPlayingFrom(0); + event.RunAndWait(); + + // Cycle ticking so that we get a non-null reference time. + time_source_.StartTicking(); + time_source_.StopTicking(); + + // Flush and simulate a seek past EOS, where some error prevents the decoder + // from returning any frames. + EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)); + Flush(); + + StartPlayingFrom(200); + WaitForPendingRead(); + SatisfyPendingReadWithEndOfStream(); + EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); + WaitForEnded(); + Destroy(); +} + INSTANTIATE_TEST_CASE_P(OldVideoRenderer, VideoRendererImplTest, testing::Values(false)); |