From a184f3adeb3e306ea10b82f5693e6c6081b81898 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 19 Mar 2024 14:55:21 -0400 Subject: [PATCH] Always restart the analysis thread. It is needed. Also free convert_context in Pause --- src/zm_monitor.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index e21fe3165..4a8c1391a 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3453,6 +3453,11 @@ int Monitor::Pause() { Debug(1, "Decoder stopped"); } + if (convert_context) { + sws_freeContext(convert_context); + convert_context = nullptr; + } + if (analysis_thread) { analysis_thread->Stop(); Debug(1, "Analysis stopped"); @@ -3472,11 +3477,13 @@ int Monitor::Pause() { close_event_thread.join(); } } - if (camera) camera->Close(); + if (camera) { + camera->Close(); + } packetqueue.clear(); return 1; -} +} // end int Monitor::Pause() int Monitor::Play() { int ret = camera->PrimeCapture(); @@ -3499,12 +3506,10 @@ int Monitor::Play() { Debug(1, "Restarting decoder thread"); decoder->Start(); } - if (analysing != ANALYSING_NONE) { - Debug(1, "Restarting analysis thread"); - analysis_thread->Start(); - } + Debug(1, "Restarting analysis thread"); + analysis_thread->Start(); return 1; -} +} // end int Monitor::Play() int Monitor::Close() { Pause();