From d04489799cb9bc2ef7fec25b280ff22ad739d32b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 13 Oct 2024 18:03:24 -0500 Subject: [PATCH] fix(video): encode at least one frame before capture reinit --- src/video.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/video.cpp b/src/video.cpp index 5f810860441..3824c295727 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1857,7 +1857,14 @@ namespace video { } while (true) { - if (shutdown_event->peek() || reinit_event.peek() || !images->running()) { + // Break out of the encoding loop if any of the following are true: + // a) The stream is ending + // b) Sunshine is quitting + // c) The capture side is waiting to reinit and we've encoded at least one frame + // + // If we have to reinit before we have received any captured frames, we will encode + // the blank dummy frame just to let Moonlight know that we're alive. + if (shutdown_event->peek() || !images->running() || (reinit_event.peek() && frame_nr > 1)) { break; }