Skip to content

obs-output: swap output total-bytes query to safe Rust (Refs #5208) - #5223

Merged
rdoupe merged 2 commits into
masterfrom
port/5208-output-total-bytes
Nov 19, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/5208-output-total-bytes

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #5208

Moves obs_output_get_total_bytes() to obs-output in hybrid libobs. The prerequisite extraction (#5207) left it alone in libobs/obs-output-total-bytes-query.c.h.

What changes

  • obs-output::output_total_bytes: safe core over a Host trait. The order matches the C: the NULL diagnostic, the callback check before the delay loads, short-circuit delay_active && !delay_capturing, then one dispatch.
  • obs-output::ffi::output_total_bytes: the export. Only after the NULL check does the hidden adapter obs_output_total_bytes_fields() (new obs-output-total-bytes-fields.c.h, declared in obs-internal.h) hand over the addresses of info.get_total_bytes, delay_active, delay_capturing and context.data. Nothing is copied up front. The callback slot is read again at dispatch, as the C reads it twice, and context.data is read at the call. The delay flags are AtomicBool SeqCst loads, the same as os_atomic_load_bool. struct obs_output is not mirrored.
  • The original C now builds only in the reference-only group libobs.ported-output-total-bytes+. Its two static inline delay helpers come from obs-output-total-bytes-query-support.c.h, an unchanged copy of the ones in obs-output.c.h, because that group no longer shares a unity build with obs-output.c.h. The oracle compiles the same two files.
  • Per-unit fragments: rust exports, ported source set, link support for standalone *_rust consumers, native registration test, README row.

No public header, existing C test, workflow or WebSocket edits. No new test executable: the tests are modules in obs-tests-core.

Evidence

RED (5cc82e0, safe-core mirrors against the stub):

soldr cargo test -p obs-data --test obs-tests-core output_total_bytes
  mirrors_callback_delay_matrix ... FAILED   left: (0, [])  right: (0, [Callback])
  mirrors_null_output ... FAILED
test result: FAILED. 0 passed; 2 failed

GREEN (c37ff17):

  • soldr cargo test -p obs-data --test obs-tests-core output_total_bytes: 4 passed (2 Tier 1 mirrors, a real-header layout check, and the Tier 3 differential: all 48 valid flag combinations × 6 edge results plus 256 proptest cases, original C against Rust, with an independent expected-value assertion).
  • Killed mutation: dropping !host.delay_capturing() from the core makes edge_matrix_matches_c fail at flags=0xd (left [0, 0, 0, 0, …], right [0, 1, 0, 1, …]).
  • soldr cargo test -p obs-studio-rust --test obs-tests-app canonical_output_total_bytes: 1 passed.
  • Tier 2 (OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 --tests 'test_output_total_bytes_query|test_encoder_output_getters'): the full suite passes, 1026/1026 on hybrid (ON) and on the C reference (OFF). Both selected tests pass 3× on each. libobs exported symbols, C vs Rust: IDENTICAL (1769 symbols).
  • OBS_CMOCKA_LINK=true uv run --no-project ci/windows_link_check.py: Windows MSVC and macOS arm64 hybrid libobs and all 55 *_rust fixtures link.
  • ./lint: ok.

No intentional differences. Tier 4 does not apply.

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 19, 2026 05:09
…Refs #5208)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obs_output_get_total_bytes() moves to obs-output. The hidden
obs_output_total_bytes_fields() adapter lends the callback slot, the two
delay flags and context.data, formed only after the NULL check, so each
read stays where the C reads it. The original C stays in a reference-only
unity group and in the oracle for the differential test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795083185,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"c2ca72b4a6605548035815d4e08208dc","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083185,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"7896c9bc78dbe2fa913a0901aacdaf46","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083185,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"c118b7ce5c9dee09264a1cad01b0599c","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083185,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"9c78a530aa3d93124a56da9f5b74a8a6","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083087,"gate":"general/all/client-lint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"714ad6e38e2df6da4f264710a6022c34","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083185,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"32f8b9e5dc4e127946413263d6485855","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"9d95d1cea5d4c14226c7d929d310223a","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"1849ad21e700d4b719fd6a627ae2b165","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"bb092cd54756b29544d3d82c0a6e32e5","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"3c311ac94c2f3371ed4fc01408396ad4","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083087,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"adea2a970e2e63e4a8a825c120113d57","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083087,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"2af1858c064e9464eb5c9e552a02119f","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"74df2eb97655093cb7bdc978f24cccc6","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"37e3b8ab00bcda04a75faeee3f9952fc","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083087,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"224bd85ee3b4c670f62c56655668ac79","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083088,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"c9197a59db0826a54b53d5384b4cb246","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083087,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"727b41fbd36def3e20b633e64b4b1a6d","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083087,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e4fb482ee4106c2a46fe7e7be370ed2b0a24ca78e6ff36a2e7d2462f2b387d16","lane":"client-lint","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":96,"stamp":"28ec1b6a1c1b10c54eac25eda0d94e92","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}
Ci-Attestation: {"at":1795083422,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"3694626f353701b531ec1fe85e272ed98af546a39d9de3ab32cb6bbdbb186a0f","lane":"client-test-x86_64-unknown-linux-gnu","parents":["5cc82e0f0dca8b27593a82e8e6af8cdc2f9e362c"],"secs":237,"stamp":"3adb475a49a2a8917ffc49b711a5ba98","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"c037c2b3ba6db8681433cda92f7d828188cf60af","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-output+.h.c","libobs/build/libobs.ported-output-total-bytes+.h.c","libobs/build/ported-source-sets/output-total-bytes.json","libobs/cmake/rust-exports.d/obs-output-output_total_bytes.txt","libobs/obs-internal.h","libobs/obs-output-total-bytes-fields.c.h","libobs/obs-output-total-bytes-query-support.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_output_total_bytes_swap_is_registered.rs","rust/obs-c-oracle/oracle/output_total_bytes.c","rust/obs-output/src/ffi/mod.rs","rust/obs-output/src/ffi/output_total_bytes.rs","rust/obs-output/src/lib.rs","rust/obs-output/src/output_total_bytes.rs","rust/obs-output/tests/output/main.rs","rust/obs-output/tests/output/output_total_bytes.rs","rust/obs-output/tests/output/output_total_bytes_parity.rs","test/cmocka/output-total-bytes-link-support.c","test/cmocka/tests.d/output_total_bytes_link_support.cmake"],"head":"d87b9f2a4f7f5f303326df88070134e20238bfcc","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":"d0bf592d2999a87cdfeef770dff826efa6a2ea1ce2dc175d0421fc44b753f34b","tree":"5f5825c58ae1f13aa0f5345ff0b2fe132c07f127"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 19, 2026 10:17
@rdoupe
rdoupe enabled auto-merge November 19, 2026 10:17
@rdoupe
rdoupe added this pull request to the merge queue Nov 19, 2026
Merged via the queue into master with commit 44886e5 Nov 19, 2026
83 of 85 checks passed
@rdoupe
rdoupe deleted the port/5208-output-total-bytes branch November 19, 2026 12: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