Skip to content

obs-source: port obs_source_get_frame and obs_source_release_frame to Rust (Fixes #5757) - #5758

Merged
rdoupe merged 4 commits into
masterfrom
port/5757-get-release-frame
Nov 26, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/5757-get-release-frame

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5757.

Ports the exported async-frame consumer pair obs_source_get_frame() and obs_source_release_frame() from libobs/obs-source.c.h to obs-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

  1. libobs: extract ... verbatim moves both functions unchanged into libobs/obs-source-get-release-frame.c.h, a member of the live core-source group. No behavior change.
  2. test: characterize ... adds test_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; otherwise cur_async_frame is 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 taking async_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, clears prev_frame and marks the first cache slot holding the frame unused (characterized, not endorsed: zero goes to -1). async_mutex is free after every call (probed from another thread, as it is recursive).
  3. test: RED adds Tier 1 (obs_source::get_release_frame over a recording model: every step's order and the lock's scope) against todo!() cores.
  4. obs-source: port implements the core and the exports. The mutex, the slot, the atomics, obs_source_frame_destroy() and remove_async_frame() stay C in the new adapter file 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 cmocka consumers link through source-get-release-frame-link-support.c (in rust-static-support.json). The do-nothing obs_source_release_frame() and remove_async_frame() stand-ins in rust/obs-c-oracle/oracle/source_deinterlace_links.c are 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 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 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!()):

soldr cargo test -p obs-data --test obs-tests-core get_release_frame::
test result: FAILED. 0 passed; 10 failed; 0 ignored; 0 measured; 6814 filtered out
(each: not yet implemented: obs_source_get_frame / obs_source_release_frame safe core (#5757))

GREEN (commit 4):

soldr cargo test -p obs-data --test obs-tests-core get_release_frame
test result: ok. 13 passed; 0 failed   (10 Tier 1 + 3 Tier 3: characterized, mutants, proptest)
soldr cargo test -p obs-studio-rust --test obs-tests-app -- canonical_source_get_release_frame
test result: ok. 1 passed; 0 failed
./lint   -> lane lint: ok

Mutation checks on the safe core (each reverted), all three Tier 3 tests fail on each:

  • get takes the frame without adding a reference;
  • a NULL source no longer destroys the frame;
  • async_mutex released 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|...'):

  • characterization commit: C reference 1118/1118 and hybrid 1118/1118 passed; repeats passed.
  • GREEN, with test_source_deinterlace, test_async_delay_pacing and test_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).
  • The new binary run directly from that build tree, on each library: 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-source crate description and the native.rs registration list. After the rebase, get_release_frame 13/13 passed, the get_release_frame and frame_copy registration tests 2/2 passed, and ./lint is ok; PR CI reruns Tier 2.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner November 26, 2026 03:09
@rdoupe
rdoupe force-pushed the port/5757-get-release-frame branch 2 times, most recently from 880122d to 37c0f8d Compare November 26, 2026 05:40
@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 26, 2026
@rdoupe
rdoupe force-pushed the port/5757-get-release-frame branch from 37c0f8d to 909c60b Compare November 26, 2026 08:04
@rdoupe
rdoupe enabled auto-merge November 26, 2026 08:04
@rdoupe

rdoupe commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

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: obs-tests-core get_release_frame 13/13, frame_wrappers 11/11, deinterlace 180/180; registration test ok; ./lint ok; Tier 2 1121/1121 on the C reference and hybrid libobs, then test_source_get_release_frame|test_source_frame_wrappers|deinterlace|test_async_delay repeated (20/20 each).

@rdoupe
rdoupe force-pushed the port/5757-get-release-frame branch from 909c60b to 0030310 Compare November 26, 2026 10:08
@rdoupe

rdoupe commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto master after #5765 merged (it conflicted in the obs-source crate description). Re-verified on the new base: ./lint ok; obs-tests-core get_release_frame/frame_wrappers/show_preloaded/deinterlace 216/216; Tier 2 test_source_get_release_frame|test_source_frame_wrappers|show_preloaded|deinterlace|test_async_delay repeated 5x, 21/21 passed.

@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this to In merge queue in obs-rust Multiview Nov 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 26, 2026
@rdoupe
rdoupe force-pushed the port/5757-get-release-frame branch from 0030310 to ad4fabe Compare November 26, 2026 11:53
rdoupe and others added 4 commits November 26, 2026 13:56
…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"}}
@rdoupe
rdoupe force-pushed the port/5757-get-release-frame branch from ad4fabe to 28a3005 Compare November 26, 2026 19:08
@rdoupe

rdoupe commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto master (7 commits behind, clean). Re-verified: ./lint ok; obs-tests-core get_release_frame/frame_wrappers/show_preloaded/filter_set_order 35/35. The previous Windows Tier 2 attempts were cancelled at the job's 25-minute limit, not failed: the C build compiled the same 9,147 units as a green run but took ~16 min instead of ~5, since the obs-internal.h change misses every cached libobs object and a cancelled job never saves its cache. Fresh run on the new head.

@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
Merged via the queue into master with commit 529d2d9 Nov 26, 2026
46 checks passed
@rdoupe
rdoupe deleted the port/5757-get-release-frame branch November 26, 2026 20:09
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In merge queue to Done in obs-rust Multiview Nov 26, 2026
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_frame and obs_source_release_frame to obs-source

1 participant