Commit 5f60f910 authored by scherkus@chromium.org's avatar scherkus@chromium.org

Add playback underflow logic to media::VideoRendererImpl.

BUG=144683

Review URL: https://codereview.chromium.org/391023002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283501 0039d316-1c4b-4281-b951-d872f2087c98
parent 0b898e7a
......@@ -221,9 +221,15 @@ void VideoRendererImpl::ThreadMain() {
// Remain idle until we have the next frame ready for rendering.
if (ready_frames_.empty()) {
if (received_end_of_stream_ && !rendered_end_of_stream_) {
rendered_end_of_stream_ = true;
ended_cb_.Run();
if (received_end_of_stream_) {
if (!rendered_end_of_stream_) {
rendered_end_of_stream_ = true;
ended_cb_.Run();
}
} else {
buffering_state_ = BUFFERING_HAVE_NOTHING;
task_runner_->PostTask(
FROM_HERE, base::Bind(buffering_state_cb_, BUFFERING_HAVE_NOTHING));
}
UpdateStatsAndWait_Locked(kIdleTimeDelta);
......
......@@ -421,7 +421,7 @@ TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) {
TEST_F(VideoRendererImplTest, EndOfStream_ClipDuration) {
Initialize();
QueueFrames("0 10 20 30");
QueueFrames("0");
EXPECT_CALL(mock_cb_, Display(HasTimestamp(0)));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
StartPlayingFrom(0);
......@@ -497,8 +497,12 @@ TEST_F(VideoRendererImplTest, StartPlayingFrom_LowDelay) {
InitializeWithLowDelay(true);
QueueFrames("0");
// Expect to frequently have enough/nothing due to only requiring one frame.
EXPECT_CALL(mock_cb_, Display(HasTimestamp(0)));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH))
.Times(AtLeast(1));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING))
.Times(AtLeast(1));
StartPlayingFrom(0);
QueueFrames("10");
......@@ -547,4 +551,35 @@ TEST_F(VideoRendererImplTest, VideoDecoder_InitFailure) {
Stop();
}
TEST_F(VideoRendererImplTest, Underflow) {
Initialize();
QueueFrames("0 10 20 30");
EXPECT_CALL(mock_cb_, Display(HasTimestamp(0)));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
StartPlayingFrom(0);
// Frames should be dropped and we should signal having nothing.
{
SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING");
WaitableMessageLoopEvent event;
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING))
.WillOnce(RunClosure(event.GetClosure()));
AdvanceTimeInMs(100);
event.RunAndWait();
}
// Receiving end of stream should signal having enough.
{
SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH");
WaitableMessageLoopEvent event;
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH))
.WillOnce(RunClosure(event.GetClosure()));
SatisfyPendingReadWithEndOfStream();
event.RunAndWait();
}
WaitForEnded();
Shutdown();
}
} // namespace media
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment