]> git.sesse.net Git - nageru/commitdiff
Fix an issue where the mixer lagging too much behind CEF would cause us to display... cef
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Feb 2018 17:54:01 +0000 (18:54 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Feb 2018 18:19:19 +0000 (19:19 +0100)
cef_capture.cpp

index 76c5c7f753c8630ff6a796de58ac660daff65bf1..c52e3a45ddccf92f18b6fb489a80d26b66f05ebc 100644 (file)
@@ -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()