Skip to content

obs-audio-monitoring: swap the null audio-monitoring backend to safe Rust (Refs #5269) - #5278

Merged
rdoupe merged 2 commits into
masterfrom
port/5269-null-audio-monitoring
Nov 19, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/5269-null-audio-monitoring

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #5269

Swaps the null audio-monitoring backend (libobs/audio-monitoring/null/null-audio-monitoring.c.h, the one Linux and FreeBSD select when ENABLE_PULSEAUDIO is off) to safe Rust in obs-audio-monitoring. The characterization (#5262, PR #5268) is on master.

What changes

  • Symbol ownership stays with the selected backend. Windows, macOS and PulseAudio builds define the same six canonical names (obs_audio_monitoring_available, obs_enum_audio_monitoring_devices, audio_monitor_create, audio_monitor_reset, audio_monitor_destroy, devices_match) in their own backends, so the always-linked Rust archive must not export them. They stay thin C forwarders in null-audio-monitoring.c.h, which only the selected libobs.null-audio group compiles, and each calls a uniquely named adapter declared in the new private header null/null-audio-monitoring.h (no EXPORT, listed in rust-hidden.d). This is the "uniquely named hidden Rust functions behind selected thin native forwarders" option the issue names.
  • Rust: obs-audio-monitoring::null_monitoring (safe core; Monitor is an uninhabited type, so create can never return one) and ffi::null_monitoring (the six hidden adapters). No argument is read, written, kept or freed; no callback runs; nothing logs or allocates.
  • C reference: the original bodies, verbatim, under the adapter names in null-audio-monitoring-reference.c.h, compiled by the new group libobs.ported-null-audio-monitoring (its own small PCH, LIBOBS_LINUX_PORTED_SOURCES through ported-source-sets/nix-null-audio-monitoring.json, so it covers Linux and FreeBSD without editing a shared CMake file).
  • Tier 2: test_null_audio_monitoring.c is unchanged. Its target now also links libobs_rust-static (family core-relinked, as rust: Port libobs/obs-video-level-queries.c.h to obs-core #5187 did for test_video_level_queries): its two public calls still go through the selected real libobs (C reference in mode OFF, hybrid in mode ON), and its renamed copy of the whole source (null_c_*, now the forwarders) reaches the Rust adapters. Its teardown keeps checking zero log calls and balanced bnum_allocs.

Tests

  • Tier 1 (obs-tests-core, audio_monitoring::null_monitoring): every assertion of test_null_audio_monitoring.c, 1:1, same names and order, against the safe core.
  • Tier 3 (audio_monitoring::null_monitoring_parity): the original C (oracle null_monitoring.c, the reference copy renamed oracle_*) and the Rust shims over the C test's inputs (NULL, caller storage that is not an OBS object, equal/non-UTF-8/unterminated IDs) and a proptest over arbitrary never-valid addresses: same answers, zero callbacks, storage unchanged. Mutation check: the_comparison_catches_a_backend_that_matches_ids swaps in a devices_match that matches equal pointers and asserts the comparison sees it.

RED → GREEN

soldr cargo test -p obs-data --test obs-tests-core null_monitoring

  • RED (test: Mirror the null audio-monitoring characterization over a stub, core todo!()):
    test result: FAILED. 0 passed; 4 failed (all four Tier 1 cases: not yet implemented: null monitoring: ...).
  • GREEN (obs-audio-monitoring: Port the null audio-monitoring backend to Rust):
    test result: ok. 7 passed; 0 failed (4 Tier 1 + 3 Tier 3).

Also run locally: ./lint (lane lint ok), export_list (4 passed), the Rust-static registration tests (rust_static: 18 passed, entries_cover_every_rust_static_target ok).

Tier 2, PulseAudio off (the only configuration that selects this backend; CI's Linux Tier 2 builds with PulseAudio on, where test_null_audio_monitoring is not selected). OBS_EXTRA_CMAKE_ARGS=-DENABLE_PULSEAUDIO=OFF uv run rust/tools/linux-validate/run.py --repeat 2 --tests '...' built both libraries and printed:

== libobs exported symbols, C vs Rust
IDENTICAL (1769 symbols)

It then stops at FAIL: audio-monitoring/pulse/pulseaudio-monitor-format.c.h.o was not compiled into libobs-c-reference: the ported-object proof always expects the PulseAudio ported groups, so a pulse-off run stops there on master too. I ran the tests from the same build tree (ENABLE_PULSEAUDIO:BOOL=OFF) in the linux-validate image under xvfb-run, ctest -R 'null_audio_monitoring|audio_monitor|monitoring' --repeat until-fail:2:

  • mode ON (hybrid): 100% tests passed, 0 tests failed out of 7
  • mode OFF (LD_LIBRARY_PATH=.../libobs-c-reference, ldd shows libobs.so.30 => /build/tree/libobs-c-reference/libobs.so.30): 100% tests passed, 0 tests failed out of 7
  • test_null_audio_monitoring run directly in both modes: [ PASSED ] 4 test(s)., every case [ RUN ]/[ OK ] (none skipped).
  • nm on the test binary shows the six obs_null_audio_monitor* adapters defined from the Rust archive; nm -D on hybrid libobs shows none of them exported.

PulseAudio-on Tier 2, the Windows MSVC link and the other targets run in PR CI.

No public header, existing C test or OBS WebSocket changes.

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 19, 2026 14:44
…RED, Refs #5269)

Tier 1 ports every assertion of test_null_audio_monitoring.c to the safe
core of the null backend, which is todo!() here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(GREEN, Refs #5269)

The six canonical functions of null-audio-monitoring.c stay thin C
forwarders in the selected libobs.null-audio group, so no other backend
sees the names; they call six hidden adapters (null-audio-monitoring.h),
Rust in hybrid libobs and the original C in the C reference group
libobs.ported-null-audio-monitoring. The unchanged characterization is
relinked against the Rust archive; Tier 3 compares the original C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795118585,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":94,"stamp":"04d3438467e627b991d8ae4ea38301ce","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118585,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":94,"stamp":"5429750b315068f8956eb1f591b43462","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118585,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":94,"stamp":"9e9c7a3590d16a7435951f370789fba8","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118585,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":94,"stamp":"cbaf38e9a523344e288a8451b37a5289","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"general/all/client-lint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"ad53031b7d430c09fc74cb70fd4f3baa","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118585,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":94,"stamp":"15982da2ca6dd4abf6127f71c7eeec64","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118490,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"8b18a8e62147e9dd2e91c9e43e652a15","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118490,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"fee2cf12e08ac7e1e146d3c0f0b4886c","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"f4ffe9a1fa9db69b05a74a621d5d10e9","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"ef44afa257c359aa6433f9abc212f23c","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"553ac59d156c1c0262997626d7bc309c","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"1e2e4fd21a8d8e32c8b7fb179a304323","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"dff74604a59f03329f733889b50f9d04","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"cd9a9dd548d80ed4d77258aac5a7db89","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"9d6997d33e50f35b23dceccfe9948f4c","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"41605132cb93b2a80653c2513e19202f","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"744a728919cb333bc2c5cd063d0173fe","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118489,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"bf140ca6bc993aca4242631716fa6008420da94313b0b85ce14d267f3e7394e8","lane":"client-lint","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":77,"stamp":"e0115a18a82f75bcbce7280fa84d7f8d","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}
Ci-Attestation: {"at":1795118812,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"85e26f106665f70b82c27d4e4842446d2174c1dc1a831a3446346edf7ba37c45","lane":"client-test-x86_64-unknown-linux-gnu","parents":["7961a50f913755d5c46511ad26590a236689f9e9"],"secs":226,"stamp":"cfe1610db666618ab2a8b4b5935afa39","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"7d19e183b72303c24dfdb5569f032d1c21756cab","coverage":"all-tracked-applicable-files","diff":["libobs/audio-monitoring/null/null-audio-monitoring-reference.c.h","libobs/audio-monitoring/null/null-audio-monitoring.c.h","libobs/audio-monitoring/null/null-audio-monitoring.h","libobs/build/libobs-nix.pch.h","libobs/build/libobs-ported-null-audio-monitoring.pch.h","libobs/build/libobs.ported-null-audio-monitoring+.h.c","libobs/build/ported-source-sets/nix-null-audio-monitoring.json","libobs/cmake/rust-hidden.d/obs-audio-monitoring-null_monitoring.txt","rust/README.md","rust/obs-audio-monitoring/Cargo.toml","rust/obs-audio-monitoring/src/ffi/mod.rs","rust/obs-audio-monitoring/src/ffi/null_monitoring.rs","rust/obs-audio-monitoring/src/lib.rs","rust/obs-audio-monitoring/src/null_monitoring.rs","rust/obs-audio-monitoring/tests/audio_monitoring/main.rs","rust/obs-audio-monitoring/tests/audio_monitoring/null_monitoring.rs","rust/obs-audio-monitoring/tests/audio_monitoring/null_monitoring_parity.rs","rust/obs-build/tests/native/registration/rust-static/cases/core-relinked/test_null_audio_monitoring.json","rust/obs-c-oracle/oracle/null_monitoring.c","rust/obs-c-oracle/src/lib.rs","rust/obs-c-oracle/src/null_monitoring.rs","test/cmocka/build/test-graph.json"],"head":"0f35857beec13ceb477bad81e6ba349500063626","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"d3bf2cd385214723465a6400857580c279c762b53bd2e13a04e228180853920b","tree":"2229ab36cc9d10270830d70e63d5b58883fb1899"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 19, 2026 20:07
@rdoupe rdoupe changed the title obs-audio-monitoring: Port the null audio-monitoring backend to Rust (GREEN, Refs #5269) obs-audio-monitoring: swap the null audio-monitoring backend to safe Rust (Refs #5269) Nov 19, 2026
@rdoupe
rdoupe enabled auto-merge November 19, 2026 20:28
@rdoupe
rdoupe added this pull request to the merge queue Nov 19, 2026
@zackees

zackees commented Nov 19, 2026

Copy link
Copy Markdown
Member

Heads-up from the pool manager: this queue run failed only in Tier 2 Linux (tests OFF): test_scene_item_transition_serialization_lifetime / roundtrip_replace_clear, obs_weak_source_expired(weak) is not true (job 135870054317). That's the same weak-reference-expiry timing family as #4680 (the video tick can briefly still hold a ref), not your null audio-monitoring swap. With HEADGREEN, this PR still merges if a later group containing it passes; otherwise re-arming at the same head is reasonable. We'll track it as a #4680-family flake.

Merged via the queue into master with commit 717ea6c Nov 19, 2026
46 checks passed
@rdoupe
rdoupe deleted the port/5269-null-audio-monitoring branch November 19, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants