Repository navigation
Description
Unit
Port the audio input decisions in libobs/obs-source.c.h to rust/obs-source, as a new module audio_input:
- in
process_audio:- the discontinuity rule (libobs: Drop audio held in the resampler when a new stream starts #546): a packet more than
TS_SMOOTHING_THRESHOLDfromnext_resample_in_tsrestarts the resampler; - the reset condition (rate, format, speakers, the compensation flag, or the discontinuity);
- the balance gate and the mono gate;
- the discontinuity rule (libobs: Drop audio held in the resampler when a new stream starts #546): a packet more than
- in
reset_resampler: the "no resampler needed" rule from the clock drift fix; process_audio_balancing(the sine, square and linear laws over two planes) anddownmix_to_mono_planar.
These stay C:
- the computation of
next_resample_in_ts, which C stores and passes in; - the resampler calls,
copy_audio_dataand its allocation; audio_resampler_set_compensation_errorand the drift filter. Rust only reads the compensation flag.
Plan (one PR, separate commits)
-
Behaviour-neutral move into
libobs/obs-source-audio-input.c.h, as hidden functions. The loops take plainfloat **and counts.process_audiokeeps its order. -
Characterization in
test_source_audio_input_steps:- the discontinuity at the threshold −1, equal and +1, in both directions, and with a zero start;
- each reset trigger on its own;
- the balance gate at 0.49, 0.50, 0.51 and just outside, NaN, and out-of-range balances;
- each law on known samples, bit-exact, and an unknown law;
- mono with 2, 6 and 8 channels, and 0 frames.
Plus one real-libobs case for the balance and mono gates, read back through an audio capture callback.
-
RED, then GREEN: the safe Rust core plus shims, in a
libobs.ported-source-audio-inputgroup. Exported symbols are unchanged. If libmsinfand Rust'sf32::sindiffer by an ulp on any platform, C computes the two gains and Rust ports only the loop. -
Tier 3 parity against the original C, plus a deliberate-break check and
port_comparisonnumbers:- exhaustive over the gate flags;
- full-range timestamps;
- bit-equal
f32planes for random samples and balances.
These real-libobs tests must stay green on every lane: test_audio_restart_resampler_tail, test_audio_clock_drift, test_media_sync_offset_restart and test_async_delay_audio.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 23, 2026
Claiming: #1994.
libobs: Move the source audio input steps into obs-source-audio-input.c
test: Characterize the source audio input steps
obs-source: Add Tier 1 tests for the source audio input steps port
obs-source: Port the source audio input steps
obs-source: Check the source audio input steps port against the C
docs: Record the source audio input steps port
obs-source: Port the source audio input steps (obs-rust#2021)