Commit 51b64a4d authored by Vasiliy Telezhnikov's avatar Vasiliy Telezhnikov Committed by Commit Bot

Fix RunAfterPendingVideoFrames before CreateVideoFrame

RunAfterPendingVideoFrames is used to make sure VideoFrameFactoryImpl
pipeline is ordered and the callback is run after all pending
CreateVideoFrame is done. For this purpose it RequestImage() with the
same ImageSpec as last request and waits for request to complete.

It is possible that RunAfterPendingVideoFrames is called before any
CreateVideoFrame calls and so ImageSpec isn't initialized yet. This CL
fixes this by skipping RequestImage() in this case, as there should be
no pending CreateVideoFrame.

Bug: 1099384
Change-Id: I669718a8c470c1f0360a79c47317252025fdedd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302410Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791252}
parent d8ca3b06
...@@ -200,8 +200,21 @@ void VideoFrameFactoryImpl::CreateVideoFrame_OnFrameInfoReady( ...@@ -200,8 +200,21 @@ void VideoFrameFactoryImpl::CreateVideoFrame_OnFrameInfoReady(
// nothing. But in this case call comes from RunAfterPendingVideoFrames and we // nothing. But in this case call comes from RunAfterPendingVideoFrames and we
// just want to ask for the same image spec as before to order callback after // just want to ask for the same image spec as before to order callback after
// all RequestImage, so skip updating image_spec_ in this case. // all RequestImage, so skip updating image_spec_ in this case.
if (output_buffer_renderer) if (output_buffer_renderer) {
image_spec_.coded_size = frame_info.coded_size; image_spec_.coded_size = frame_info.coded_size;
} else {
// It is possible that we come here from RunAfterPendingVideoFrames before
// CreateVideoFrame was called. In this case we don't have coded_size, but
// it also means that there was no `image_provider_->RequestImage` calls so
// we can just run callback instantly.
if (image_spec_.coded_size.IsEmpty()) {
std::move(image_ready_cb)
.Run(nullptr, FrameInfoHelper::FrameInfo(),
SharedImageVideoProvider::ImageRecord());
return;
}
}
DCHECK(!image_spec_.coded_size.IsEmpty());
auto cb = base::BindOnce(std::move(image_ready_cb), auto cb = base::BindOnce(std::move(image_ready_cb),
std::move(output_buffer_renderer), frame_info); std::move(output_buffer_renderer), frame_info);
......
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