Skip to main content

Module clock

Module clock 

Source
Expand description

SharedClock - the single playback time source (decision 2).

Both the Player (worker thread) and the UI (main thread) read the SAME clock, so highlight and audio physically can’t drift. The Player writes position; the UI’s ~15 Hz timer reads SharedClock::position_s and highlights the WordMark whose time_s <= position.

Cross-thread via a relaxed AtomicU64 (nanoseconds) - cheap and single-producer (Player) / single-consumer (UI timer).

Structs§

SharedClock
Shared playback position in nanoseconds (0 = start of playback).

Functions§

highlight_index
Pick the index of the last WordMark whose time_s is <= position_s (the currently-highlighted word). Returns None before the first word.