Repository navigation
obs-source: port obs_source_get_frame and obs_source_release_frame to Rust (Fixes #5757) - #5758
Conversation
880122d to
37c0f8d
Compare
37c0f8d to
909c60b
Compare
|
Rebased onto master after #5761 merged (it conflicted in the core-source group, obs-internal.h neighbours, lib.rs/main.rs/ffi mod lists and the obs-source description). Re-verified on the new base: |
909c60b to
0030310
Compare
|
Rebased onto master after #5765 merged (it conflicted in the obs-source crate description). Re-verified on the new base: |
0030310 to
ad4fabe
Compare
…batim (Refs #5757) Moves the two exported async-frame consumer functions, with the comment above obs_source_get_frame(), unchanged into libobs/obs-source-get-release-frame.c.h in the live core-source group. remove_async_frame() stays in obs-source.c.h (obs-internal.h declares it), and its callers there use the exported functions through obs.h. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(Refs #5757) test_source_get_release_frame runs on stack source fixtures against the hybrid libobs and the C reference: get_frame of a NULL source and of an empty slot return NULL; otherwise cur_async_frame is taken (the slot emptied) with one added reference and nothing else touched. release_frame of a NULL frame does nothing and a NULL source destroys the frame whatever its references, neither taking async_mutex (another thread holds it while they run); the last reference destroys the frame and leaves the cache alone; any other count, zero included, clears prev_frame and marks the first cache slot holding the frame unused. async_mutex is free after each call (probed from another thread, as it is recursive). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (Refs #5757) Adds obs_source::get_release_frame (the Host trait over the source and frame operations, get_frame and release_frame against todo!()) and its Tier 1 cases over a recording model, mirroring every test_source_get_release_frame case plus the order of each step and the lock's scope: the NULL source diagnostic, the take with one reference under async_mutex, NULL frames ignored, a NULL source destroying without the lock, the last reference destroying under it, and any other count returning the frame to the cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Rust (Fixes #5757) The exports run the safe core obs_source::get_release_frame in the C's order. get_frame: a NULL source logs the obs_source_valid() line and returns NULL; otherwise async_mutex is taken, cur_async_frame taken (the slot left NULL) with one added reference, and the mutex released. release_frame: a NULL frame does nothing; a NULL source destroys the frame without locking; otherwise, under async_mutex, one reference is dropped and the frame destroyed at zero, or else returned to the async cache. The mutex, the slot, the atomics, obs_source_frame_destroy() and remove_async_frame() stay C in obs-source-get-release-frame-fields.c.h; remove_async_frame() moves there unchanged from obs-source.c.h so the adapters' closure is one file, which Rust-static consumers link through source-get-release-frame-link-support.c. The do-nothing obs_source_release_frame() and remove_async_frame() stand-ins of oracle/source_deinterlace_links.c are gone: the Rust export and the oracle's compiled adapters now provide them. The extracted C moves unchanged to the reference-only group libobs.ported-source-get-release-frame. Tier 3 runs the original C and the Rust exports over real sources and frames on the same adapters, with the mutex lock and unlock and the frame destroy recorded, and compares each call's result, the recorded calls, the diagnostic and the state left (current frame, each frame's references and prev_frame, every cache slot), pinning the characterized answers, rejecting four export mutants, and running a proptest over call sequences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795719820,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":95,"stamp":"fac4fcb66ed9b4d2f744393b63f9304d","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719820,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":95,"stamp":"0ffd6bc3a50f34692715fd11d8d13e27","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719820,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":95,"stamp":"4805b5961f97f679b0803bb7437553c2","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719820,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":95,"stamp":"d166753b8e3a455d4ee18a760ec3bb18","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"general/all/client-lint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"a8974b46fb27af02662d04efe6c10b13","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719820,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":95,"stamp":"ffedf5ff4d67f6291843d7cad5faf1fe","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719725,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"63eab31afb83cde287231e8d4e9e9bbf","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719725,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"b33a74b372e685870c44b4bce42a167d","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"5ef8c01c5eb294269dd8dd1f481042fa","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"dd8928b5ae4c7b834ed09fd39aade793","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"03699469c5a26bb97609620c26011236","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"7230f07d6c678be326ffd02b23049b88","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"22f37fc6cba159bbeac4cdd89956a71e","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"4780c5ca27a8cf724ba2a93b63e6882e","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"c0aa473b63741459eb2a1f2978490a51","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"5338416a13bcca199caedceedf0f247a","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"f70c010302d0b1a6b790ad155f4f021b","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795719724,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"3b0a3b8828c4f061d1116bef64d2fafcdfbb8ccbb2105258f83716fefd729c81","lane":"client-lint","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":72,"stamp":"2e79c37bae06747dae661641d595de8a","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Ci-Attestation: {"at":1795720080,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"db8946eb99f8e7ae130bb0e4a700ff7e93f0844f9e694a86b5085a78ec80e8b6","lane":"client-test-x86_64-unknown-linux-gnu","parents":["a59c52b93e5724daea3f63d947bb0c1fab84d2ad"],"secs":260,"stamp":"a114bf1c0970131348fca49e3fe3b5c9","tree":"2bfd975e3701685866bcae1cb2481511d970a640","v":1,"via":"run"} Client-Checks: {"checks":{"base":"7ca20456e78c60f8eace82f435605881cb28f684","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-get-release-frame+.h.c","libobs/build/ported-source-sets/source-get-release-frame.json","libobs/cmake/rust-exports.d/obs-source-source_get_release_frame.txt","libobs/obs-internal.h","libobs/obs-source-get-release-frame-fields.c.h","libobs/obs-source-get-release-frame.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_get_release_frame_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-get-release-frame.list","rust/obs-c-oracle/oracle/source_deinterlace_links.c","rust/obs-c-oracle/oracle/source_get_release_frame.c","rust/obs-source/Cargo.toml","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_get_release_frame.rs","rust/obs-source/src/get_release_frame.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/get_release_frame.rs","rust/obs-source/tests/source/get_release_frame_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/rust-static-support.json","test/cmocka/build/test-graph.json","test/cmocka/source-get-release-frame-link-support.c","test/cmocka/test_source_get_release_frame.c","test/cmocka/tests.d/test_source_get_release_frame.cmake"],"head":"0d0a7bb8ea907fdd62e3eef6e5e2f20b63d3735a","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":"a520d9545f669eb364d0b3dc3f05f954aa285203e414771ff50693362ca9f8ce","tree":"2bfd975e3701685866bcae1cb2481511d970a640"}}
ad4fabe to
28a3005
Compare
|
Rebased onto master (7 commits behind, clean). Re-verified: |
Fixes #5757.
Ports the exported async-frame consumer pair
obs_source_get_frame()andobs_source_release_frame()fromlibobs/obs-source.c.htoobs-source. Every caller (obs_source_update_async_video, the deinterlacer, the async delay filter) takes a frame with one and gives it back with the other.Commits
libobs: extract ... verbatimmoves both functions unchanged intolibobs/obs-source-get-release-frame.c.h, a member of the live core-source group. No behavior change.test: characterize ...addstest_source_get_release_frame(cmocka, stack source fixtures, 10 cases) against hybrid libobs and the C reference: get of a NULL source or an empty slot returns NULL; otherwisecur_async_frameis taken (slot emptied) with one added reference and nothing else touched. Release of a NULL frame does nothing, and a NULL source destroys the frame whatever its references, neither takingasync_mutex(another thread holds it while they run); the last reference destroys the frame and leaves the cache slot alone; any other count, zero included, clearsprev_frameand marks the first cache slot holding the frame unused (characterized, not endorsed: zero goes to -1).async_mutexis free after every call (probed from another thread, as it is recursive).test: REDadds Tier 1 (obs_source::get_release_frameover a recording model: every step's order and the lock's scope) againsttodo!()cores.obs-source: portimplements the core and the exports. The mutex, the slot, the atomics,obs_source_frame_destroy()andremove_async_frame()stay C in the new adapter fileobs-source-get-release-frame-fields.c.h;remove_async_frame()moves there unchanged fromobs-source.c.h, so the adapters' closure is one file, which Rust-static cmocka consumers link throughsource-get-release-frame-link-support.c(inrust-static-support.json). The do-nothingobs_source_release_frame()andremove_async_frame()stand-ins inrust/obs-c-oracle/oracle/source_deinterlace_links.care removed, since the Rust export and the oracle's compiled adapters now define them (as obs-source: Port the source type lookup #4608). The extracted C moves to the reference-only grouplibobs.ported-source-get-release-frame.Tier 3 runs the original C and the Rust exports over real sources and frames on the same production adapters, with the mutex lock/unlock and the frame destroy routed through recorders, and compares each call's result, the recorded calls, the diagnostic, and the state left (current frame, each frame's references and
prev_frame, every cache slot). It pins the characterized answers, rejects four export mutants, and runs a proptest over call sequences.No intentional differences. No public-header, existing-C-test, WebSocket or workflow edits. Tier 4 does not apply.
Evidence
RED (commit 3, cores
todo!()):GREEN (commit 4):
Mutation checks on the safe core (each reverted), all three Tier 3 tests fail on each:
async_mutexreleased before the reference is dropped (destroy / cache return outside the lock).Export mutants inside the Tier 3 test, each rejected: no diagnostic for a NULL source; no added reference; destroy without the lock; NULL source ignored.
Tier 2 (
OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_source_get_release_frame|...'):test_source_deinterlace,test_async_delay_pacingandtest_deinterlace_mode_load: C reference 1118/1118 and hybrid 1118/1118 passed, repeats 6/6 on each; 622 ported C objects excluded from production libobs (621 before); exported symbols identical C vs Rust (1769).tests: 10 test(s) run. PASSED 10 test(s)for both hybrid (libobs/libobs.so.30) and the C reference (libobs-c-reference/libobs.so.30), on both commits.Rebased onto master after the frame_copy port (#5741) merged: conflicts only in the
obs-sourcecrate description and thenative.rsregistration list. After the rebase,get_release_frame13/13 passed, the get_release_frame and frame_copy registration tests 2/2 passed, and./lintis ok; PR CI reruns Tier 2.🤖 Generated with Claude Code