From abc5d6af4b63a11b414b40db6e484ff8ae409ac1 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Mon, 21 Jul 2025 11:58:47 +0100 Subject: [PATCH] fix: use current frame for timecode sync check Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) --- src/sync_logic.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sync_logic.rs b/src/sync_logic.rs index 4a7acf6..efd2f27 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -91,6 +91,18 @@ impl LtcState { match frame.status.as_str() { "LOCK" => { self.lock_count += 1; + + // Recompute timecode-match every 5 seconds + let now_secs = Utc::now().timestamp(); + if now_secs - self.last_match_check >= 5 { + self.last_match_status = if frame.matches_system_time() { + "IN SYNC" + } else { + "OUT OF SYNC" + } + .into(); + self.last_match_check = now_secs; + } } "FREE" => { self.free_count += 1; @@ -101,18 +113,6 @@ impl LtcState { _ => {} } - // Recompute timecode-match every 5 seconds - let now_secs = Utc::now().timestamp(); - if now_secs - self.last_match_check >= 5 { - self.last_match_status = if let Some(frame) = &self.latest { - if frame.matches_system_time() { "IN SYNC" } else { "OUT OF SYNC" } - } else { - "UNKNOWN" - } - .into(); - self.last_match_check = now_secs; - } - self.latest = Some(frame); }