From cd6c44db47b7df91f889c54303d8858e32ac61e2 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Jan 2022 17:01:04 -0500 Subject: [PATCH] Revert "Remove sleeping from Analysis thread. It is uneccessary and results in us starting off way behind the capture thread. It also limits us to 30fps." This reverts commit 6c4156a4830da04d6128a9159c32c3bb0be607b1. --- src/zm_analysis_thread.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/zm_analysis_thread.cpp b/src/zm_analysis_thread.cpp index 325d8de59..7d803c16b 100644 --- a/src/zm_analysis_thread.cpp +++ b/src/zm_analysis_thread.cpp @@ -23,6 +23,14 @@ void AnalysisThread::Start() { void AnalysisThread::Run() { while (!(terminate_ or zm_terminate)) { - monitor_->Analyse(); + // Some periodic updates are required for variable capturing framerate + Debug(2, "Analyzing"); + if (!monitor_->Analyse()) { + if (!(terminate_ or zm_terminate)) { + Microseconds sleep_for = monitor_->Active() ? Microseconds(ZM_SAMPLE_RATE) : Microseconds(ZM_SUSPENDED_RATE); + Debug(2, "Sleeping for %" PRId64 "us", int64(sleep_for.count())); + std::this_thread::sleep_for(sleep_for); + } + } } }