Skip to main content

decide_adjustment

Function decide_adjustment 

Source
pub(crate) fn decide_adjustment(
    current_ns: i128,
    previous_ns: Option<i128>,
    step_windows: u32,
    max_slew_ns: i128,
) -> ClockAdjustment
Expand description

Decides how to adjust the timeline from two consecutive window offsets.

§Arguments

  • current_ns - Minimum receive-time minus sample-time in the window that just ended, in nanoseconds. Positive means the timeline is behind the system clock.
  • previous_ns - The same measure for the window before, if there was one.
  • step_windows - Consecutive windows, including this one, whose offset was at least CLOCK_STEP_THRESHOLD_NS in this direction.
  • max_slew_ns - Largest slew allowed, in nanoseconds (positive).

§Returns

ClockAdjustment::Step when a step-sized offset has lasted CLOCK_STEP_WINDOWS windows, ClockAdjustment::Slew when an offset of at least CLOCK_SLEW_THRESHOLD_NS points the same way as in the previous window, and ClockAdjustment::None otherwise.

§Examples

decide_adjustment(64 ms, Some(60 ms), 0, 1 ms)   -> Slew(+1 ms)
decide_adjustment(64 ms, Some(-400 ms), 0, 1 ms) -> None     (direction changed)
decide_adjustment(3 s, Some(3 s), 3, 1 ms)       -> Step(+3 s)