From: Steinar H. Gunderson Date: Thu, 7 Jan 2016 22:28:56 +0000 (+0100) Subject: Make sure no frames are lost in storage on shutdown. X-Git-Tag: 1.0.0~44 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=6a341a95305e6ed4187d858e80f03ed476919dff Make sure no frames are lost in storage on shutdown. --- 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();