Commit eb1a8753 authored by servolk's avatar servolk Committed by Commit bot

Invoke VideoRenderer flush callback via PostTask

This is necessary to ensure flush callback is called outside of
VideoRenderer::lock_ thus allowing the callback code to access
VideoRender methods. AudioRendererImpl already does the same thing.

Review-Url: https://codereview.chromium.org/2012903002
Cr-Commit-Position: refs/heads/master@{#396963}
parent 9eba18f3
...@@ -497,7 +497,10 @@ void VideoRendererImpl::AttemptRead_Locked() { ...@@ -497,7 +497,10 @@ void VideoRendererImpl::AttemptRead_Locked() {
} }
void VideoRendererImpl::OnVideoFrameStreamResetDone() { void VideoRendererImpl::OnVideoFrameStreamResetDone() {
base::AutoLock auto_lock(lock_); // We don't need to acquire the |lock_| here, because we can only get here
// when Flush is in progress, so rendering and video sink must be stopped.
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!sink_started_);
DCHECK_EQ(kFlushing, state_); DCHECK_EQ(kFlushing, state_);
DCHECK(!received_end_of_stream_); DCHECK(!received_end_of_stream_);
DCHECK(!rendered_end_of_stream_); DCHECK(!rendered_end_of_stream_);
......
...@@ -573,6 +573,27 @@ TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) { ...@@ -573,6 +573,27 @@ TEST_F(VideoRendererImplTest, FlushWithNothingBuffered) {
Destroy(); Destroy();
} }
// Verify that the flush callback is invoked outside of VideoRenderer lock, so
// we should be able to call other renderer methods from the Flush callback.
static void VideoRendererImplTest_FlushDoneCB(VideoRendererImplTest* test,
VideoRenderer* renderer,
const base::Closure& success_cb) {
test->QueueFrames("0 10 20 30");
renderer->StartPlayingFrom(base::TimeDelta::FromSeconds(0));
success_cb.Run();
}
TEST_F(VideoRendererImplTest, FlushCallbackNoLock) {
Initialize();
StartPlayingFrom(0);
WaitableMessageLoopEvent event;
renderer_->Flush(
base::Bind(&VideoRendererImplTest_FlushDoneCB, base::Unretained(this),
base::Unretained(renderer_.get()), event.GetClosure()));
event.RunAndWait();
Destroy();
}
TEST_F(VideoRendererImplTest, DecodeError_Playing) { TEST_F(VideoRendererImplTest, DecodeError_Playing) {
Initialize(); Initialize();
QueueFrames("0 10 20 30"); QueueFrames("0 10 20 30");
......
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