Repository navigation
obs-source: port obs_source_activate and obs_source_deactivate to Rust (Fixes #5811) - #5812
Merged
Merged
Conversation
…m (Refs #5811) Move obs_source_activate(), obs_source_deactivate() and their four tree callbacks (show_tree, hide_tree, activate_tree, deactivate_tree) unchanged out of obs-source.c.h into obs-source-activate.c.h, still compiled in the live core-source group. Both entries are declared in obs-internal.h (in the precompiled header) and the callbacks are used only by them, so the earlier position in the unity group needs no new declaration. No Rust, no behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#5811) New cmocka test through the real core (xvfb-run), against hybrid libobs and the C reference. Both entries are internal, so it reaches them through obs_source_inc_showing/inc_active (AUX and MAIN activate) and dec_showing/dec_active (AUX and MAIN deactivate), on private sources whose enum_active_sources lists a nested tree (a lists b and d, b lists c) and records all eight counters at every visit. It pins: activate raises the root's show_refs, then walks the active tree once (post-order) adding 1 to each descendant's; MAIN then does the same for activate_refs, after the whole show walk. Deactivate lowers show_refs and walks only when the root's is above zero, then for MAIN the same for activate_refs, each counter checked on its own; descendants are not floor-checked and go below zero; a root at zero is never walked; nothing logs. The entries' own NULL check can't be reached from outside libobs (every caller checks first), so it goes to Tier 1 and Tier 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#5811) New obs-source module activate with a todo!() core (activate, deactivate and visit, the four tree callbacks) over a Counters trait, and Tier 1 mirrors of test_source_activate.c on a model of its tree (a lists b and d, b lists c) that walks post-order and records every increment, decrement, load and walk with all eight counters at each walk's start: AUX and MAIN activation (show step and walk, then for MAIN the active step and walk, never a load, from any count), AUX and MAIN deactivation (each counter loaded once and stepped and walked only above zero; a hidden but active root walks once; descendants not floor-checked), a root at zero left alone, a balanced sequence, any view type but MAIN_VIEW showing only, each callback moving one counter of the child, and the NULL source the C test can't reach (one line naming the entry). soldr cargo test -p obs-data --test obs-tests-core -- source::activate:: test result: FAILED. 0 passed; 13 failed panicked at rust/obs-source/src/activate.rs:97:5: not yet implemented: #5811 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #5811) Safe core activate::{activate, deactivate, visit} over the Counters trait (visit is the four tree callbacks), and the shims in ffi::source_activate: the hidden obs_source_activate() and obs_source_deactivate() (rust-hidden.d, no EXPORT) and the Rust show_tree/hide_tree/activate_tree/deactivate_tree handed to the C obs_source_enum_active_tree(). The shims reject NULL with the original LOG_DEBUG line before any adapter runs. The atomic increments, decrements and loads of show_refs and activate_refs stay C in the new obs-source-activate-fields.c.h (live core-source group, no EXPORT). The extracted C moves to the reference-only group libobs.ported-source-activate. Oracle refit: oracle/view.c's tracing doubles of the two symbols are gone. The view, show-counter and active-child parity tests now reach the Rust exports, whose counter adapters have one dispatching stand-in each in the new oracle/source_activate.c: with that file's fixture installed they are the real adapters, otherwise they report each step to view.c, which traces the same "activate|deactivate <name> <view type>" event as before (closed at the next traced step, a hook change, or oracle_view_flush()). obs_source_enum_active_tree()'s link stand-in moves there from audio_callback_links.c. No assertion of an existing test changed. Tier 3 (activate_parity, oracle source_activate.c): the original C and the Rust exports on noise-filled real-header sources with a scripted walk, over every call, source (NULL too), view type (MAIN, AUX, 0, 3, u32::MAX), root counter edge and edge set, plus a proptest. It compares each walk's root and every counter when it began, the counters after, the log lines and every other byte, and rejects eleven mutants. Registration test in obs-build; rust/README row. soldr cargo test -p obs-data --test obs-tests-core -- source::activate test result: ok. 14 passed; 0 failed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795772249,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":93,"stamp":"578c030b33a1fc33feeaab424555f78d","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772249,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":93,"stamp":"cb7285dd05e851bec8b19b576f7d3b86","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772249,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":93,"stamp":"a573108259aae4ffde03c4f8866fb820","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772249,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":93,"stamp":"08e8854242983d7a1f3875197202f501","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"general/all/client-lint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"d42e9403e810353a83b5a8f2bff6b0d6","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772249,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":93,"stamp":"652dc304120cef41a99a8e115d3129e5","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"8ffcc1f892d868c4863c3b9346663857","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"8bd3f6f2a5169c6b34303e91a0dabf0f","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"5e31f96e69f76d8e74dc7d7607ecf301","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"fb4b2bbb41ecc7aeddea3c9853a16b94","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"80ea9715ebdff5ba38018d6907d39fe0","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"54fc1c376786d63779afd496b77b1bc8","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"6e7e403600b1da2b96c970b741ee000e","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"a8183d0d209ee859482ec5a7b8f17615","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"bada2c4f3036844e51732231e7bde360","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"849e536fd51717aa8fa68af94c00747e","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"c942e9085c292d932b8bd9afe0d3caf7","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772155,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b05d0165315058aa95066f670d9c307e7ca3fbfe3b2b35e9314963ccf666c65d","lane":"client-lint","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":107,"stamp":"6c914298fe79c701a260f2fceb318cab","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Ci-Attestation: {"at":1795772520,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"e25a66120554518aaa24f72931a63090b01c20e97dd129b9ae7c58db6964d4f8","lane":"client-test-x86_64-unknown-linux-gnu","parents":["07dd8338fbd8d74c263ce9b23feea036070a201e"],"secs":270,"stamp":"156396e2ded76c149af2870adfb2c26c","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30","v":1,"via":"run"} Client-Checks: {"checks":{"base":"7e3006910b56a445f1019b1c9b3f84e1ecd6f1f0","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-activate+.h.c","libobs/build/ported-source-sets/source-activate.json","libobs/cmake/rust-hidden.d/obs-source-source_activate.txt","libobs/obs-source-activate-fields.c.h","libobs/obs-source-activate.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_activate_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-activate.list","rust/obs-c-oracle/oracle/audio_callback_links.c","rust/obs-c-oracle/oracle/source_activate.c","rust/obs-c-oracle/oracle/source_active_child.c","rust/obs-c-oracle/oracle/source_show_active_counters.c","rust/obs-c-oracle/oracle/view.c","rust/obs-c-oracle/src/view.rs","rust/obs-core/tests/obs_core/view_parity.rs","rust/obs-source/Cargo.toml","rust/obs-source/src/activate.rs","rust/obs-source/src/active_child.rs","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_activate.rs","rust/obs-source/src/ffi/source_active_child.rs","rust/obs-source/src/ffi/source_show_active_counters.rs","rust/obs-source/src/lib.rs","rust/obs-source/src/show_active_counters.rs","rust/obs-source/tests/source/activate.rs","rust/obs-source/tests/source/activate_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_activate.c","test/cmocka/tests.d/test_source_activate.cmake"],"head":"8202d6a90614479b42af2acf4e0b16a67df33bb0","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":"6f39a094d19ef1b17b048e3d373a78c343e6a336b5a7a7cd9b1ae188b3a3a7d5","tree":"91c2db35bc51688a1c9a580f353a10a6093eeb30"}}
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.
Fixes #5811.
Ports
obs_source_activate()andobs_source_deactivate()(declared inobs-internal.hwithoutEXPORT) and their four tree callbacks (show_tree,hide_tree,activate_tree,deactivate_tree) toobs-source. The safe core isactivate::{activate, deactivate, visit}over aCounterstrait; the hidden exports and the Rust tree callbacks are inffi::source_activate(rust-hidden.d, never exported).Contract kept:
obs_source_activate: Null 'source' parameter(orobs_source_deactivate) atLOG_DEBUGand nothing else happens.show_refs+1, then oneobs_source_enum_active_tree()walk adding 1 to each child'sshow_refs; only forMAIN_VIEW, thenactivate_refs+1 and a second walk for the children'sactivate_refs. Any other view type only touches the show counters.show_refs > 0, -1 and a walk subtracting 1 from each child's (children are not floor-checked); then forMAIN_VIEW, only whenactivate_refs > 0, the same foractivate_refs. A source at zero is left alone and not walked.What stays C: the atomic increments, decrements and loads of
show_refsandactivate_refs, as hidden non-EXPORT adapters inlibobs/obs-source-activate-fields.c.h(livelibobs.core-sourcegroup), and the walk itself (obs_source_enum_active_tree(), #5729 / #5735). The extracted original moves to the reference-only grouplibobs.ported-source-activate.Oracle refit:
rust/obs-c-oracle/oracle/view.cno longer defines tracing doubles namedobs_source_activate/obs_source_deactivate. The view, show-counter and active-child parity tests now reach the Rust exports. Each counter adapter has a single dispatching stand-in in the neworacle/source_activate.c. With that file's fixture installed, the stand-ins run the real adapters. Without it, they report each step toview.c, which traces the sameactivate|deactivate <name> <view type>event as before. That event is written out at the next traced step, when the hook changes, or atoracle_view_flush(). Theobs_source_enum_active_tree()link stand-in moves there fromaudio_callback_links.c. No assertion in any existing test changed.view_parity'stake_trace()and the two oracle check functions now flush first.Commits:
libobs/obs-source-activate.c.h, still in the live group.test_source_activatethrough the real core (xvfb-run), against hybrid libobs and the C reference. It reaches the hidden entries throughobs_source_inc_showing/inc_active/dec_showing/dec_activeon private sources whoseenum_active_sourceslists a nested tree (a lists b and d, b lists c). Every visit records all eight counters. It covers AUX/MAIN activate and deactivate, the walk order (post-order, the show walk before the active step), descendants going below zero, a root at zero never walked, a hidden but active root walking once, and no logging. The entries' own NULL check can't be reached from outside libobs because every caller checks first, so Tier 1 and Tier 3 cover it.todo!()core.No public-header, existing-C-test, WebSocket or workflow edits. Tier 4 does not apply. No user-visible change, so there is no features ledger line.
RED
GREEN
activate_parity,oracle/source_activate.c): runs the original C and the Rust exports on noise-filled real-header sources, both reaching the same scripted walk. Inputs: every call, source (NULL too), view type (MAIN, AUX, 0, 3,u32::MAX), root counter edge and edge set (none, the C test's tree, the root as its own child, a repeated child, a NULL parent), plus a 512-case proptest. It compares each walk's root and every counter when the walk began, the counters afterwards, the log lines and every other byte. It rejects 11 mutants built into the test: silent NULL, swapped NULL names, swapped views, the active step first, the opposite walk, the wrong counter's walk, no floor check, a floor at zero, the active step only when hidden, the walk before the root's step, and no walk. By hand it also rejected a core mutant (>= 0on the show load), which I reverted.xvfb-runin the kept build volume,test_source_activateshows[ PASSED ] 10 test(s)against hybrid libobs and againstlibobs-c-reference, none skipped. The characterization also passed on both libraries before the swap (the same run on the extract + characterize head: 1130/1130 each)../lintpasses.soldr cargo test --workspace --no-run --lockedlinks every test binary, andOBS_CMOCKA_LINK=false uv run --no-project ci/windows_link_check.pylinks the Windows MSVC category binaries.Test cost: new tests: longest about 0.1 s (
activate_matches_c, isolated child process), peak RSS 82 MB for the whole isolated test binary (14 MB for the Tier 1 module), no own threads../pushran the client lanes, but the Swift lane can't run here and the final commit isn't signed, so the PR runs the full selected CI.🤖 Generated with Claude Code