Skip to content

obs-source: port obs_source_get_last_async_ts to Rust (Fixes #5766) - #5767

Merged
rdoupe merged 4 commits into
masterfrom
port/5766-last-async-ts
Nov 26, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/5766-last-async-ts

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5766

What changes

obs_source_get_last_async_ts(), the hidden libobs getter the source profiler reads for an async video source each tick, moves from libobs/obs-source.c.h to obs-source::async_flag_getters, beside the async flag getters.

Commits, in order:

  1. libobs: the body moves verbatim into libobs/obs-source-async-last-ts-getter.c.h, still in the live libobs.core-source group. No behavior change.
  2. test: new cmocka characterization test/cmocka/test_source_last_async_ts.c on a test-owned struct obs_source: the getter answers async_last_rendered_ts exactly (0, ordinary timestamps, every single bit, UINT64_MAX) whatever the other bytes hold, writes no byte and logs nothing. The getter is hidden (obs-internal.h, no EXPORT), so the test compiles the extracted C file into itself, as test_source_texcoords_centered_setter does (obs-source: port obs_source_set_texcoords_centered to Rust (Fixes #5599) #5600).
  3. test: RED. Tier 1 mirrors against a todo!() core.
  4. obs-source: GREEN.
    • Safe core async_flag_getters::last_async_ts and a hidden shim (rust-hidden.d/obs-source-source_async_flag_getters.txt). The shim reads through a new address adapter, obs_source_async_last_ts_field(), added to the existing obs-source-async-flag-fields.c.h. No NULL check, as in the C (it dereferences).
    • The extracted C moves to the existing reference-only group libobs.ported-source-async-flag-getters (and to that group's PCH).
    • The oracle's source-profiler stand-in of the same name is gone. The obs-core shim test now reaches the Rust getter over the real zeroed oracle source, the same way obs_source_get_output_flags does since rust: port extracted obs_source_get_output_flags to obs-source #5340.
    • The module's Rust-static link stubs (source-async-flag-getter-link-stubs.c, 28 *_rust step tests) gain the new adapter, aborting like the existing one.
    • Registration test in obs-build; rust/README row.

No public header, existing C test, WebSocket or workflow change. No intentional differences. Tier 4 does not apply.

Tests

  • Tier 1 (rust/obs-source/tests/source/async_flag_getters.rs): edge values, every bit, neighbours untouched.
  • Tier 2: the new test_source_last_async_ts, test_source_profiler and the 28 Rust-static step tests that link the stubs, on hybrid libobs and the C reference.
  • Tier 3 (async_flag_getters_parity.rs): the original C and the Rust export on noise-filled real-layout fixtures (three noise bytes, edge values, every bit, and a proptest over noise and timestamp), with the full source snapshot compared after every read, and the adapter's field offset against the real header's offsetof. Mutation check: a shim that clears bit 0 fails last_ts_characterized_edges and last_ts_matches_c (reverted).

Evidence

RED (test: RED ...):

soldr cargo test -p obs-data --test obs-tests-core -- async_flag_getters::
test source::async_flag_getters::last_async_ts_writes_nothing ... FAILED
test source::async_flag_getters::last_async_ts_answers_the_stored_timestamp ... FAILED
panicked at rust/obs-source/src/async_flag_getters.rs:41:5: not yet implemented: #5766
test result: FAILED. 4 passed; 2 failed; 0 ignored; 0 measured; 6841 filtered out

GREEN:

soldr cargo test -p obs-data --test obs-tests-core -- async_flag_getters source_profiler
test result: ok. 52 passed; 0 failed

soldr cargo test -p obs-studio-rust --test obs-tests-app -- canonical_source_last_async_ts canonical_source_async_flag
test result: ok. 2 passed; 0 failed

./lint
== lane lint: ok

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_source_last_async_ts|test_source_profiler|test_source_async_flag|_steps_rust|test_source_init_context_rust'
IDENTICAL (1769 symbols)
100% tests passed, 0 tests failed out of 1121   (each build: hybrid and C reference)
100% tests passed, 0 tests failed out of 48     (the selected tests, each build)

🤖 Generated with Claude Code

rdoupe and others added 4 commits November 26, 2026 03:23
Moves the source profiler's async timestamp getter unchanged from
obs-source.c.h into libobs/obs-source-async-last-ts-getter.c.h, a member
of the live core-source unity group. No Rust, no behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New cmocka test on a test-owned struct obs_source: the getter answers
async_last_rendered_ts exactly (0, ordinary timestamps, every single bit,
UINT64_MAX) whatever the other bytes hold, writes no byte of the source
and logs nothing. The getter is hidden in libobs (obs-internal.h, no
EXPORT), so the test compiles its extracted C file into itself, as
test_source_texcoords_centered_setter does. NULL is outside the C
contract and is not tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1 mirrors of test_source_last_async_ts.c against a todo!() stub,
async_flag_getters::last_async_ts: the stored timestamp exactly for edge
values and every single bit, and nothing written to its neighbours.

RED: soldr cargo test -p obs-data --test obs-tests-core -- async_flag_getters::
gives 4 passed, 2 failed (both panic in the todo!()).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The getter joins async_flag_getters beside the async flag reads. The
shim reads async_last_rendered_ts through a new address adapter,
obs_source_async_last_ts_field(), in the existing async flag fields file,
with no NULL check (the C dereferences), no write and no log. It stays
hidden as the C was (obs-internal.h, no EXPORT): the name goes into a new
rust-hidden.d fragment for the module. The extracted C moves to the
reference-only group libobs.ported-source-async-flag-getters.

The source-profiler stand-in of the same name in the oracle is gone: the
obs-core shim test now reaches the Rust getter, over the same real
zeroed oracle source as the output flags. The Rust-static link stubs of
the module gain the new adapter, aborting like the existing one.

Tier 1 passes; Tier 3 compares the original C and the Rust export on
noise-filled real-layout fixtures (edge values, every bit, a proptest),
the full source snapshot after each read, and the adapter's field offset
against the real header. A shim that clears bit 0 fails parity (reverted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795683304,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":94,"stamp":"a9e743c053ca668df49966173e092b4c","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683304,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":94,"stamp":"ba607311e7f77732ca823a3d59bce3b9","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683304,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":94,"stamp":"c207e600ce8b7247b3b825eb00588a52","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683304,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":94,"stamp":"951c16dd7551a992cc14872ba0c7c7eb","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"general/all/client-lint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"67e40033f3795eb62bd2310607a24ba2","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683304,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":94,"stamp":"80ff49e819ece30f74b8fa45c9d16d8f","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"46efdcaa10e50d46b72a486999af6aa0","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"55f1e3f86bf0a789f45f097e0b0cdf58","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"454665bd78d4e812bd23fa1372a2534c","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"2c8c2893e2ddea292a45b1a984a3a1dc","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"27a0284e6cdd655361d9c3707cfa6afd","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"320893977cd24ed96e714e8eae5196c3","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"c5f6760317aadf87360234a240367931","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"b1fac1a0b231a55f014f6091c5082aae","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"6a3d8562b0ca9cccbb2b55999e4ac7a7","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"518c7ca5ab1bef98785c9c1c9361bfbb","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"a830f7e45e91c2898709c59846e342e2","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683209,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"0780a1574166fd5e0db798c875e172c843c2312e4666f4d607e380a37dd941e2","lane":"client-lint","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":98,"stamp":"80b129d7f8e59d44fa1646bff51b0349","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}
Ci-Attestation: {"at":1795683594,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"7813d4f2031da2d4cfc13b22f255164d27211f733757d954e8b3e4bbefe2898e","lane":"client-test-x86_64-unknown-linux-gnu","parents":["ae40452d893dd6dbdb992315b3f96aa98a84bd8f"],"secs":289,"stamp":"2c90813d0e9dc62ac638f4b2b5c14bda","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"69df7dfd1d68b826d596ed525ae0e4e5588e8eb8","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.ported-source-async-flag-getters+.h.c","libobs/cmake/rust-hidden.d/obs-source-source_async_flag_getters.txt","libobs/obs-internal.h","libobs/obs-source-async-flag-fields.c.h","libobs/obs-source-async-last-ts-getter.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_last_async_ts_swap_is_registered.rs","rust/obs-c-oracle/oracle/source_async_flag_getters.c","rust/obs-c-oracle/oracle/source_profiler_host.c","rust/obs-source/src/async_flag_getters.rs","rust/obs-source/src/ffi/source_async_flag_getters.rs","rust/obs-source/tests/source/async_flag_getters.rs","rust/obs-source/tests/source/async_flag_getters_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/source-async-flag-getter-link-stubs.c","test/cmocka/test_source_last_async_ts.c","test/cmocka/tests.d/test_source_last_async_ts.cmake"],"head":"4a16be1d976fa7fa76a7070fbff1160118dc26d8","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":"08653b2970c01f5b6d927b439406e96daf8f89d56cc6a9b51ab0a40cb31951f9","tree":"684a4c7723f7471bb9905b63a885c1dce8c004ac"}}
@rdoupe
rdoupe marked this pull request as ready for review November 26, 2026 10:11
@rdoupe
rdoupe requested a review from zackees as a code owner November 26, 2026 10:11
@rdoupe
rdoupe enabled auto-merge November 26, 2026 10:11
@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
Merged via the queue into master with commit e8cbea4 Nov 26, 2026
135 of 139 checks passed
@rdoupe
rdoupe deleted the port/5766-last-async-ts branch November 26, 2026 11:13
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 obs_source_get_last_async_ts to obs-source

1 participant