Repository navigation
obs-core: port obs-view to Rust (#1933) - #1935
Merged
Merged
Conversation
12 Tier 1 cases on a recording host fail with 'not yet implemented: #1933'.
The view functions move from obs-view.c.h to obs-view-api.c.h in their own unity group, libobs.ported-view, which the hybrid libobs replaces with the Rust shims in obs-core's ffi::view (rust-exports.d/obs-core-view.txt; the internal obs_view_init/obs_view_free are hidden). struct obs_view stays C in obs-view.c.h, embedded in struct obs_canvas: hidden one-step accessors there give the C file and the shims its mutex, channels and type, a source's removed flag and the video mixes list. Tier 3 (view_parity): fixed and random operation sequences through the C oracle (NDEBUG, as release libobs) and the shims over shared traced stand-ins, comparing the trace, results, channels and mixes after each step; plus obs_view_init/obs_view_free on a raw struct. Swapping the activation of the new source and the deactivation of the old one in set_source fails it. Refs #1933
Rust/C on the oracle's stand-ins: set_source swap 30.4/27.3 ns, get_source 7.80/7.70 ns, render (16 of 64 channels) 174.1/169.0 ns, create + destroy 188.8/200.2 ns.
6 of 7 tasks
6 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1933. Tier 2 is #1934 (
test/cmocka/test_view.c).RED
c39ea9829:todo!()stubs inrust/obs-core/src/view.rsand 12 Tier 1 cases inrust/obs-core/tests/obs_core/view.rs(a recording host); all 12 fail withnot yet implemented: #1933.GREEN
dda5c76basafe core over aHosttrait, in the C's order:set_sourcetakes the new reference and swaps it under the lock, then activates the new source and deactivates and releases the old one;renderdrops removed sources and renders the others under the lock;freedeactivates and releases each channel, clears them, destroys the mutex. 12/12 Tier 1 pass.e955cf794swap: the view functions move fromlibobs/obs-view.c.htolibobs/obs-view-api.c.hin a new unity grouplibobs.ported-view(+ pch,source-sets.json), which the hybrid libobs replaces withobs-core'sffi::view. The 9 public functions are exported (rust-exports.d/obs-core-view.txt);obs_view_init/obs_view_free(internal, called byobs-canvas.c) are hidden (rust-hidden.txt,rust-exports.map,rust-unexports-macos.txt).93bac7240bench.What stayed C and why
struct obs_viewis embedded instruct obs_canvas, so its layout stays C inobs-view.c.h, behind 19 hidden one-step accessors declared inobs-internal.h: the mutex (init/destroy/lock/unlock), type, channels, a source'sremovedflag, the main canvas mix info, and theobs->video.mixeslist (obs_view_mix_addkeepsobs_create_video_mix+ the locked push together). Theobs_source_*calls are the real ones.Tiers
view_parityruns fixed and random (512 cases) operation sequences through the unmodified C (oracle/view.c, built withNDEBUGas release libobs) and the shims over shared traced stand-ins, comparing the trace, results, every channel and the mixes after each step; plus init/free on a raw struct. Swapping activate-new / deactivate-old inset_sourcefails it../lintpasses;obs-utilexport-list tests pass (6);ci/test_ported_sources.pypasses. Both changed C groups compile (gcc -fsyntax-only).Bench (Rust / C, oracle stand-ins)
Kept / intentional differences
Kept, characterized, not endorsed:
obs_view_renderreleases a removed source without deactivating it;obs_view_enum_video_infodoes not check the view (NULL enumerates mixes whose view was removed). Intentional: no assert on the channel (out of range returns, as release libobs); a NULLenum_procwith a matching mix panics (the C calls through it).Not user-visible; no features.md line.