mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-10 07:34:22 -04:00
Sleep if Decode fails instead of spinning
This commit is contained in:
@@ -22,6 +22,13 @@ void DecoderThread::Run() {
|
||||
Debug(2, "DecoderThread::Run() for %d", monitor_->Id());
|
||||
|
||||
while (!(terminate_ or zm_terminate)) {
|
||||
monitor_->Decode();
|
||||
if (!monitor_->Decode()) {
|
||||
if (!(terminate_ or zm_terminate)) {
|
||||
// We only sleep when Decode returns false because it is an error condition and we will spin like mad if it persists.
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user