Skip to content

obs-core: port obs_add_raw_audio_callback to Rust (Fixes #5511) - #5512

Merged
rdoupe merged 2 commits into
masterfrom
port/raw-audio-add
Nov 23, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/raw-audio-add

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5511

What and why

obs_add_raw_audio_callback (libobs/obs-raw-audio-add.c.h, extracted and characterized by #5505) moves to Rust in obs-core, the counterpart of obs_remove_raw_audio_callback (#5003). The safe core (raw_audio_add::add) reads the main audio output once and forwards the full size_t mix index, the conversion pointer and the unchanged callback/parameter pair to audio_output_connect exactly once, ignoring its result as the C does, also when the initialized core has no audio output, the mix is out of range or the pair is already registered. The duplicate and range checks and the locking stay in media-io; no validation or fallback is added. The C reads obs->audio.audio directly; the Rust uses the public obs_get_audio getter, which returns that same field. The C file moves to its own ported unity group (libobs.ported-raw-audio-add+), so the C reference keeps compiling it and hybrid libobs links the Rust. No intentional differences from the C.

Tiers: Tier 1 mirrors all seven test_raw_audio_add cases in the Core state binary (a synchronous output model, no threads or waits). Tier 2 is the unchanged test_raw_audio_add against both libraries. Tier 3 runs the renamed original C and the Rust bridge against one connect recorder that keeps media-io's registration rule, comparing arguments, call count, registration state and that neither the core nor the conversion is written, over every mix in 0..8 plus usize::MAX and (on 64-bit) u32::MAX + 1/+ 2, three conversions, four callbacks, four params, with and without audio, plus 256 proptest cases; it also checks the real-header layout of size_t, the callback, void * and struct audio_convert_info. Tier 4 does not apply. No existing C test or public header changes.

Evidence

  • RED, 9e3e0d8 (rebased from e5fd35c; todo!() core): soldr cargo test -p obs-data --test obs-tests-core -- raw_audio_add → 0 passed, 8 failed (not yet implemented: obs_add_raw_audio_callback).
  • GREEN, same command on the head: 8 passed (7 Tier 1 + the original-C Tier 3 parity case). The neighbouring raw_audio filter: 70 passed.
  • Mutation: forwarding mix & 3 instead of mix fails raw_audio_add_parity::original_c_arguments_calls_and_registration_state and four Tier 1 cases.
  • Tier 2 (OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 20 --tests '^test_raw_audio_(add|remove)$'): full suite 1089/1089 on the C reference and 1089/1089 on hybrid libobs, test_raw_audio_add and test_raw_audio_remove 20/20 repeats on each, exported symbols identical (1769).
  • ./lint: ok.

Test cost: seven Tier 1 tests in microseconds, no threads; the parity test runs in one child process (~10 ms).

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner November 23, 2026 13:12
@rdoupe
rdoupe added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 23, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 23, 2026
rdoupe and others added 2 commits November 23, 2026 10:01
… a todo!() stub (Refs #5511)

RED: the obs-core core is todo!(), so all seven Tier 1 cases (one per
test_raw_audio_add case) and the Tier 3 parity test fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The safe core reads the main audio output once and forwards the full
size_t mix, the conversion pointer and the unchanged callback/parameter
pair to audio_output_connect exactly once, ignoring its result as the C
does. The C file moves to its own ported group, so the C reference keeps
compiling it and hybrid libobs links the Rust.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Ci-Attestation: {"at":1795446333,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":95,"stamp":"3950c82497494283895d2e502a1e770a","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446333,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":95,"stamp":"7f015d9f8d594561e5da1023c85d84f5","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446333,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":95,"stamp":"5dd1c0005713f020ace396282a0afb9e","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446333,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":95,"stamp":"dcd5743647ce298c72fd1acd36b031d8","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"general/all/client-lint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"546188afb6421a62337101055742a85b","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446333,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":95,"stamp":"a0823fb5a381090a8f933893ebd85635","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"8b8b3d13bb6a1b4d1fbebef0362bbad6","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"a68c975e98f2a590f0284891074ffd3f","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"9b472030ad226938b6d7d9c41d5f2ab9","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"3feee47989d1ae88d7a66c298c7a8cae","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"7bb5f4018928e3c505a01622d3cd09e8","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"2c296f7240e9d22a806f3c6764e4a050","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"4e0f3fdb7f230f884f093246031e91d1","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"31362f06eac44d6450fefd2784431ee8","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"a99e093823dbcd5ba8b6ccdcc718b0d4","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"d3fd70231f36a7cffac5a23646d1d04f","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"efd4af4eb637881098aa4ced5b39f92e","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446237,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"131bc1426e9b06c0e05dc41336ffa09a5bff544b43048224a0c5a7ce7656b348","lane":"client-lint","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":11,"stamp":"f1c881d40a1838958cfe5822b64819be","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}
Ci-Attestation: {"at":1795446516,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"7d5de99a6e585a6c4748041fd18e607517fbf4fabbe7d528ff4010e75158b363","lane":"client-test-x86_64-unknown-linux-gnu","parents":["9e3e0d87a210d85ef27c7b87f44300586b24e5a7"],"secs":183,"stamp":"fa026ea010e2ddd54e987f356af33f9e","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"fa55e76310e8f3af70b0e7352feff69697ebc9b2","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/build/libobs.ported-raw-audio-add+.h.c","libobs/build/ported-source-sets/raw-audio-add.json","libobs/cmake/rust-exports.d/obs-core-raw_audio_add.txt","rust/README.md","rust/obs-c-oracle/oracle/raw_audio_add.c","rust/obs-core/src/ffi/mod.rs","rust/obs-core/src/ffi/raw_audio_add.rs","rust/obs-core/src/lib.rs","rust/obs-core/src/raw_audio_add.rs","rust/obs-core/tests/obs_core/main.rs","rust/obs-core/tests/obs_core/raw_audio_add.rs","rust/obs-core/tests/obs_core/raw_audio_add_parity.rs"],"head":"3e225268ed05982a3d5ee008ba7db6bdc61321f1","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":"40d8b2be7a3c6c907469d67b6c29f3b662b8d2c5efc34aed778caae4ac2a3739","tree":"a7ddc10789cea163d1b78fce21da18fb3fc3f426"}}
@rdoupe
rdoupe force-pushed the port/raw-audio-add branch from 3a34cb3 to eaeecdb Compare November 23, 2026 15:08
@rdoupe
rdoupe added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit a868903 Nov 23, 2026
45 checks passed
@rdoupe
rdoupe deleted the port/raw-audio-add branch November 23, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Port libobs/obs-raw-audio-add.c.h to obs-core

1 participant