Repository navigation
obs-core: Port the per-source decisions of the audio render step (#2452) - #2456
Merged
Merged
Conversation
…-audio-render.c Behaviour-neutral extraction for the port to obs-core (slice 4 of obs-audio.c, after #1903, #2403 and #2405). Four decisions of audio_callback's render-order and render steps move to libobs/obs-audio-render.c.h, on plain values, declared in obs-audio-render.h without EXPORT: - obs_audio_render_tree: push_audio_tree2's choice for one visited source (skip a removed source, add a new one, tag an individual audio source that is already in the render order, or nothing). - obs_audio_render_silence: should_silence_monitored_source. - obs_audio_render_clear_mixes: the mixes clear_audio_output_buf clears. - obs_audio_render_backwards: the "gone backwards" choice in the render loop (mark pending, drop and render again, or nothing). obs-audio.c keeps the walks, the locks and refs, render_order and root_nodes, the memset, the rendering and the logging, and passes the fields in. test_audio_buffering_subsample compiles the new file in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cases for obs-audio-render.c before its port to obs-core, in test_audio_buffering_subsample: - tree_choice: a removed source is skipped, a new one added, an individual audio source that is present and not tagged is tagged; a scene, a transition, a composite input, an input without audio and a filter are never tagged (they are mixed through each parent). - tree_wrapper_tags_once: push_audio_tree2 on a render order tags a repeated microphone once and makes it a root node, leaves a repeated scene alone, and skips a removed source that is in the render order. - silence_check and silence_wrappers_use_the_source_fields: an active, unmuted Audio Output Capture source silences monitored sources but not itself; a fader within 0.0001 of 0 counts as muted; only the mixes both sources use are cleared, all frames of them. - clear_mixes_choice: bits at and above MAX_AUDIO_MIXES are not mixes. - backwards_choice: only at the maximum buffering, with a timestamp and strictly before the tick start; a render source is marked pending, another source is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The safe core of obs-audio-render.c in obs_core::audio_render: tree, silence, clear_mixes and backwards, with todo!() bodies. Tier 1 in obs-tests-core: the four cmocka cases of obs-audio-render.c one to one (tree_choice, silence_check, clear_mixes_choice, backwards_choice), edge cases (a type outside the enum, the fader at the precision and NaN, the backwards check at both ends of u64) and properties for each function. RED: the 11 audio_render tests fail on todo!(). Co-Authored-By: Claude Opus 5.5 <[email protected]>
GREEN for obs_core::audio_render: the safe core (tree, silence, clear_mixes, backwards), a thin hidden #[no_mangle] shim for the four functions of obs-audio-render.h, and the include moved to the libobs.ported-audio-render group, so the hybrid libobs drops the C. The deduplication source's fields cross as struct obs_audio_monitor_dedup (#[repr(C)] mirror, layout checked against the C). Tier 1: 11/11. Tier 3 (obs_core::audio_render_parity) against the unmodified C in rust/obs-c-oracle/oracle/audio_render.c: the enum and struct layout and the copied constants; the tree choice exhaustively over removed x present x duplicated x 7 types x every subset of 6 flags; the silence check over every combination of 5 flags x 13 edge volumes (+-0, +-1e-4, +-5e-5, 1e-3, 1, the smallest subnormal, NaN, +-inf); the mixes and the backwards edges; 50 000 random cases per function. 10/10. port_comparison (M1 Max): tree_duplicate 1.64 ns (C 1.65 ns), silence_monitored 1.30 ns (C 1.30 ns). Intentional difference: a null dedup silences nothing (C: dereferences it; libobs always passes one). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
|
Coordinator review: a pure-decision extraction like #2448. The new characterization cases are added to test_audio_buffering_subsample.c with no existing assertion changed, which follows the one-binary-per-category rule. The C-vs-Rust parity test, the bench and the export maps are in. Queuing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2452
Slice 4 of
obs-audio.c, after #1903, #2403 (#2404) and #2405 (#2406): the per-source decisions of the "build audio render order" and "render audio data" steps of the audio tick move tolibobs/obs-audio-render.c.hand are ported toobs_core::audio_render.What changed
libobs/obs-audio-render.{h,c.h}, on plain values:obs_audio_render_tree():push_audio_tree2's choice for one visited source (skip a removed source, add a new one, tag an individual audio source that is already in the render order so it is mixed as a root node, or nothing);obs_audio_render_silence():should_silence_monitored_source, on the deduplication source's fields (struct obs_audio_monitor_dedup: set, active, muted, volume, mixers),monitoring_enabledand whether the source is the deduplication source;obs_audio_render_clear_mixes(): the mixesclear_audio_output_bufclears;obs_audio_render_backwards(): the "gone backwards" choice in the render loop (mark pending, drop and render again, or nothing).obs-audio-render.h(checked by_Static_assertinobs-audio.c.h), so the core and the C oracle compile withoutobs.h. Own PCH, asaudio_min_ts.obs-audio.c.hkeeps the walks over the views, the tree and the audio sources, the locks and refs,render_orderandroot_nodes, thememsetof the output buffers, the rendering, the task queue and the logging. After this slice it holds only that orchestration.rust/obs-core/src/audio_render.rs(safe core) andsrc/ffi/audio_render.rs(shim). Own unity grouplibobs.ported-audio-render; the shims are hidden;ci/test_ported_sources.py;rust/README.md.Kept, characterized, not endorsed
push_audio_tree(top-level sources and the audio source list) does not checkobs_source_removed; its callers do.Intentional difference (C dereferences null; libobs never gets there)
dedupsilences nothing.RED → GREEN
c1a0ead86(behaviour-neutral, no Rust): the audio tests 32/32 on Linux.498f8ea97: 6 new cases intest_audio_buffering_subsample(41/41), 4 on plain values and 2 through the C wrappers (push_audio_tree2on a render order;should_silence_monitored_sourceandclear_audio_output_bufon sources with output buffers).81929a4c9: Tier 1obs_core::audio_render, the 4 plain-value cases 1:1 plus edge cases and properties: 0 of 11 pass (todo!()).25e7b2951: 11 of 11, and Tier 3: the C oracle (the file unmodified, functions renamed) against the shims, 10 of 10. The layout of both enums and the struct and the copied constants; the tree choice exhaustively over removed × present × duplicated × 7 types × every subset of 6 flags; the silence check over every combination of 5 flags × 13 edge volumes (±0, ±1e-4, ±5e-5, 1e-3, 1, the smallest subnormal, NaN, ±∞); the mixes and the backwards edges; 50 000 random cases per function.Mutation check (done once, not committed): all 13 mutants fail Tier 1 or Tier 3 (removed not first;
presentinverted;duplicated, composite flag, type,active, the deduplication source and the fader ignored;<instead of<=inclose_float; the mix mask dropped;>instead of>=andaudio_ts == 0ignored in the backwards check; pending and drop swapped).port_comparison(M1 Max):audio_render/tree_duplicate1.64 ns (C 1.65 ns),audio_render/silence_monitored1.30 ns (C 1.30 ns).Tier 2 (Linux x86_64, Debian 13)
Lint lane (
ci/local_gate.py --lane lint) on the same host passes: clang-format, gersemi, ruff, the 225ci/test_*.pyself-tests, the ratchets, rustfmt, clippy-D warningsfor the workspace and every feature set, and the Dylints.test_audio_buffering_subsample,test_async_delay_audio,test_audio_capture_mix_race,test_audio_clock_drift,test_audio_sync_offset_change,test_group_hide_transition_audio,test_transition_removed_child_audioandtest_preview_audio_sourcespass on the hybrid libobs and onlibobs-c-reference(8/8 each; the loaded libobs checked withLD_DEBUG=libs). Exported symbols: 1766 on both; the four shims are local.The real-host before/after (CT104, NDI/ALSA audio) goes with the next production rebuild, together with #2403 and #2405.
Checklist
master