Expand description
Time on the public surface: a span is a Duration, a position is a
Clock27.
The controller keeps two clocks: the host’s monotonic clock (arrival
instants, ticks, timeouts) and the playback (PTS) domain (27 MHz tick
positions, PTS90k x 300). The workspace has one type for each
(docs/API-CONVENTIONS.md): a span of host time is
core::time::Duration, and a position in the playback domain is
broadcast_common::clock33::Clock27, the validated 27 MHz clock value
that cannot hold a PCR extension or a wrap outside the clock. The
controller itself computes host spans in whole microseconds, so it converts
at its edge with instant_micros (or window_micros for a configured
window) and back with micros_as_duration.
§Rounding
One placeholder. A reading (a clock instant) or a difference of two is
truncated to the microsecond it is in (instant_micros): rounding a
reading up makes a logged “now” replay a microsecond in the future, and
makes ceil(a) - ceil(b) disagree with ceil(a - b) by
MAX_DIFFERENCE_ERROR. A configured window that must not become zero
(a jitter window, a hold, a bucket) rounds up (window_micros), so a
sub-microsecond setting is one microsecond rather than an empty window.
This is the workspace’s rule: floor a reading, raise only what a zero would
make meaningless.
Structs§
- Clock27
- A validated 27 MHz clock value:
base * 300 + ext(ISO/IEC 13818-1 §2.4.3.5 PCR, §2.4.3.7 ESCR, §2.5.3.4 program-stream SCR).
Constants§
- MAX_
DIFFERENCE_ ERROR - The most a difference of two truncated readings can understate the real one: each reading is floored by up to one microsecond less than it, and the two roundings cannot exceed this together.
Functions§
- duration_
add a + bin whole microseconds, saturating at the end of the microsecond range rather than panicking on an overflow.- duration_
between - The span from
earliertolater, the whole microsecond it is in, zero whenlateris not after it (a span never goes backwards). - instant_
micros - The microsecond an instant names, truncated: the whole microsecond it falls
in. A span too long for the microsecond range clamps to
u64::MAX. - micros_
as_ duration - Whole microseconds as a
Duration. - window_
micros - The microseconds a configured window spans, rounded up.