From 82e392b0e444d9b4043b78ef3413343b092e4537 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 26 Feb 2018 18:54:01 +0100 Subject: [PATCH] Fix an issue where the mixer lagging too much behind CEF would cause us to display an old frame forever. --- cef_capture.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cef_capture.cpp b/cef_capture.cpp index 76c5c7f..c52e3a4 100644 --- a/cef_capture.cpp +++ b/cef_capture.cpp @@ -99,16 +99,25 @@ void CEFCapture::OnPaint(const void *buffer, int width, int height) video_format.is_connected = true; FrameAllocator::Frame video_frame = video_frame_allocator->alloc_frame(); - if (video_frame.data != nullptr) { + if (video_frame.data == nullptr) { + // We lost a frame, so we need to invalidate the entire thing. + // (CEF only sends OnPaint when there are actual changes, + // so we need to do this explicitly, or we could be stuck on an + // old frame forever if the image doesn't change.) + post_to_cef_ui_thread([this] { + browser->GetHost()->Invalidate(PET_VIEW); + }); + ++timecode; + } else { assert(video_frame.size >= unsigned(width * height * 4)); assert(!video_frame.interleaved); memcpy(video_frame.data, buffer, width * height * 4); video_frame.len = video_format.stride * height; video_frame.received_timestamp = timestamp; + frame_callback(timecode++, + video_frame, 0, video_format, + FrameAllocator::Frame(), 0, AudioFormat()); } - frame_callback(timecode++, - video_frame, 0, video_format, - FrameAllocator::Frame(), 0, AudioFormat()); } void CEFCapture::OnLoadEnd() -- 2.39.2