From 6a341a95305e6ed4187d858e80f03ed476919dff Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 7 Jan 2016 23:28:56 +0100 Subject: [PATCH] Make sure no frames are lost in storage on shutdown. --- h264encode.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/h264encode.cpp b/h264encode.cpp index c233f39..641cf50 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -1611,7 +1611,7 @@ void H264Encoder::save_codeddata(storage_task task) { unique_lock lock(frame_queue_mutex); frame_queue_nonempty.wait(lock, [this]{ return copy_thread_should_quit || !pending_audio_frames.empty(); }); - if (copy_thread_should_quit) return; + if (copy_thread_should_quit && pending_audio_frames.empty()) return; auto it = pending_audio_frames.begin(); if (it->first > task.pts) break; audio_pts = it->first; @@ -1792,18 +1792,18 @@ H264Encoder::H264Encoder(QSurface *surface, int width, int height, HTTPD *httpd) H264Encoder::~H264Encoder() { - { - unique_lock lock(storage_task_queue_mutex); - storage_thread_should_quit = true; - storage_task_queue_changed.notify_all(); - } { unique_lock lock(frame_queue_mutex); copy_thread_should_quit = true; frame_queue_nonempty.notify_all(); } - storage_thread.join(); copy_thread.join(); + { + unique_lock lock(storage_task_queue_mutex); + storage_thread_should_quit = true; + storage_task_queue_changed.notify_all(); + } + storage_thread.join(); release_encode(); deinit_va(); -- 2.39.2