add sleeping when no viewers and in ondemand mode

This commit is contained in:
Isaac Connor 2022-01-01 17:54:47 -05:00
parent 8c8a9ca32a
commit a250567e74
1 changed files with 9 additions and 5 deletions

View File

@ -250,9 +250,12 @@ int main(int argc, char *argv[]) {
monitor->Id()); monitor->Id());
zmDbDo(sql); zmDbDo(sql);
while ((monitor->Capturing() == Monitor::CAPTURING_ONDEMAND) and !monitor->hasViewers()) {
if (monitor->Capturing() == Monitor::CAPTURING_ONDEMAND) {
while (!zm_terminate and !monitor->hasViewers()) {
Debug(1, "ONDEMAND and no Viewers. Sleeping"); Debug(1, "ONDEMAND and no Viewers. Sleeping");
sleep(1); std::this_thread::sleep_for(Seconds(1));
}
} }
Seconds sleep_time = Seconds(0); Seconds sleep_time = Seconds(0);
@ -295,7 +298,8 @@ int main(int argc, char *argv[]) {
for (size_t i = 0; i < monitors.size(); i++) { for (size_t i = 0; i < monitors.size(); i++) {
monitors[i]->CheckAction(); monitors[i]->CheckAction();
if (monitors[i]->Capturing() == Monitor::CAPTURING_ONDEMAND and !monitors[i]->hasViewers()) { if ((monitors[i]->Capturing() == Monitor::CAPTURING_ONDEMAND) and !monitors[i]->hasViewers()) {
std::this_thread::sleep_for(Microseconds(100000));
result = 0; result = 0;
continue; continue;
} }