Repository navigation
Description
Unit
Port the audio timestamp placement decisions in libobs/obs-source.c.h to Rust. This unit creates a new crate, rust/obs-source, the crate for libobs/obs-source*.c.h units, following the precedent of rust/obs-scene and #444. Please tell me if you'd rather have it as a module somewhere else before anyone else creates that crate.
What moves (on master today):
source_output_audio_data: the direct-timestamp detection, the jump/smooth/log choice onnext_audio_ts_min(withdrift_errorandcontinuous), the push-back/place choice onnext_audio_sys_ts_min(with the "no timing reset when the audio was continuous" rule), and the sync-offset arithmetic with its "offset changed → place" rule;reset_audio_timinganduint64_diff;- the
audio_tsrule ofreset_audio_data_at_sys_time.
What stays C: handle_ts_jump (it takes audio_buf_mutex and empties the buffers), audio_resampler_set_compensation_error, conv_frames_to_time (C computes the packet duration, so no sample-rate division reaches Rust), the deque place/push-back, the signals, muting and the lock.
Plan (one PR, separate commits)
- Move the decisions into
libobs/obs-source-audio-timing.c.has two hidden pure steps around the lock: one before it, one under it. C reads the fields into a small struct, calls a step, and writes the result back, so thevolatilestores oftiming_set/timing_adjuststay where they are. This commit is behaviour-neutral. - Characterization (
test_source_audio_timing_steps), covering:- every branch of both steps;
- values just under, at and just over the 70 ms smoothing threshold and the 2 s
MAX_TS_VAR; - direct timestamps, the async-decoupled re-anchor and
next_audio_ts_min == 0; - a negative sync offset larger than the timestamp, and
u64wrap, pinned as characterized, not endorsed; - a sync offset changed between packets.
- RED, then GREEN: the safe Rust core plus shims in a
libobs.ported-source-audio-timinggroup, with exported symbols unchanged. The arithmetic wraps exactly where C's unsigned arithmetic does. - Tier 3 parity against the original C: a proptest over full-range
u64timestamps andi64offsets, every flag combination, and sequences of 2–50 packets. The step outputs and the written-back state must be byte-equal. Plus a deliberate-break check andport_comparisonnumbers.
These real-libobs tests must stay green on every lane: test_async_delay_audio, test_audio_sync_offset_change, test_media_sync_offset_restart, test_audio_restart_resampler_tail and test_audio_clock_drift.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 23, 2026
Claiming: #1932 (creates
rust/obs-source).libobs: Move the source audio timestamp placement into obs-source-aud…
test: Characterize the source audio timestamp placement
obs-source: Add Tier 1 tests for the source audio timestamp placement…
obs-source: Port the source audio timestamp placement
obs-source: Check the source audio timestamp placement port against t…
docs: Record the source audio timestamp placement port
obs-source: Port the source audio timestamp placement (obs-rust#1936)