pub struct ClockNormalizer { /* private fields */ }Expand description
Normalizes device PTS to the shared monotonic clock.
Records the device PTS origin and monotonic clock origin on the first sample.
Later calls return device_pts - device_origin + monotonic_origin, shifting the
device clock onto the monotonic timeline while preserving its rate.
For sources without device PTS, such as microphones, pass each sample’s arrival
time (monotonic_now_ns) as 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 device PTS (ns) to normalized monotonic PTS (ns).
The first call fixes the origins and uses the current monotonic_now_ns as
the monotonic origin. Later calls preserve device-clock deltas.
Trait Implementations§
Source§impl Clone for ClockNormalizer
impl Clone for ClockNormalizer
Source§impl Debug for ClockNormalizer
impl Debug for ClockNormalizer
Auto Trait Implementations§
impl Freeze for ClockNormalizer
impl RefUnwindSafe for ClockNormalizer
impl Send for ClockNormalizer
impl Sync for ClockNormalizer
impl Unpin for ClockNormalizer
impl UnsafeUnpin for ClockNormalizer
impl UnwindSafe for ClockNormalizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more