class RecoveredClock
Defined at line 41 of file ../../src/media/audio/lib/clock/recovered_clock.h
A wrapper that allows "recovering" a clock from a stream of position updates. Each position
update has the form `(mono_time, position)`, where `mono_time` is the system monotonic time
at which the `position` was observed. The `position` is any 64-bit integer, such as an index
into a byte stream, where the `position` must advance at a constant rate relative to the
reference clock we are recovering.
Given a position update, combined with a function `ref_time(p)` that translates from position
to the expected reference time at that position, we can compute a clock error:
```
mono_time - clock->MonotonicTimeFromReferenceTime(ref_time(position))
```
If this clock error is non-zero, the RecoveredClock is adjusted to (attempt to) eliminate that
error in future position readings. For example, a RecoveredClock can approximate a hardware
device clock that can be read only indirectly via position updates from a device driver.
All methods are safe to call from any thread.
Public Methods
std::shared_ptr<RecoveredClock> Create (std::string_view name, std::shared_ptr<Clock> backing_clock, PidControl::Coefficients pid_coefficients)
Creates a RecoveredClock which drives the given `backing_clock`, which must be adjustable.
The backing clock is adjusted using a PID controller with the given coefficients.
Defined at line 18 of file ../../src/media/audio/lib/clock/recovered_clock.cc
void Reset (zx::time mono_reset_time, media::TimelineFunction pos_to_ref_time)
Resets the clock's rate to match the system monotonic clock, clears all accumulated state,
and starts using a new translation from position to reference time.
Defined at line 34 of file ../../src/media/audio/lib/clock/recovered_clock.cc
zx::time Update (zx::time mono_time, int64_t position)
Tunes the clock based on an updated position. Returns the clock's predicted monotonic time.
There must be at least one Reset before the first Update. The sequence of Reset and
Update calls must use monotonically-increasing values for both time and position.
Defined at line 41 of file ../../src/media/audio/lib/clock/recovered_clock.cc
std::string_view name ()
Defined at line 52 of file ../../src/media/audio/lib/clock/recovered_clock.h
zx_koid_t koid ()
Defined at line 53 of file ../../src/media/audio/lib/clock/recovered_clock.h
uint32_t domain ()
Defined at line 54 of file ../../src/media/audio/lib/clock/recovered_clock.h
bool adjustable ()
Defined at line 55 of file ../../src/media/audio/lib/clock/recovered_clock.h
zx::time now ()
Defined at line 57 of file ../../src/media/audio/lib/clock/recovered_clock.h
ToClockMonoSnapshot to_clock_mono_snapshot ()
Defined at line 58 of file ../../src/media/audio/lib/clock/recovered_clock.h
void SetRate (int32_t rate_adjust_ppm)
Although a RecoveredClock's rate can change over time, the clock cannot be adjusted directly.
All adjustments happen via `Reset` and `Update`.
Defined at line 64 of file ../../src/media/audio/lib/clock/recovered_clock.h
std::optional<zx::clock> DuplicateZxClockReadOnly ()
Defined at line 68 of file ../../src/media/audio/lib/clock/recovered_clock.h