X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=h264encode.cpp;h=641cf5039bb2db9214d15e9277120a43f3e38a61;hb=6a341a95305e6ed4187d858e80f03ed476919dff;hp=c233f39b738101140589182d9e738dedb467f861;hpb=64b8430160caae390a7e408a6c7d9629dc08e923;p=nageru 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();