From 2efacc634c788d1f260bac78a94757df4cc8a081 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 26 Oct 2024 14:30:02 -0400 Subject: [PATCH] Add back in a Join on the analysis thread and decoder thread before clearing the packetqueue --- src/zm_monitor.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 664cc9ab7e..cfe3718950 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3377,16 +3377,7 @@ int Monitor::PostCapture() const { return camera->PostCapture(); } int Monitor::Pause() { // Because the stream indexes may change we have to clear out the packetqueue - if (decoder) { - Debug(1, "Decoder stopping"); - decoder->Stop(); - Debug(1, "Decoder stopped"); - } - - if (convert_context) { - sws_freeContext(convert_context); - convert_context = nullptr; - } + if (decoder) decoder->Stop(); if (analysis_thread) { analysis_thread->Stop(); @@ -3397,6 +3388,13 @@ int Monitor::Pause() { // Wake everyone up packetqueue.stop(); + if (decoder) decoder->Join(); + if (convert_context) { + sws_freeContext(convert_context); + convert_context = nullptr; + } + if (analysis_thread) analysis_thread->Join(); + // Must close event before closing camera because it uses in_streams if (close_event_thread.joinable()) { Debug(1, "Joining event thread");