Repository navigation
obs-output: swap encoder group started count to safe Rust (Refs #5319) - #5375
Merged
Merged
Conversation
… (Refs #5319) Safe Rust mirrors of every assertion of the unchanged test_encoder_group_num_started.c on two recording groups (one lock and one unlock of the selected group's mutex, never nested; the exact count over the full u32 range, UINT32_MAX included, for the queried group and its complement for the other, with unrelated lifecycle state set and nothing changed; the value seen under the lock returned and the unlock's value left), plus the lock/read/unlock order and a proptest over any count and any rewrite in the lock or the unlock, against a todo!() core. Tier 3: the original obs-encoder-group-num-started.c.h and the new private adapters (obs-encoder-group-num-started-fields.c.h, beside the original in the core-output group) on two recording fixture groups in the oracle, comparing the result, every lock and unlock, and both groups byte for byte, with the count rewritten by the lock and/or the unlock, against a not-exported shim stub. The real-header layout and the adapters are checked; mutants (read before the lock, read after the unlock, no lock, no unlock, count clamped to i32::MAX or 16 bits) are caught. soldr cargo test -p obs-data --test obs-tests-core -- output::encoder_group_num_started test result: FAILED. 3 passed; 6 failed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obs_encoder_group_num_started (hidden, obs-internal.h) now comes from obs-output. Rust owns the decision: the group's mutex is taken once, num_encoders_started read once while it is held, and the mutex released once, so the value seen under the lock is returned over the full uint32_t range. The group is never NULL (the C precondition, kept). The mutex and the count stay in C behind private adapters (obs-encoder-group-num-started-fields.c.h); Rust never sees the group layout or its pthread mutex. The original moves to libobs.ported-encoder-group-num-started for the C reference. Tier 2: the unchanged test_encoder_group_num_started keeps testing the C source; its twin test_encoder_group_num_started_rust compiles the same fixture with the same recorder definitions, without the original, and runs its assertions on the Rust shim through the real adapters. No other target compiled the original, and the only other C definition of the name (output_interleave_fields_stub.c, test_output_interleave) never links the Rust archive, so no shared Rust-static support member is needed. The shim is hidden in both libraries and the adapters are never exported, so on Darwin the twin cannot bind either name to libobs.dylib (#5226); the registration test pins that. Same-name fakes: the interleave parity fixture's own definition of the name would collide with the export in obs-tests-core, so it now reaches its groups through the real shim; the oracle's single definition of each adapter forwards groups that are not its own to per-thread handlers the fixture installs. The bench's abort stand-in is dropped (and from ci/test_bench_libobs_stand_ins.py); the oracle defines the adapters there. soldr cargo test -p obs-data --test obs-tests-core -- output::encoder_group_num_started output::interleave test result: ok. 74 passed; 0 failed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795224770,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":95,"stamp":"fc03d1ed07056a4bad07c36a4ef62653","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224770,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":95,"stamp":"cc5d0456b85468f08c5b26bf70ddac65","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224770,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":95,"stamp":"109c469bba06e99c5deccc9d767df8a4","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224770,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":95,"stamp":"d6ad03e5cc7ba98a1e27e14426c3549f","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"general/all/client-lint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"09f0a34ae0a43afb576f2144300a604e","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224770,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":95,"stamp":"8f7161e8547866cd88bb8f965b4f3672","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"28de048c7adf743e50abda3a52481dd0","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"a623681cb5e0c33d4fd1603df36bfb3d","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"f5833fe28e03991f89918fbad86fc7ca","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"8aed974fea0c9502e9c1fd8bee9cd28c","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"0dbf2156909c1f313b43aa5877f2fc4f","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"94c41614869ad18cde4a5326fc6a08fa","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"67a79b9d5808b8d411a85de3e5d8ab32","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"7b60feec5d840c7c5eb8f0bc4221396c","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"cce92a44eb3bbbca4d0242a0025bb9d0","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"36ec0640de17d561bf8da314be47fb02","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"6db26000ede60f5e5c98a5fec8c5cbb6","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224675,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"2db147e7a0cfa82a5ad543a99845b7a73ed6e1b8452607d4b943b88a0eefd017","lane":"client-lint","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":103,"stamp":"f602562697dfa10e842db638505ece3b","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Ci-Attestation: {"at":1795224983,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"57ecf0d0dc8fcaf878678b516b5ce48223ab7dc8d448d4a5a8b0da0e960f096e","lane":"client-test-x86_64-unknown-linux-gnu","parents":["857bf31451adab51b0e4e9a2bf3a3dfccc75121c"],"secs":211,"stamp":"d111256363b3efd5ed92fcf532925611","tree":"d384a14b382f130096df19d4bb7b109e6b779b95","v":1,"via":"run"} Client-Checks: {"checks":{"base":"cbf2fd14f434a285f8cd985cb1572bef630272f3","coverage":"all-tracked-applicable-files","diff":["ci/test_bench_libobs_stand_ins.py","libobs/build/libobs.core-output+.h.c","libobs/build/libobs.ported-encoder-group-num-started+.h.c","libobs/build/ported-source-sets/encoder-group-num-started.json","libobs/cmake/rust-hidden.d/obs-output-encoder_group_num_started.txt","libobs/obs-encoder-group-num-started-fields.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_encoder_group_num_started_swap_is_registered.rs","rust/obs-build/tests/native/registration/rust-static/cases/core-relinked/test_encoder_group_num_started_rust.json","rust/obs-c-oracle/benches/port_comparison.rs","rust/obs-c-oracle/oracle/encoder_group_num_started.c","rust/obs-output/src/encoder_group_num_started.rs","rust/obs-output/src/ffi/encoder_group_num_started.rs","rust/obs-output/src/ffi/mod.rs","rust/obs-output/src/lib.rs","rust/obs-output/tests/output/encoder_group_num_started.rs","rust/obs-output/tests/output/encoder_group_num_started_parity.rs","rust/obs-output/tests/output/interleave_parity.rs","rust/obs-output/tests/output/main.rs","test/cmocka/build/test-graph.json","test/cmocka/encoder-group-num-started-record-support.c"],"head":"9ed7db1611e7a57179a6da509b29aa522c52808c","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":"96301fee900b7d230d2bcc5f90308b3f31a111458f3eefb4f787c1aa4eee1f52","tree":"d384a14b382f130096df19d4bb7b109e6b779b95"}}
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.
Refs #5319
Swaps the hidden accessor
obs_encoder_group_num_started(obs-internal.h, noEXPORT) into obs-output. Rust owns the decision: the group's mutex is taken once,num_encoders_startedis read once while it is held, and the mutex is released once, so the value seen under the lock comes back over the fulluint32_trange. The group is never NULL (the C precondition, kept). The mutex and the count stay in C behind three private adapters (libobs/obs-encoder-group-num-started-fields.c.h), so Rust never sees the group layout or its pthread mutex. The original moves tolibobs.ported-encoder-group-num-startedfor the C reference. No intentional behavior differences. Not user-visible, so no features-ledger line.Inventory (callers and same-name fakes)
obs-encoder-set-group.c.handobs-output-interleave.c.hare C inside libobs and now resolve to the hidden Rust export. The Rust interleaver's import (rust/obs-output/src/ffi/output_interleave.rs) is unchanged.test/cmocka/output_interleave_fields_stub.cdefines the name fortest_output_interleave, which never linkslibobs_rust-static. It stays as it is, and a registration test pins that no target compiles the stub together with the Rust archive.rust/obs-output/tests/output/interleave_parity.rshad its own#[no_mangle]copy of the name, which would collide with the export inobs-tests-core. It now reaches its groups through the real shim: the oracle has one definition of each adapter, and it forwards any group it does not own to per-thread handlers that the interleave fixture installs (oracle_encoder_group_num_started_foreign, thescene_enum_items.cshape). The recordedNumStartedevent is unchanged, and the handlers also check that the read happens under the group lock.rust/obs-c-oracle/benches/port_comparison.rs: the abort stand-in is dropped, along with its entry inci/test_bench_libobs_stand_ins.py, because a workspace crate now exports the name. The oracle defines the adapters there.Darwin fixture binding (#5226)
The shim is hidden in both libraries and the adapters are never exported, so libobs.dylib can bind neither of them for the twin. From the cross-linked Mach-O artifacts of
ci/windows_link_check.py:obs.dylib:llvm-nm -gUlists 1,904 exports and 0*group_num_started*names;_obs_encoder_group_num_startedand the three adapters arenon-external (was a private external).test_encoder_group_num_started_rust(arm64):_obs_encoder_group_num_startedis defined locally (from the Rust archive). Its disassembly calls the local_obs_encoder_group_num_started_{lock,read,unlock};lockandunlockbranch to the test's_encoder_group_count_record_{lock,unlock}, andreadisldr w0, [x0, #0x60].A registration test pins the source side: the name is in
rust-hidden.d, it is in norust-exports.dfragment, the adapters have noEXPORT, and the twin keeps the C target's recorder definitions.RED (857bf31)
Tier 1 mirrors every assertion of
test_encoder_group_num_started.c: one lock and one unlock of the selected group's mutex, never nested; the exact count for 0, 1, 2, 32,UINT32_MAX - 1andUINT32_MAXwith the complement in the other group; unrelated lifecycle state set and nothing changed; the snapshot under the lock returned and the unlock's value left. It adds the lock, read, unlock order and a proptest, all run against atodo!()core. Tier 3 runs the original and a not-exported stub on two recording fixture groups (oracleencoder_group_num_started.c). It compares the result, each lock and unlock, and both groups byte for byte, with the count rewritten in the lock and/or the unlock. It also includes real-header layout and adapter checks, and these mutants: read before the lock, read after the unlock, no lock, no unlock, count clamped toi32::MAXand to 16 bits.(The 3 passes are the layout/adapter check, the original's characterization and the mutant check, which exercise only the C side.)
GREEN (b8329ce)
OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'encoder_group|output_interleave'): exported symbols C vs Rust IDENTICAL (1769). OFF/C reference: 1064/1064 passed, repeat 11/11. ON/hybrid: 1064/1064 passed, repeat 11/11. I ran the binaries from the kept volume directly to prove the cases ran rather than skipped. On bothlibobsandlibobs-c-reference:test_encoder_group_num_started2 passed,test_encoder_group_num_started_rust2 passed,test_output_interleave30 passed,test_encoder_group_move4 passed.uv run --no-project ci/windows_link_check.py: all category binaries linked, and the Windows MSVC and Darwin hybrid libobs plus every configured*_rustfixture, includingtest_encoder_group_num_started_rust, linked as well (link only, nothing executed)../lint: ok.Test cost: the 9 new tests together take under 0.01 s at
OBS_PARITY_CASES=reducedin the debug build. Peak RSS for the module is 37 MB over 21 runs. They start no threads of their own../push: client-lint (six-target clippy and Dylint) ok, client-test ok; the optional Swift lane is not available here, and the head is unsigned, so the regular PR checks run.Not verified locally: running natively on macOS or Windows (CI runs those).
🤖 Generated with Claude Code