File timing_core.h¶
FileList > inc > timing > timing_core.h
Go to the source code of this file
#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | dp_sample_clock_t |
Public Functions¶
| Type | Name |
|---|---|
| uint64_t | dp_mono_ns (void) |
| uint64_t | dp_real_ns (void) |
| dp_sample_clock_t * | dp_sample_clock_create (double fs, int resync) |
| void | dp_sample_clock_destroy (dp_sample_clock_t * c) |
| void | dp_sample_clock_init (dp_sample_clock_t * c, double fs, int resync) |
| double | dp_sample_clock_pace (dp_sample_clock_t * c, size_t count) |
| void | dp_sample_clock_reset (dp_sample_clock_t * c) |
| void | dp_sample_clock_resync (dp_sample_clock_t * c) |
| uint64_t | dp_sample_clock_stamp (const dp_sample_clock_t * c) |
| void | dp_sample_clock_stats (const dp_sample_clock_t * c, dp_sample_clock_t * out) |
Public Functions Documentation¶
function dp_mono_ns¶
Current monotonic clock in ns (CLOCK_MONOTONIC) — for pacing.
function dp_real_ns¶
Current wall-clock in ns since the UNIX epoch (CLOCK_REALTIME).
function dp_sample_clock_create¶
Heap-allocate and initialise a clock for sample rate fs (Hz); see dp_sample_clock_init for resync. Returns NULL on allocation failure. This is the opaque-handle constructor the generated realtime composer stream drives (Composer.stream(realtime=fs)): it owns a void *clk created here and freed by dp_sample_clock_destroy.
function dp_sample_clock_destroy¶
Free a clock from dp_sample_clock_create (NULL-safe).
function dp_sample_clock_init¶
Initialise c for sample rate fs (Hz), capturing both epochs now. If resync is nonzero, pace() re-anchors the timeline to "now" whenever it falls behind (absorbing the slip) instead of keeping the absolute schedule.
function dp_sample_clock_pace¶
Advance by count samples and sleep until that block's deadline (epoch + n/fs). Returns the slack in seconds measured before sleeping: >= 0 means early (and it slept that long); < 0 means it arrived late — an underrun, which is counted (and the epoch re-anchored when resync is set), with no sleep.
function dp_sample_clock_reset¶
Re-capture both epochs and zero the counters — a fresh clock at n=0.
function dp_sample_clock_resync¶
Re-anchor the pacing epoch to "now" without clearing n or counters, dropping any accumulated lateness so future blocks pace forward from the present. (pace() does this automatically when resync is set.)
function dp_sample_clock_stamp¶
Ideal wall-clock timestamp (ns since the UNIX epoch) of the next sample to be produced — sample index n. Call it before pace() to tag the block you are about to emit, or after to tag the following block.
function dp_sample_clock_stats¶
The documentation for this class was generated from the following file native/inc/timing/timing_core.h