Repository navigation
perf(audio-mix): add only into the active mixes (#3189) - #3227
Merged
Merged
Conversation
obs_audio_mix_add() adds every root source into all 6 mixes, though audio_callback() gets the mask of the mixes some output reads (audio-io sets a bit for each mix with inputs). The mixes outside the mask are never read: clamp_audio_output() skips a mix without inputs, and do_audio_output() has no input to hand it to. obs_audio_mix_add_mixers() takes that mask. obs_audio_mix_add() keeps its signature, which test_audio_buffering_subsample calls, and becomes the all-mixes case. The C in obs-audio-mix.c.h is the spec and the oracle (one more rename in oracle/audio_mix.c); the hidden symbol is in rust-exports.map, rust-hidden.txt and rust-unexports-macos.txt. The safe core gets ALL_MIXERS and mix_active() (todo!() here), the shim obs_audio_mix_add_mixers() on top of it. Tests: - Tier 1 (tests/obs_core/audio_mix.rs): mix_active() over every mask of the 6 mixes against every mix, ALL_MIXERS is the six mixes, and a mix past 32 bits is never active. - Tier 3 (audio_mix_parity.rs): compare_mix() takes an optional mask; mix_mixers_every_mask compares the shim with the C for all 64 masks, alone and with every bit above them set, on a whole tick and from frame 300, stereo and 8 channels, and checks that a mix outside the mask keeps its values. OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core -- audio_mix: the 3 Tier 1 tests fail on todo!(); mix_mixers_every_mask reaches it through the extern "C" shim and aborts the run (a panic that cannot unwind). Co-Authored-By: Claude Opus 5.5 <[email protected]>
mix_active() is the bit test, 0 for a mix past the mask's 32 bits. obs_audio_mix_add() in the shim is obs_audio_mix_add_mixers() with ALL_MIXERS, so test_audio_buffering_subsample and every other caller see what they saw before. audio_callback() in obs-audio.c.h mixes through the new static mix_audio_mixers(), which passes the mask it gets to obs_audio_mix_add_mixers(). mix_audio() stays the all-mixes form: test_audio_buffering_subsample includes obs-audio.c.h and calls it. A mix outside the mask now keeps the zeros audio-io cleared it to. For a normal source that is the same bytes as before: process_audio_source_tick() zeroes the source's buffer of every mix outside the mask, so the old add was + 0.0f. A source with its own audio_render (a scene, a transition) leaves those buffers as the last tick that mixed them wrote them, and the old add put that stale audio into a mix nobody reads; an output that connects to that mix during the tick now gets one tick of silence instead. rust/README.md: the audio mix row names the new function. OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core -- audio_mix: 50 passed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…3189) audio_mix/add_sources/<sources>/<6_mixes|1_mix>: one tick of that many root sources, each its own stereo whole-tick buffer, through obs_audio_mix_add_mixers() on both sides, checked bit for bit once and then timed. 6_mixes is what obs_audio_mix_add() did for every source before; 1_mix is one recording or stream track. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=79807bb4dd1795687641df5f7e800a9fafc50c09 secs=431 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1793469720,"gate":"rust/all/fmt","host":"linux-x86_64","key":"51fb5ff39635282aaab440f392fb6f6e24f8ffb32e4a50fdc23618602fa1fff3","lane":"lint","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":91,"stamp":"2ae25cd9e24655373a3a9d36e8686af7","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"51fb5ff39635282aaab440f392fb6f6e24f8ffb32e4a50fdc23618602fa1fff3","lane":"lint","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":91,"stamp":"6c628bd464008446e4ad9cdaa33bc0bd","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"a55aaf5b49b6a59a672129082b2295b478c46063fbedac2ec8b07395a4405ab7","lane":"rust-test","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":174,"stamp":"7f02de83198e543b66d3530423700973","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"acef0931c5427c10f2ac96452965f58309b140b2cf37d8dc079dd297212271b6","lane":"cross","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":165,"stamp":"3ad0eac374e2bd8043e947170156ec93","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"acef0931c5427c10f2ac96452965f58309b140b2cf37d8dc079dd297212271b6","lane":"cross","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":165,"stamp":"8fbb875e6f9b904928675175273edfc9","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"acef0931c5427c10f2ac96452965f58309b140b2cf37d8dc079dd297212271b6","lane":"cross","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":165,"stamp":"7320ac573a93c1dbf1ad3bad269e2032","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"acef0931c5427c10f2ac96452965f58309b140b2cf37d8dc079dd297212271b6","lane":"cross","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":165,"stamp":"f13f2d26b89e718e2deeb9d31b8546b8","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"} Ci-Attestation: {"at":1793469720,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"44f2b20d1240545e0249c4dca1b99a6d85c14f53fbbafa88d43306de1204c667","lane":"tier2-linux","parents":["509723b7e268153ceb103b83612098c2894e3e97"],"secs":246,"stamp":"0efa4979f00b09f31569177b15c34444","tree":"79807bb4dd1795687641df5f7e800a9fafc50c09","v":1,"via":"run"}
zackees
reviewed
Oct 31, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Coordinator review: No blocking findings.
libobs/obs-audio-mix.his an internal header (not inpublic_headersinlibobs/CMakeLists.txt, declarations carry noEXPORT), so addingobs_audio_mix_add_mixersis not a public-header edit. The symbol is added to all three hidden lists (rust-exports.map,rust-hidden.txt,rust-unexports-macos.txt).- C (
obs-audio-mix.c.h:54) and Rust (ffi/audio_mix.rs,mix_active) skip the same mixes.obs_audio_mix_addstays theALL_MIXERScase, sotest_audio_buffering_subsampleis unchanged. Tier 3 parity covers every mask, and the Test cost line is present. - The one behaviour change is that stale audio from scenes or transitions is no longer added into unread mixes. It is documented in the body and reaches no output.
zackees
added a commit
that referenced
this pull request
Oct 31, 2026
…enerate the linker lists (#3233) [GREEN] rust-hidden.txt becomes libobs/cmake/rust-hidden.d/<crate>-<ffi module>.txt (132 fragments) plus rust-hidden-base.txt for Rust runtime patterns, C glue and the macOS-only compiler-rt helpers. libobs/cmake/rust-hidden.cmake generates rust-exports.map and rust-unexports-macos.txt into the build tree at configure time (also runnable with cmake -P); rust/obs-build writes the same lists. The committed .map and macOS list are gone. Rebased onto master after #3165 and #3227: their eight new hidden shims moved into the per-module fragments (obs-graphics-effect_param_types.txt, obs-core-audio_mix.txt), so the generated sets still equal master's old lists exactly. ci_scope: a rust-hidden.d fragment edit is Linux only; the mirrored-lists rule (#2288) and its test are removed. export_list.rs reads the fragments and checks each names only its own module's shims. Refs #3233, #3232
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 31, 2026
…ists (obs-rust#3233) (obs-rust#3248) * test(ci): pin per-module hidden-symbol fragments and Linux-only scope (obs-rust#3233) [RED] Fails: the three shared lists still exist, rust-hidden.d/ and the generator are missing, and a fragment edit selects macOS and Windows. Refs obs-rust#3233, obs-rust#3232 * build(libobs): split hidden-symbol lists into per-module fragments, generate the linker lists (obs-rust#3233) [GREEN] rust-hidden.txt becomes libobs/cmake/rust-hidden.d/<crate>-<ffi module>.txt (132 fragments) plus rust-hidden-base.txt for Rust runtime patterns, C glue and the macOS-only compiler-rt helpers. libobs/cmake/rust-hidden.cmake generates rust-exports.map and rust-unexports-macos.txt into the build tree at configure time (also runnable with cmake -P); rust/obs-build writes the same lists. The committed .map and macOS list are gone. Rebased onto master after obs-rust#3165 and obs-rust#3227: their eight new hidden shims moved into the per-module fragments (obs-graphics-effect_param_types.txt, obs-core-audio_mix.txt), so the generated sets still equal master's old lists exactly. ci_scope: a rust-hidden.d fragment edit is Linux only; the mirrored-lists rule (obs-rust#2288) and its test are removed. export_list.rs reads the fragments and checks each names only its own module's shims. Refs obs-rust#3233, obs-rust#3232 * style: gersemi format rust-hidden.cmake (obs-rust#3233)
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 #3189
What
obs_audio_mix_add()added every root source into all 6 mixes, thoughaudio_callback()gets the mask of the mixes some output reads (audio-io sets a bit for each mix with inputs). Nothing reads a mix outside the mask:clamp_audio_output()skips a mix without inputs, anddo_audio_output()has no input to hand it to.obs_audio_mix_add_mixers(…, uint32_t mixers)(C inobs-audio-mix.c.h, Rust shim on the safe core's newmix_active()): adds into the mixes whose bit is set and leaves the others as they are.obs_audio_mix_add()keeps its signature (test_audio_buffering_subsamplecalls it) and is now the all-mixes case (ALL_MIXERS).audio_callback()inobs-audio.c.hmixes through a new staticmix_audio_mixers()that passes its mask on.mix_audio()stays the all-mixes form:test_audio_buffering_subsampleincludesobs-audio.c.hand calls it.Output. A mix outside the mask keeps the zeros audio-io cleared it to.
process_audio_source_tick()already zeroes the source's buffer of every mix outside the mask, so the old add was+ 0.0f.audio_render(a scene, a transition) does not clear those buffers, so they hold what the last tick that mixed them wrote. Before, that stale audio went into a mix nobody reads. The one visible difference: an output that connects to a mix between audio-io taking the mask and handing out the mixes gets one tick of silence instead of one tick of stale audio.Commits
RED 61d5c94: the C function (the spec, and the oracle through one more rename), the declaration, the export lists,
ALL_MIXERSandmix_active()as atodo!()stub, the shim, and the tests:mix_active()over every mask of the 6 mixes against every mix,ALL_MIXERSis the six mixes, a mix past 32 bits is never active;mix_mixers_every_maskcompares the shim with the C for all 64 masks, alone and with every bit above them set, on a whole tick and from frame 300, stereo and 8 channels, and checks that a mix outside the mask keeps its values.The 3 Tier 1 tests fail on the stub; the Tier 3 test reaches it through the
extern "C"shim and aborts the run.GREEN 509723b:
mix_active(),obs_audio_mix_add()as the all-mixes case,mix_audio_mixers()inaudio_callback(); therust/README.mdrow. 50/50audio_mixtests.Bench 1c0d4e3:
audio_mix/add_sources/<4|16|32>/<6_mixes|1_mix>, one tick of that many sources (each its own stereo buffer) throughobs_audio_mix_add_mixers()on both sides, checked bit for bit once, then timed.Numbers
rust/tools/benchmarks/record.py --cpu 31 --repeats 5 --category audio_mix, Ryzen 9 5950X (Linux x86_64), two runs.6_mixesis what every tick did before this PR;1_mixis one recording or stream track.Rust/C stays at 0.29–0.36 in every case. The other
audio_mixrows do not move.Tests
OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core -- audio_mix: 50/50./usr/bin/time -l):mix_mixers_every_masklongest 0.81 s, peak RSS 13 MB; the wholeaudio_mix_paritymodule 0.78 s reduced, 1.49 s full cases, peak RSS 21 MB; the three new Tier 1 tests only test bits. No test starts its own threads.test_audio_buffering_subsampleand the real-mixer Tier 2 tests (test_audio_clock_drift,test_audio_capture_mix_race, …) run the changedaudio_callback()through libobs.Checklist
master🤖 Generated with Claude Code