From 10ea67719e623426ace2a8b5e9c3308e81c319ae Mon Sep 17 00:00:00 2001 From: Cameron Gutman <aicommander@gmail.com> Date: Thu, 4 May 2023 21:08:51 -0500 Subject: [PATCH] Fix crash if capture is stopped before completing startup --- src/video.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/video.cpp b/src/video.cpp index cac50837..8bb8fa06 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -775,9 +775,12 @@ namespace video { } } - if (auto capture_ctx = capture_ctx_queue->pop()) { - capture_ctxs.emplace_back(std::move(*capture_ctx)); + // Wait for the initial capture context or a request to stop the queue + auto initial_capture_ctx = capture_ctx_queue->pop(); + if (!initial_capture_ctx) { + return; } + capture_ctxs.emplace_back(std::move(*initial_capture_ctx)); auto disp = platf::display(map_base_dev_type(encoder.base_dev_type), display_names[display_p], capture_ctxs.front().config); if (!disp) {