From 6cc423bf7a838a48c2e0df665222f78d9c725d23 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 28 Oct 2024 15:51:44 -0400 Subject: [PATCH] Change logic for going to sleep to just have an image instead of using Ready() which looks for keyframe interval. --- src/zmc.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/zmc.cpp b/src/zmc.cpp index cff67132fb..6b231ba1a0 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -293,9 +293,11 @@ int main(int argc, char *argv[]) { if (monitors[i]->Capturing() == Monitor::CAPTURING_ONDEMAND) { SystemTimePoint now = std::chrono::system_clock::now(); monitors[i]->SetHeartbeatTime(now); - int64 since_last_view = static_cast(std::chrono::duration_cast(now.time_since_epoch()).count()) - monitors[i]->getLastViewed(); - if (since_last_view > 10 and monitors[i]->Ready()) { + time_t last_viewed = monitors[i]->getLastViewed(); + int64 since_last_view = static_cast(std::chrono::duration_cast(now.time_since_epoch()).count()) - last_viewed; + Debug(1, "Last view %jd= %" PRId64 " seconds since last view", last_viewed, since_last_view); + if (((!last_viewed) or (since_last_view > 10)) and (monitors[i]->GetLastWriteIndex() != monitors[i]->GetImageBufferCount())) { if (monitors[i]->getCamera()->isPrimed()) { monitors[i]->Pause(); } @@ -303,10 +305,12 @@ int main(int argc, char *argv[]) { result = 0; continue; } else if (!monitors[i]->getCamera()->isPrimed()) { - if (1 > (result = monitors[i]->Play())) + if (1 > (result = monitors[i]->Play())) { + Debug(1, "Failed to play"); break; + } } - } + } // end if ONDEMAND if (monitors[i]->PreCapture() < 0) { Error("Failed to pre-capture monitor %d %s (%zu/%zu)",