From ef2446c7768549827aed6cd2b635a514366c2025 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 13 Dec 2018 20:38:15 +0100 Subject: [PATCH] Fix another shutdown hang. --- futatabi/video_stream.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index ef56ee4..8593936 100644 --- a/futatabi/video_stream.cpp +++ b/futatabi/video_stream.cpp @@ -269,6 +269,7 @@ void VideoStream::start() void VideoStream::stop() { should_quit = true; + queue_changed.notify_all(); clear_queue(); encode_thread.join(); } @@ -560,8 +561,11 @@ void VideoStream::encode_thread_func() // Wait until we have a frame to play. queue_changed.wait(lock, [this]{ - return !frame_queue.empty(); + return !frame_queue.empty() || should_quit; }); + if (should_quit) { + break; + } steady_clock::time_point frame_start = frame_queue.front().local_pts; // Now sleep until the frame is supposed to start (the usual case), -- 2.39.2