diff --git a/tools/chatgui/src/stream_publish_engine.cpp b/tools/chatgui/src/stream_publish_engine.cpp index e46f6007..447e27ae 100644 --- a/tools/chatgui/src/stream_publish_engine.cpp +++ b/tools/chatgui/src/stream_publish_engine.cpp @@ -103,6 +103,7 @@ struct StreamPublishEngine::Impl { #endif std::unique_ptr window; QImage frame; + QImage latestImage; QVideoFrame previewFrame; QVideoFrame presentedPreview; int64_t lastImageCaptureAt = 0; @@ -282,7 +283,7 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) { { std::lock_guard guard(m->lock); if (!m->running || generation != m->sourceGeneration) return; - m->frame = std::move(image); m->framePts = framePts; m->frameGeneration = m->generation; + m->latestImage = image; m->frame = std::move(image); m->framePts = framePts; m->frameGeneration = m->generation; } m->wake.notify_all(); }, Qt::DirectConnection); @@ -414,7 +415,8 @@ void StreamPublishEngine::closeSource() { if (m->screen) { disconnect(m->screen.get(), nullptr, this, nullptr); m->screen->stop(); } if (m->window) { disconnect(m->window.get(), nullptr, this, nullptr); m->window->stop(); } m->session.reset(); m->camera.reset(); m->screen.reset(); m->window.reset(); m->sink.reset(); - std::lock_guard guard(m->lock); m->frame = {}; m->previewFrame = {}; m->presentedPreview = {}; m->framePts = -1; + std::lock_guard guard(m->lock); + m->frame = {}; m->latestImage = {}; m->previewFrame = {}; m->presentedPreview = {}; m->framePts = -1; #endif } @@ -491,7 +493,7 @@ bool StreamPublishEngine::reconfigure(const StreamPublishConfig& config) { && (config.video.width != previous.video.width || config.video.height != previous.video.height || config.video.fps != previous.video.fps)); { std::lock_guard guard(m->lock); m->wanted = config; m->generation++; m->started = monotonicUs(); m->softwareRequest = 0; #ifdef HAVE_STREAM_CAPTURE - if (!sourceChange) m->frameGeneration = m->generation; + if (!sourceChange) { m->frame = m->latestImage; m->frameGeneration = m->generation; } #endif } if (sourceChange && !openSource(config)) { sourceFailed(m->generation, text("Could not open the selected video source")); return false; }