Skip to content

obs-core: Port the video stop check to Rust - #4671

Merged
zackees merged 4 commits into
masterfrom
fix/rust-port-port-the-graphics-task-739
Nov 11, 2026
Merged

zackees merged 4 commits into
masterfrom
fix/rust-port-port-the-graphics-task-739

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4670
Refs #4670

What and why

Ports stop_requested() (libobs/obs-video-stop-requested.c.h), the graphics thread's per-frame check that every mix's video output has stopped, to obs-core::video_stop_requested. It is the Rust half of the extraction in #4099 (which closed the earlier port issue, #4098, before the port), and a sibling of the render size port (#4541) from the same obs-video.c.h split.

  • The live obs-video-stop-requested.c.h is now a private bridge: stop_requested() calls the hidden obs_video_stop_requested() (declared in the new private obs-video-stop-requested.h, not EXPORT, listed in rust-hidden.d) with the core, four accessors (lock and unlock of mixes_mutex, mixes.num, mix i's video) and video_output_stopped(). The mix list and its mutex stay C-owned; the Rust reads no private layout.
  • The Rust keeps the C's order exactly: one lock around the whole walk, the count read once under it, every mix asked in order with no early exit once one is running.
  • test_video_stop_requested_rust is registered in the native build's Rust-static fixtures (private-steps); linked strictly (--as-needed) against the production archive alone it passes 1/1 and keeps no libobs DSO.
  • The original C is the C reference, verbatim, in its own ported group (obs-video-stop-requested-reference.c.h, libobs.ported-video-stop-requested+).
  • No intentional differences.

The graphics task loop from the same split (execute_graphics_tasks(), #4408) is not in this PR: zackees has its port on his own branch under his claim on that issue, and I've asked there whether he wants it carried here. The render size (#4285) already landed in #4541.

Upstream: no upstream issue. The C characterization and extraction are zackees' (#4099).

RED → GREEN

  • RED commit: 3767dab. obs_core::video_stop_requested::stop_all_combinations and a_running_first_mix_still_asks_the_rest (Tier 1, ported 1:1 from test_video_stop_requested.c) fail on the todo!() core ("not yet implemented"); --lane lint passes, and --test-diff fails on those two tests only.
  • GREEN: e6a78a6 (port), 4f79d62 (Tier 3), 4af48d9 (docs). Runs were on 4af48d9.
    • Tier 1: obs_core::video_stop_requested 2/2.
    • Tier 2: the unchanged test_video_stop_requested passes against the C reference, and its new _rust variant against the Rust, on the C and hybrid trees; the 49 video, shutdown and reset tests (ctest -R 'video|shutdown|reset') pass 49/49 against hybrid libobs and 49/49 against libobs-c-reference, 0 skipped.
    • Tier 3: obs_core::video_stop_requested_parity 2/2 (every stopped vector up to six mixes, and a proptest over lists up to 63). Planted mutants caught: an early exit on the first running mix, and the unlock moved before the walk.
    • Gates: ci/local_gate.py --test-diff (8293 passed, 6 skipped), --lane lint, --lane dylint, --lane cross, and cargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets -D warnings all pass.
    • Export sets: identical on the C, hybrid and c-ref builds (1767 symbols); obs_video_stop_requested is local (t) in all three.
  • Test cost: new tests: longest 0.02 s, peak RSS 5 MB over 20 runs (OBS_PARITY_CASES=reduced), no threads of their own.
  • Real app (UI, protocol output or logging changes): not applicable, an internal helper with no change in behaviour.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (none)

Tier 1 tests for obs-core's video_stop_requested, ported 1:1 from
test_video_stop_requested.c: every stopped vector up to four mixes
and the empty list, every mix asked even after one is running, and
mixes_mutex held across the count, each mix read and each query,
then released. The core is a todo!() stub, so both tests fail.

Refs #4670.
stop_requested() in obs-video-stop-requested.c.h is now a bridge to
the hidden obs_video_stop_requested(), Rust in hybrid libobs
(obs-core::video_stop_requested). The bridge passes the core, its
accessors for mixes_mutex, mixes.num and mix i's video, and
video_output_stopped(), so the mix list stays C-owned. The Rust keeps
the C's order: one lock around the walk, the count read once under
it, every mix asked with no early exit.

The original C is the C reference, in its own ported group
(obs-video-stop-requested-reference.c.h), and the unchanged
test_video_stop_requested runs against it and, as
test_video_stop_requested_rust, against the Rust.

Refs #4670.
Tier 3 for obs-core's video_stop_requested. The oracle compiles the
original C (obs-video-stop-requested-reference.c.h) and the
production bridge's accessors over a real private core with a real
mixes_mutex. The parity test runs both over the same core and
compares the answer, every video_output_stopped() call (the video
asked and whether the mutex was held) and the released mutex, for
every stopped vector up to six mixes and random lists up to 63.

Planted mutants caught: an early exit on the first running mix (the
query log differs) and the unlock moved before the walk (the count
is read unlocked).

Refs #4670.
The rust/README.md row for obs-video-stop-requested.c.h, its place
in naming.md's obs-core row, and obs-core's Cargo.toml description
and module docs.

Fixes #4670.

Local-Gate: v1 tree=c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a secs=2395 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1794385710,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9630d37af094a143d61464be069b33a111346373aa9400e2da86bd8f9c2b7e93","lane":"lint","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":55,"stamp":"25a8d923078242a2855eff60a96e3251","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9630d37af094a143d61464be069b33a111346373aa9400e2da86bd8f9c2b7e93","lane":"lint","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":55,"stamp":"3d9981e40d140befae01c2ca0184ecad","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"b8cc88edd96ef04db364e6b530de906f165084520671cedde0f19bc5a84f5cc3","lane":"dylint","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":0,"stamp":"52fb0370b425797b6b6a090c15c68c3e","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"919c23b795ec8b0d3c9adcf257142a5cc4d79256bb1b92c64e775312c4a927c6","lane":"rust-test","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":143,"stamp":"26a2f4f7b6a59be853e0e3720c0cbd83","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"57db76cd49f47282912aff972368b5e2f53c046ad842a84d1845272320a368a4","lane":"cross","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":78,"stamp":"1414494d67de86e38985e6d468b57cba","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"57db76cd49f47282912aff972368b5e2f53c046ad842a84d1845272320a368a4","lane":"cross","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":78,"stamp":"3f69986d52acb3c03acb4bf2cfaf01f6","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"57db76cd49f47282912aff972368b5e2f53c046ad842a84d1845272320a368a4","lane":"cross","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":78,"stamp":"ff45d2e23863b9f430107e13ffde4550","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"57db76cd49f47282912aff972368b5e2f53c046ad842a84d1845272320a368a4","lane":"cross","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":78,"stamp":"611e3e35c59929cbbdc63a10e47e0cca","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
Ci-Attestation: {"at":1794385710,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"3f61850996d7ea6f9664810a7bf77b75b904097bf3f3b17f0787aaf327e4df1c","lane":"tier2-linux","parents":["4f79d623cdf18bf57661f6dd035837a4f9ff36c3"],"secs":2395,"stamp":"74fbd5209109f02e8f85024cc5f57fcd","tree":"c6e5c1f5d95d8e54eeac77a5a0346a4554343f4a","v":1,"via":"run"}
@rdoupe
rdoupe force-pushed the fix/rust-port-port-the-graphics-task-739 branch from f59b311 to 4af48d9 Compare November 11, 2026 08:28
@rdoupe
rdoupe marked this pull request as ready for review November 11, 2026 08:43
@rdoupe
rdoupe requested a review from zackees as a code owner November 11, 2026 08:43
@zackees
zackees added this pull request to the merge queue Nov 11, 2026
Merged via the queue into master with commit 2265b51 Nov 11, 2026
39 checks passed
@zackees
zackees deleted the fix/rust-port-port-the-graphics-task-739 branch November 11, 2026 08:54
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Done in obs-rust Multiview Nov 11, 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 the video stop check to obs-core

2 participants