Skip to content

obs-core: swap audio-info and video-statistics queries to safe Rust (Refs #5363, #5364) - #5365

Merged
rdoupe merged 4 commits into
masterfrom
port/5363-5364-core-queries
Nov 20, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/5363-5364-core-queries

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #5363, #5364

Two obs-core swaps of public queries extracted from obs.c.h in #5191. One RED/GREEN commit pair per issue.

Audio-info queries (#5363)

  • obs_get_audio_info and obs_get_audio_info2 are now Rust exports (obs-core::ffi::audio_info_queries over the safe audio_info_queries core). A NULL core answers false before any read. obs_get_audio_info checks its output, then the core's audio output, then reads rate and speakers through the real audio_output_get_info(). obs_get_audio_info2 runs the info read into a local first, then checks its own output and the audio output again, and stores rate, speakers, fixed_buffer and obs_core_setup_rules_buffer_ms(max_buffering_ticks, rate) cast straight to uint32_t. Nothing is written on failure; the caller's struct is written field by field.
  • Core layout stays in C behind private adapters (libobs/obs-audio-info-queries-fields.c.h, also a shared Rust-static support member). The original moves to the reference-only group libobs.ported-audio-info-queries+.h.c; exports in rust-exports.d/obs-core-audio_info_queries.txt.
  • Tier 1: audio_info_queries.rs mirrors all eight test_audio_info_queries cases plus the full read order and a proptest.
  • Tier 3: audio_info_queries_parity.rs runs the original and the shim on one real-header core filled with any byte through one recording audio_output_get_info probe: result, sentinel-filled output bytes, info call log, core bytes, current core pointer, real-header layouts; four shim mutants.
  • The audio-controls oracle's obs_get_audio_info stand-in is dropped: obs-core's export answers false there with no current core (the stand-in's answer).

Video-statistics queries (#5364)

  • obs_get_video_frame_time, obs_get_active_fps, obs_get_average_frame_time_ns, obs_get_total_frames, obs_get_lagged_frames are now Rust exports. Each is one call of its own obs_video_stats_* reader on the current core's video.stats (one lock/read/unlock, as bug: libobs: video stats (fps, frame time, total/lagged frames) raced between graphics and UI threads #175 made it): no combined snapshot, no no-core defaults.
  • Stats layout and mutex stay in C behind private adapters (libobs/obs-video-stats-queries-fields.c.h, which call the header's static inline readers). The original moves to libobs.ported-video-stats-queries+.h.c; exports in rust-exports.d/obs-core-video_stats_queries.txt.
  • Tier 1: video_stats_queries.rs mirrors all five test_video_stats_queries cases over a mutex-guarded host (one locked read of its own field per query, mutex free after each) plus a proptest.
  • Tier 3: video_stats_queries_parity.rs compares exact result bits (FPS as any non-signaling binary64), mutex free after every query, unchanged values and current core pointer, and the adapter's address; four shim mutants.

The unchanged C tests keep testing the extracted C sources (they #include them with renamed symbols); test_get_audio, test_core_setup_rules_steps and test_video_stats_race cover the real library. No public headers, C tests, websocket code or workflows change. Tier 4 does not apply.

Evidence

RED (stubs are todo!()):

soldr cargo test -p obs-data --test obs-tests-core -- audio_info_queries
test result: FAILED. 0 passed; 9 failed

soldr cargo test -p obs-data --test obs-tests-core -- video_stats_queries
test result: FAILED. 0 passed; 6 failed

GREEN:

soldr cargo test -p obs-data --test obs-tests-core -- video_stats_queries audio_info_queries audio_controls
test result: ok. 48 passed; 0 failed

Mutation checks of the safe cores (reverted):

  • get_audio_info2 negating fixed_buffering: audio_info_queries_parity 2 passed; 2 failed.
  • total_frames reading the lagged count: video_stats_queries 2 passed; 8 failed (Tier 1 and parity).

./lint: ok (after --fix reflowed one oracle prototype, folded into the GREEN commit).

Tier 2 (one Docker build, full ctest on both builds, then the touched tests repeated):

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 --tests 'test_audio_info_queries|test_video_stats_queries|test_video_stats_race|test_get_audio|test_core_setup_rules_steps|test_audio_controls'
== libobs exported symbols, C vs Rust: IDENTICAL (1769 symbols)
[OFF] 100% tests passed, 0 tests failed out of 1059   (repeat: 6/6)
[ON]  100% tests passed, 0 tests failed out of 1059   (repeat: 6/6)

Notes:

  • A plain cargo test of the whole obs-tests-core binary (all tests in one process) fails canvas_valid_video_info_parity on its allocation-count check (bnum_allocs() moved by other tests in parallel). It fails the same way with this PR's modules skipped and passes alone; CI runs the binary under nextest, one process per test.
  • ./push attested client-test but stopped at client-swift (no swift-format on this host), so this PR runs ordinary CI.

🤖 Generated with Claude Code

rdoupe and others added 4 commits November 20, 2026 09:03
Safe Rust mirrors of every case of the unchanged
test_audio_info_queries.c (no core, NULL outputs, no audio output, the
copied rate and speakers, info2's inner info read before its own output
check, all four info2 fields with the helper's arguments, the int-to-u32
cast of a negative helper result), plus the full read order and a
proptest over any core, against todo!() cores for obs_get_audio_info and
obs_get_audio_info2.

    soldr cargo test -p obs-data --test obs-tests-core -- audio_info_queries
    test result: FAILED. 0 passed; 9 failed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obs_get_audio_info and obs_get_audio_info2 now come from obs-core in
hybrid libobs. A NULL core answers false before any read. info checks its
output, then the core's audio output, then reads the rate and speakers
through the real audio_output_get_info(). info2 runs the info read into a
local first, then checks its own output and the audio output again, and
stores the rate, the speakers, fixed_buffer and
obs_core_setup_rules_buffer_ms(max_buffering_ticks, rate) cast straight to
uint32_t. Nothing is written on failure; the caller's struct is written
field by field.

The core layout stays in C behind private adapters
(obs-audio-info-queries-fields.c.h, also a shared Rust-static support
member). The original moves to libobs.ported-audio-info-queries for the C
reference; the unchanged test_audio_info_queries keeps testing it, and
test_get_audio and test_core_setup_rules_steps run the real library.

Tier 3 runs the original and the shim on one real-header core filled with
any byte, through one recording audio_output_get_info probe: result,
sentinel-filled output bytes, info call log, core bytes and the current
core pointer, plus the real-header layouts, with four shim mutants. The
audio-controls oracle's obs_get_audio_info stand-in is dropped: obs-core's
export answers false there without a current core.

    soldr cargo test -p obs-data --test obs-tests-core -- audio_info_queries audio_controls
    test result: ok. 38 passed; 0 failed

Mutation (fixed_buffering negated in the safe core): audio_info_queries_parity
2 passed; 2 failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

Safe Rust mirrors of every case of the unchanged
test_video_stats_queries.c (zeroed stats, each query reading its own
field, full-width boundaries, following the current core, values written
through the private setters), each read taken under the stats mutex and
the mutex free after every query, plus a proptest over any values with the
FPS as any bit pattern, against todo!() cores for the five queries.

    soldr cargo test -p obs-data --test obs-tests-core -- video_stats_queries
    test result: FAILED. 0 passed; 6 failed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obs_get_video_frame_time, obs_get_active_fps,
obs_get_average_frame_time_ns, obs_get_total_frames and
obs_get_lagged_frames now come from obs-core in hybrid libobs. Each is one
call of its own obs_video_stats_* reader on the current core's video.stats
(one lock, read and unlock, as #175 made it), returned unchanged: no
combined snapshot and no no-core defaults.

The stats layout and mutex stay in C behind private adapters
(obs-video-stats-queries-fields.c.h, which call the header's static inline
readers; also a shared Rust-static support member). The original moves to
libobs.ported-video-stats-queries for the C reference; the unchanged
test_video_stats_queries keeps testing it and test_video_stats_race the
readers.

Tier 3 runs the original and the shim on one real-header core with an
initialized stats mutex: exact result bits (the FPS as any non-signaling
binary64 pattern), the mutex free after every query, unchanged values and
current core pointer, and the adapter's address, with four shim mutants.

    soldr cargo test -p obs-data --test obs-tests-core -- video_stats_queries audio_info_queries audio_controls
    test result: ok. 48 passed; 0 failed

Mutation (total_frames reading the lagged count in the safe core):
video_stats_queries 2 passed; 8 failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795185679,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":62,"stamp":"81f2b952313b636c392c808e77814cc0","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185679,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":62,"stamp":"cd7460a9e3c75a5be83e16bbc83c6faa","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185679,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":62,"stamp":"4721fb7c58fbe85e01f0c3d811565b9d","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185679,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":62,"stamp":"592af09ccba6ca0efadc81925d17ad79","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"general/all/client-lint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"909be9b678c13d5229af36615b266a62","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185679,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":62,"stamp":"d868238ebafe228fbe42fc2cf9c6ddeb","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"68216eb392cb380ee7407fbccd6b7578","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"36a784ef548e3a667fa2a0f4fdb1bfc2","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"b6fc68281e73b664a8972d19af135d70","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"a3dcf17510cd2f94222e603780a8c2c0","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"8f08ba5500ef7bf217bfeb2bbfde3d76","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"0e5ae1ca4064fd8c33a3cf15a91440ab","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"417531904bbf6ab9cd704f77a53de586","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"204b9c8d54842debd8422b0b53ef0433","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"39c21d4aed5cf85e1776737630cb939c","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"38ae3959ca0a0d6d5c2a21bd9ac836c4","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"ae0d4ba62a5b334e1faef60bdb1c0fdf","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185616,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"6b41e9db32b71e2666732734d9ef5a67ce93c85acdfee75750d8a9fb757689f3","lane":"client-lint","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":133,"stamp":"739851458ec77d8799344917ab5a3c41","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}
Ci-Attestation: {"at":1795185947,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"4a10351870147ddc72d95c32caa53cf91a61c819e2c14de8158a4acf64569573","lane":"client-test-x86_64-unknown-linux-gnu","parents":["51a0d70969e159a3ac1b6ab2ea4f8087e6d6172a"],"secs":267,"stamp":"27c3a272fbdcc88adde6dbf5874aeef6","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"63228662a57d498eca3e16c4c025b9f14a8e8edc","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/build/libobs.ported-audio-info-queries+.h.c","libobs/build/libobs.ported-video-stats-queries+.h.c","libobs/build/ported-source-sets/audio-info-queries.json","libobs/build/ported-source-sets/video-stats-queries.json","libobs/cmake/rust-exports.d/obs-core-audio_info_queries.txt","libobs/cmake/rust-exports.d/obs-core-video_stats_queries.txt","libobs/obs-audio-info-queries-fields.c.h","libobs/obs-video-stats-queries-fields.c.h","rust/README.md","rust/obs-c-oracle/oracle/audio_controls.c","rust/obs-c-oracle/oracle/audio_info_queries.c","rust/obs-c-oracle/oracle/video_stats_queries.c","rust/obs-core/src/audio_info_queries.rs","rust/obs-core/src/ffi/audio_info_queries.rs","rust/obs-core/src/ffi/mod.rs","rust/obs-core/src/ffi/video_stats_queries.rs","rust/obs-core/src/lib.rs","rust/obs-core/src/video_stats_queries.rs","rust/obs-core/tests/obs_core/audio_info_queries.rs","rust/obs-core/tests/obs_core/audio_info_queries_parity.rs","rust/obs-core/tests/obs_core/main.rs","rust/obs-core/tests/obs_core/video_stats_queries.rs","rust/obs-core/tests/obs_core/video_stats_queries_parity.rs","test/cmocka/audio-info-queries-link-support.c","test/cmocka/build/rust-static-support.json","test/cmocka/video-stats-queries-link-support.c"],"head":"25d44027f887e814aad33d78e1994d0cf8bbd93f","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":"6e3d09658646b8f01c5803cc1f218fb21e3d25e030d408c63b11b9f41215663e","tree":"0501ce5aef36ca0bad8d028e091a04e78b3aea08"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 20, 2026 14:45
@rdoupe rdoupe changed the title obs-core: swap the video-statistics queries to safe Rust (Refs #5364) obs-core: swap audio-info and video-statistics queries to safe Rust (Refs #5363, #5364) Nov 20, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit 2878c64 Nov 20, 2026
46 checks passed
@rdoupe
rdoupe deleted the port/5363-5364-core-queries branch November 20, 2026 16:09
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.

1 participant