diff --git a/src/video.cpp b/src/video.cpp index 5f810860441..86578879676 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1857,7 +1857,11 @@ 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 all pending images have been encoded + if (shutdown_event->peek() || !images->running() || (reinit_event.peek() && !images->peek())) { break; }