Skip to content

obs-source: port obs_source_filter_set_order to Rust (Fixes #5775) - #5776

Merged
rdoupe merged 4 commits into
masterfrom
port/5775-filter-set-order
Nov 26, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/5775-filter-set-order

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5775

What changes

obs_source_filter_set_order(), the filter move behind the filters dialog's up and down buttons and obs-websocket's filter index helper, moves from libobs/obs-source.c.h to obs-source::filter_set_order, with its static helpers move_filter_dir(), find_next_filter() and find_prev_filter() and the retarget walk after a move. The movement, walk and target rules were already Rust (obs-source::source_filter_chain); this is the C that was left around them.

Commits, in order:

  1. libobs: the entry and its three helpers move verbatim into libobs/obs-source-filter-set-order.c.h, still in the live libobs.core-source group. reorder_filter_targets() stays in obs-source.c.h; it loses its static and obs-internal.h declares it (hidden), because the new file comes before obs-source.c.h in the unity group. No behavior change.

  2. test: new cmocka characterization test/cmocka/test_source_filter_set_order.c on test-owned, noise-filled struct obs_source values with a real signal handler (no core):

    • a NULL source or filter logs obs_source_filter_set_order: Null 'source'|'filter' parameter once at LOG_DEBUG (source first), and reads (the list is NULL there), writes and signals nothing;
    • a filter not in the list moves, retargets and signals nothing, whatever the movement, and filter_mutex is free afterwards;
    • up and down move to the nearest filter of the same async kind, top and bottom to the ends, on hand-picked cases and on every chain of up to 6 filters with every async pattern, index and movement; with nowhere to go nothing moves or is signalled;
    • after a move every filter's filter_target is rewritten (the next filter, the last one the source), and reorder_filters is signalled once on the source's own handler (no global signal: obs_source_dosignal(source, NULL, ...)), after filter_mutex is released, with the source as calldata source and the list already moved;
    • nothing else of the source or any filter is written, and a non-NULL call logs nothing.

    For a movement outside the enum only what the C reference and the port share is asserted: no filter moves (the reference still retargets and signals there, the existing rust: Port the source filter chain rules to obs-source #2981 fix in the rules).

  3. test: RED. Tier 1 mirrors against a todo!() core over a FilterChain trait.

  4. obs-source: GREEN.

    • Safe core filter_set_order::set_order over FilterChain, using the source_filter_chain rules, and the exported shim ffi::source_filter_set_order (rust-exports.d/obs-source-source_filter_set_order.txt). The shim rejects NULL before calling the adapters of the new obs-source-filter-set-order-fields.c.h (live libobs.core-source group, no EXPORT): lock, count, entry, flags, da_move_item(), target write, unlock, obs_source_dosignal(). The Rust core does its own retarget.
    • The extracted C moves to the new reference-only group libobs.ported-source-filter-set-order (ported-source-sets/source-filter-set-order.json).
    • Oracle rust/obs-c-oracle/oracle/source_filter_set_order.c (+ oracle.d fragment); registration test in obs-build; rust/README row.

No public header, existing C test, WebSocket or workflow change. No intentional differences. Tier 4 does not apply. No features ledger line (no user-visible change).

Tests

  • Tier 1 (rust/obs-source/tests/source/filter_set_order.rs): the five cmocka cases on a model source that records every call, on chains of up to 7, plus the C's exact order of reads and writes (lookup, the moved filter's flags read again at each walk step, the move, each filter retargeted from the first, unlock, then the signal).
  • Tier 2: the new test_source_filter_set_order, the filter chain step tests (C and Rust-static), the test_filter_* callers, test_source_enum_filters, test_source_filter_index, test_ws_filter_settings_event, test_scroll_filter_wide_source and every _steps_rust test, on hybrid libobs and the C reference.
  • Tier 3 (filter_set_order_parity.rs): the original C and the Rust export on noise-filled real-header sources with a real signal handler, over every chain of up to 7 filters with every async pattern, every listed filter plus an unlisted and a NULL one, movements -1 to 5 and the ends of int, the NULL-source cases and a proptest; it compares the list, every filter's target, the signal (count, calldata, lock free during it, the list it saw), the global signal count, every other byte, the lock after the call and the exact log line. The original calls the filter chain rules by their libobs names, the rules hybrid libobs ships, so out-of-enum movements compare exactly too. It rejects four mutants (no retarget, no move, signal under the lock, kind ignored). Mutation check: swapping top and bottom in the core fails set_order_matches_c (reverted).
  • Test cost: longest new test 0.32 s at full, 0.06 s at reduced (debug); peak RSS 14.6 MB over the module's runs; no own threads (the parity test reruns itself in one child process for the log handler).

Evidence

RED (test: RED ...):

soldr cargo test -p obs-data --test obs-tests-core -- source::filter_set_order::
test source::filter_set_order::a_move_reads_and_writes_in_the_c_order ... FAILED
test source::filter_set_order::moves_walk_to_the_same_kind_and_the_ends ... FAILED
test source::filter_set_order::every_chain_moves_as_the_rules_say ... FAILED
test source::filter_set_order::out_of_enum_movement_moves_nothing ... FAILED
test source::filter_set_order::null_arguments_log_once_and_do_nothing ... FAILED
test source::filter_set_order::unlisted_filter_moves_nothing ... FAILED
panicked at rust/obs-source/src/filter_set_order.rs:66:5: not yet implemented: #5775
test result: FAILED. 0 passed; 6 failed; 0 ignored; 0 measured; 6856 filtered out

GREEN:

soldr cargo test -p obs-data --test obs-tests-core -- source::filter_set_order
test source::filter_set_order_parity::set_order_matches_c ... ok
test result: ok. 7 passed; 0 failed

soldr cargo test -p obs-studio-rust --test obs-tests-app -- canonical_source_filter_set_order canonical_source_enum_filters
test result: ok. 2 passed; 0 failed

./lint
== lane lint: ok

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_source_filter_set_order|test_source_filter_chain_steps|test_filter_|test_source_enum_filters|test_source_filter_index|test_ws_filter_settings_event|test_scroll_filter_wide_source|_steps_rust'
IDENTICAL (1769 symbols)
100% tests passed, 0 tests failed out of 1122   (each build: hybrid and C reference)
100% tests passed, 0 tests failed out of 53     (the selected tests, each build)

Tier 2 on the characterization commit (extraction + new test, nothing swapped):

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_source_filter_set_order|test_source_filter_chain_steps|test_filter_clipboard|test_source_enum_filters|test_source_filter_index'
IDENTICAL (1769 symbols)
100% tests passed, 0 tests failed out of 1122   (each build: hybrid and C reference)
100% tests passed, 0 tests failed out of 6      (the selected tests, each build)

🤖 Generated with Claude Code

rdoupe and others added 4 commits November 26, 2026 05:47
Move obs_source_filter_set_order() with move_filter_dir(),
find_next_filter() and find_prev_filter() unchanged out of obs-source.c.h
into obs-source-filter-set-order.c.h, still compiled in the live
core-source group. reorder_filter_targets() stays in obs-source.c.h; it
loses its `static` and obs-internal.h declares it, because the new file
comes before obs-source.c.h in the unity group. Hidden visibility keeps it
out of the exported symbols. No Rust, no behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New cmocka test on test-owned, noise-filled struct obs_source values (no
core): a NULL source or filter logs the validity check's line once
(source first) and reads, writes and signals nothing; a filter not in the
list moves nothing whatever the movement; up and down move to the nearest
filter of the same async kind, top and bottom to the ends, checked on every
chain of up to 6 filters with every async pattern; after a move every
filter is retargeted (the next one, the last the source) and
"reorder_filters" is signalled once on the source's own handler, after
filter_mutex is released, with the source as calldata. For a movement
outside the enum only what the C reference and the port share is pinned
(#2981): no filter moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New obs-source module filter_set_order with a todo!() core over a
FilterChain trait, and Tier 1 mirrors of test_source_filter_set_order.c on
a model source that records every call: the NULL lines, an unlisted
filter, the walks to the same kind and the ends on every chain of up to 7
filters, an out-of-enum movement doing nothing, and the C's order of reads
and writes (the moved filter's flags read again at each walk step, every
filter retargeted from the first, the signal after the unlock).

    soldr cargo test -p obs-data --test obs-tests-core -- source::filter_set_order::
    test result: FAILED. 0 passed; 6 failed
    panicked at rust/obs-source/src/filter_set_order.rs:66:5: not yet implemented: #5775

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_source_filter_set_order() moves to obs-source's filter_set_order
module with move_filter_dir(), find_next_filter() and find_prev_filter().
A NULL source or filter logs one LOG_DEBUG line (source first) and touches
nothing. Under filter_mutex the filter is looked up in the list (an
unlisted one moves nothing); up and down move it to the nearest filter of
the same async kind, its own flags read again at each step as the C's
recursion did; top and bottom to the ends, through the source_filter_chain
rules. After a move every filter is retargeted from the first (the next
filter, the last one the source), and reorder_filters is signalled on the
source's own handler after the unlock, only on a move.

The shim rejects NULL before calling the adapters of
obs-source-filter-set-order-fields.c.h (live core-source group, no
EXPORT): lock, count, entry, flags, da_move_item(), target write, unlock
and obs_source_dosignal(). The Rust core does its own retarget;
reorder_filter_targets() stays in obs-source.c.h. The extracted C builds
in the reference group libobs.ported-source-filter-set-order.

Tier 3 (filter_set_order_parity, oracle/source_filter_set_order.c) runs
the original C and the Rust export on noise-filled real-header sources
with a real signal handler over every chain of up to 7 filters with every
async pattern, every listed filter plus an unlisted and a NULL one,
movements -1 to 5 and the ends of int, and a proptest, comparing the list,
every target, the signal (count, calldata, lock state, the list it saw),
every other byte, the lock and the log line; it rejects four mutants (no
retarget, no move, signal under the lock, kind ignored). Mutation check:
swapping top and bottom in the core fails set_order_matches_c (reverted).

    soldr cargo test -p obs-data --test obs-tests-core -- source::filter_set_order
    test result: ok. 7 passed; 0 failed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795692160,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":93,"stamp":"e9004df02097080440aab74f605e0cdc","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692160,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":93,"stamp":"cd13c149f395b7c25430779a0f6a9bb7","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692160,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":93,"stamp":"023606b1654d7b8b60e88a6849a7e77e","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692160,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":93,"stamp":"b509983ade39dd0c84d080bfdc766105","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"general/all/client-lint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"8173e0e815a61bee8277797d386af425","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692160,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":93,"stamp":"d2057791734c5ff25de704ebe57c081e","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"ac0cc1259cef7ba59e10e8823edcc4f0","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"12dd3b06873c6d92d1115e7722760014","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"6dd754d8326e94a27cbf72603cd0f844","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"b68fd70e3f76b6f8e55a2cf3ddc49f7f","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"78de4a1733d9f75bf43b54903d0119ea","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"a9616b557093181b67df1b92d4ac0946","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"f3a9c125b2abe7c0a63f7c23c3e123f8","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"a2059b688fef4eb4e0186275f8ce7f06","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"a34ae322d4a45c3eecc338d57f72ffb7","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"30d95ec17715c6bb709cb09a69d08d9b","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"6ef4e3b17563c12cf57a92647d7ebbf8","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692066,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"43aaae08e4bad9af790b6f069a3b864cfbe5358b46564f49f7c019130b97ec08","lane":"client-lint","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":66,"stamp":"954424ad58dfde2c15ef5419136dcdc5","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}
Ci-Attestation: {"at":1795692394,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"8f13a136575ac1fac90bce4348aac9a787d408a01e3a7c5b16a332970c5b737f","lane":"client-test-x86_64-unknown-linux-gnu","parents":["31d947e6334a4732dc6617eed10bc5a6920f8505"],"secs":233,"stamp":"efc008b95951fe96c3567b3c3657bb2b","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"e8cbea4dd0142b45229389ff871e402fda40050a","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-async-flag-getters+.h.c","libobs/build/libobs.ported-source-filter-set-order+.h.c","libobs/build/ported-source-sets/source-filter-set-order.json","libobs/cmake/rust-exports.d/obs-source-source_filter_set_order.txt","libobs/cmake/rust-hidden.d/obs-source-source_async_flag_getters.txt","libobs/obs-internal.h","libobs/obs-source-async-flag-fields.c.h","libobs/obs-source-async-last-ts-getter.c.h","libobs/obs-source-filter-set-order-fields.c.h","libobs/obs-source-filter-set-order.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_filter_set_order_swap_is_registered.rs","rust/obs-build/tests/native/registration/canonical_source_last_async_ts_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-filter-set-order.list","rust/obs-c-oracle/oracle/source_async_flag_getters.c","rust/obs-c-oracle/oracle/source_filter_set_order.c","rust/obs-c-oracle/oracle/source_profiler_host.c","rust/obs-source/src/async_flag_getters.rs","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_async_flag_getters.rs","rust/obs-source/src/ffi/source_filter_set_order.rs","rust/obs-source/src/filter_set_order.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/async_flag_getters.rs","rust/obs-source/tests/source/async_flag_getters_parity.rs","rust/obs-source/tests/source/filter_set_order.rs","rust/obs-source/tests/source/filter_set_order_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/source-async-flag-getter-link-stubs.c","test/cmocka/test_source_filter_set_order.c","test/cmocka/test_source_last_async_ts.c","test/cmocka/tests.d/test_source_filter_set_order.cmake","test/cmocka/tests.d/test_source_last_async_ts.cmake"],"head":"9e2e6a38e91e9e016c20d85701d8ab2c455870db","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":"2cbf07b0eaf85291be938581550537f2e6484bf9830691da0486923b728789b0","tree":"926b9e02e17aca1b4e7c9cb309a4fad7c783e16d"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 26, 2026 11:27
@rdoupe
rdoupe added this pull request to the merge queue Nov 26, 2026
Merged via the queue into master with commit 5fd85c1 Nov 26, 2026
91 of 93 checks passed
@rdoupe
rdoupe deleted the port/5775-filter-set-order branch November 26, 2026 19:12
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_filter_set_order to obs-source

1 participant