Monado OpenXR Runtime
m_clock_offset.h File Reference

Helpers to estimate offsets between clocks. More...

#include "util/u_time.h"
Include dependency graph for m_clock_offset.h:

Go to the source code of this file.

Functions

static timepoint_ns m_clock_offset_a2b (float freq, timepoint_ns a, timepoint_ns b, time_duration_ns *inout_a2b)
 Helper to estimate the offset between two clocks using exponential smoothing. More...
 

Detailed Description

Helpers to estimate offsets between clocks.

Author
Mateo de Mayo mateo.nosp@m..dem.nosp@m.ayo@c.nosp@m.olla.nosp@m.bora..nosp@m.com

Function Documentation

◆ m_clock_offset_a2b()

static timepoint_ns m_clock_offset_a2b ( float  freq,
timepoint_ns  a,
timepoint_ns  b,
time_duration_ns inout_a2b 
)
inlinestatic

Helper to estimate the offset between two clocks using exponential smoothing.

Given a sample from two timestamp domains A and B that should have been sampled as close as possible, together with an estimate of the offset between A clock and B clock (or zero), it applies a smoothing average on the estimated offset and returns a in B clock.

Parameters
freqAbout how many times per second this function is called. Helps setting a good decay value.
aTimestamp in clock A of the event
bTimestamp in clock B of the event
[in,out]inout_a2bPointer to the current offset estimate from A to B, or 0 if unknown. Value pointed-to will be updated.
Returns
timepoint_ns a in B clock

Referenced by receive_imu_sample().