pub struct ClockNormalizer { /* private fields */ }Expand description
Translates input timestamps to the process-monotonic clock.
Records the input timestamp and monotonic clock origins on the first call.
Later calls return device_pts - device_origin + monotonic_origin, preserving
input deltas. Despite the parameter names, the facade supplies ingest arrival
times (monotonic_now_ns) for both microphone and loopback, not device PTS.
Implementations§
Source§impl ClockNormalizer
impl ClockNormalizer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a normalizer with unset origins, which are fixed by the first normalize.
Sourcepub fn is_unset(&self) -> bool
pub fn is_unset(&self) -> bool
Returns whether the origins are still unset (the first sample has not arrived).
Sourcepub fn normalize(&mut self, device_pts_ns: i64) -> i64
pub fn normalize(&mut self, device_pts_ns: i64) -> i64
Maps an input timestamp (ns) to the process-monotonic timeline (ns).
The first call fixes the origins and uses the current monotonic_now_ns as
the monotonic origin. Later calls preserve input timestamp deltas.
Input timestamp rollover uses wrapping subtraction; a translated value outside i64
saturates at the nearest boundary rather than panicking or wrapping the timeline.