diff --git a/src/zm_eventstream.cpp b/src/zm_eventstream.cpp index 2d413d0c87..de361ad352 100644 --- a/src/zm_eventstream.cpp +++ b/src/zm_eventstream.cpp @@ -940,12 +940,13 @@ void EventStream::runStream() { Microseconds delta = Microseconds(0); while (!zm_terminate) { - start = std::chrono::steady_clock::now(); + now = start = std::chrono::steady_clock::now(); { std::scoped_lock lck{mutex}; send_frame = false; + TimePoint::duration time_since_last_send = now - last_frame_sent; if (!paused) { // Figure out if we should send this frame @@ -964,16 +965,22 @@ void EventStream::runStream() { send_frame = true; } else if (!send_frame) { // We are paused, not stepping and doing nothing, meaning that comms didn't set send_frame to true - if (now - last_frame_sent > MAX_STREAM_DELAY) { + if (time_since_last_send > MAX_STREAM_DELAY) { // Send keepalive Debug(2, "Sending keepalive frame"); send_frame = true; + } else { + Debug(4, "Not Sending keepalive frame now %.2f - %.2f last = %.2f > Max %.2f", + FPSeconds(now.time_since_epoch()).count(), + FPSeconds(last_frame_sent.time_since_epoch()).count(), + FPSeconds(time_since_last_send).count(), + FPSeconds(MAX_STREAM_DELAY).count() + ); } } // end if streaming stepping or doing nothing // time_to_event > 0 means that we are not in the event if (time_to_event > Seconds(0) and mode == MODE_ALL) { - TimePoint::duration time_since_last_send = now - last_frame_sent; Debug(1, "Time since last send = %.2f s", FPSeconds(time_since_last_send).count()); if (time_since_last_send > Seconds(1)) { char frame_text[64]; @@ -1069,8 +1076,7 @@ void EventStream::runStream() { base_fps, effective_fps); } - now = std::chrono::steady_clock::now(); - TimePoint::duration elapsed = now - start; + TimePoint::duration elapsed = std::chrono::steady_clock::now() - start; delta -= std::chrono::duration_cast(elapsed); // sending frames takes time, so remove it from the sleep time Debug(2, "New delta: %fs from last frame offset %fs - next_frame_offset %fs - elapsed %fs",