Repository navigation
Description
Unit
The per-source decisions of the "build audio render order" and "render audio data" steps of the audio tick in libobs/obs-audio.c.h, into rust/obs-core as obs_core::audio_render. Slice 4 of obs-audio.c, after #1903 (audio_mix), #2403 (audio_discard) and #2405 (audio_min_ts). It moves first to libobs/obs-audio-render.c.h.
push_audio_tree2, the choice for one visited source: skip it (removed), add it to the render order (not there yet), tag it as duplicated and add it toroot_nodes(already there, an individual audio source, not tagged yet), or nothing. Withis_individual_audio_source: an input withOBS_SOURCE_AUDIOand withoutOBS_SOURCE_COMPOSITE.should_silence_monitored_source: whether a monitored source is silenced because an unmuted Audio Output Capture source records the monitoring device (the deduplication source is set, active, not muted, its volume not 0 within 0.0001, and the source is monitored and not the capture source itself).clear_audio_output_buf, the choice of mixes: the mixes that both the capture source and the source use, withinMAX_AUDIO_MIXES.- The "gone backwards" choice in the render loop: when buffering is at the maximum and a source's timestamp is set and before the tick start, a source with
audio_renderis marked pending, another source has its audio dropped (ignore_audio) and is rendered again after the lock is released. Otherwise nothing.
These stay C in obs-audio.c.h: audio_callback and its order of steps, the walk over the views and their channels (including the check for a view used by two mixes), obs_source_enum_active_tree, the walk over first_audio_source, all locks, obs_source_get_ref/obs_source_release, da_find/da_push_back on render_order and root_nodes, the memset of the output buffers, obs_source_audio_render, the task queue, and the logging. The C finds a source in the render order and passes the result; Rust does not hold source pointers.
Phase and position
Phase 6 (#444), the fourth slice of obs-audio.c. Crate obs-core, next to audio_mix, audio_discard and audio_min_ts. Size: S. After it, obs-audio.c.h keeps only the orchestration: the walks, the locks and refs, the task queue and audio_callback.
Seam
Plain values: the source type and output flags, whether the source is removed, whether it is in the render order already, its audio_is_duplicated flag, the monitoring fields of the deduplication source and of the source (set, active, muted, volume, monitoring_enabled, same source), the two mixer masks, and for the backwards check audio_render (as a bool), audio_ts, the tick start and whether buffering is at the maximum. Rust returns the choice; the C acts on it. No struct of obs-internal.h goes to Rust, and no public header changes.
#2450 (open, @rdoupe) changes the monitoring setter in obs-source.c.h and obs-internal.h. It does not touch obs-audio.c.h; if it changes a field that this slice reads, I rebase on it.
Characterized behaviour to keep (to confirm in the characterization commit)
- Only individual audio sources are tagged as duplicated. A scene or a transition that is in the tree twice is not tagged and is mixed through each parent.
push_audio_tree(top-level sources and the audio source list) does not checkobs_source_removed; its callers do for the view channels, the audio source list does it before the call.- The silence check uses the capture source's own volume (fader), not the mixer's, and treats a volume within 0.0001 of 0 as muted.
- The backwards check uses
<on the tick start and skips a source withaudio_ts == 0.
Existing tests
- No test covers these decisions. The new cases go into
test_audio_buffering_subsample, which compilesobs-audio.c.hand the extracted cores into itself. test_audio_clock_drift,test_audio_sync_offset_change,test_audio_capture_mix_race,test_async_delay_audio,test_group_hide_transition_audioandtest_transition_removed_child_audiorun the real mixer throughOBS::libobsand are the Tier 2 for this slice.
New characterization cases:
- The tree choice: removed (skip), new (add), present and individual and not tagged (tag + root), present and tagged (nothing), present and not individual: a scene, a filter-like composite, an input without audio (nothing).
- The silence check: no capture source, inactive, muted, volume 0 and 0.00005 (not silenced), volume 0.001 (silenced), the source not monitored, the source is the capture source.
- The mix mask: no common mix, one, all six, bits above
MAX_AUDIO_MIXESignored. - The backwards choice: not at the maximum,
audio_ts0, equal to the tick start, before it with and withoutaudio_render.
Plan
One PR, in this order:
- Extraction commit, behaviour-neutral, no Rust: the four decisions into
libobs/obs-audio-render.c.h, declared inlibobs/obs-audio-render.hwithoutEXPORT.obs-audio.c.hcalls them. The unchanged C tests pass. - Characterization commit: the cases above, against the C reference and the hybrid libobs.
- RED: the safe core in
obs-corewithtodo!(), Tier 1 tests inobs-tests-core(the cmocka cases 1:1, plus properties), failing. - GREEN: the core, a thin hidden
#[no_mangle]shim, the include moved to alibobs.ported-audio-rendergroup inlibobs/build/source-sets.json, Tier 3 proptest against the C oracle, andport_comparisonnumbers for the per-source choices. - Tier 2: the real-mixer tests above with Rust off and on. Tier 4: n/a.
The choices run on every audio tick for every source in the tree. The real-host before/after (CT104, NDI/ALSA audio) goes with the next production rebuild, together with #2403 and #2405.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 26, 2026
Claiming: #2452
Plan as in the description: one PR (extraction, characterization, RED, GREEN with Tier 3 and
port_comparison, Tier 2). Extraction, characterization and RED are done locally (CT104: the audio tests 32/32 after the extraction,test_audio_buffering_subsample41/41 with the new cases on the C); GREEN is in progress.obs-core: Port the per-source decisions of the audio render step (obs…