Skip to content

Commit

Permalink
Change logic for going to sleep to just have an image instead of usin…
Browse files Browse the repository at this point in the history
…g Ready() which looks for keyframe interval.
  • Loading branch information
Isaac Connor committed Oct 28, 2024
1 parent 6fe9d9d commit 6cc423b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/zmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,20 +293,24 @@ 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<int64>(std::chrono::duration_cast<Seconds>(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<int64>(std::chrono::duration_cast<Seconds>(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();
}
std::this_thread::sleep_for(Microseconds(100000));
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)",
Expand Down

0 comments on commit 6cc423b

Please sign in to comment.