Repository navigation
obs-source: port obs_source_filter_remove to Rust (Fixes #5795) - #5796
Merged
Merged
Conversation
Move obs_source_filter_remove() and obs_source_filter_remove_refless() unchanged out of obs-source.c.h into obs-source-filter-remove.c.h, still compiled in the live core-source group. obs_source_filter_remove_refless() keeps its body and loses its `static`: obs_source_destroy() calls it for a filter leaving its parent, so obs-internal.h now declares it (hidden, no EXPORT) in place of the static forward declaration, because the new file comes before obs-source.c.h in the unity group. No Rust, no behavior change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
New cmocka test through the real core (xvfb-run, skips without a display), against hybrid libobs and the C reference: a NULL source or filter logs the validity check's line once (the source first) and does nothing; a filter on no list, on another source's list, or the source itself changes nothing and is not released. A listed filter is erased; when it was not the first entry, the entry before it takes its target. Then, with filter_mutex free (probed from a second thread, the mutex is recursive), the global source_filter_remove and the source's filter_remove signals fire with the list already shortened and the filter's parent still set, the debug line is logged, the type's filter_remove callback runs with the parent (a type without one skips only that), the parent and target are cleared, and the list's reference is released once. Destroying a source removes its filters the same way, from the first entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
New obs-source module filter_remove with todo!() cores (remove,
remove_refless) over a FilterList trait, and Tier 1 mirrors of
test_source_filter_remove.c on a model that records every call: the NULL
lines (source first) with nothing touched; an unlisted filter read
through the whole list under the lock, then unlocked, nothing else; and
on every chain of up to 7 filters, every entry, with and without the
type's callback, through both entry points, the C's order: the lookup,
the entry before taking the removed one's target (none for the first),
the erase, the unlock, the signals, the log line, the callback check and
call, the cleared links, then one release (obs_source_filter_remove only).
Draining from the first entry removes each filter once in list order.
soldr cargo test -p obs-data --test obs-tests-core -- source::filter_remove::
test result: FAILED. 0 passed; 5 failed
panicked at rust/obs-source/src/filter_remove.rs:80:5: not yet implemented: #5795
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Safe core filter_remove::{remove, remove_refless} over the FilterList
trait, with source_filter_chain's retarget rule, and the shims in
ffi::source_filter_remove: the exported obs_source_filter_remove()
(rust-exports.d) and the hidden obs_source_filter_remove_refless() that
obs_source_destroy() calls (rust-hidden.d; declared in obs-internal.h
without EXPORT). The shims reject NULL before any adapter runs; the lock,
count, entry, target read and write, da_erase(), unlock, the two signals
on one calldata, the debug line, the callback check and call, the cleared
links and obs_source_release() stay C in the new
obs-source-filter-remove-fields.c.h (live core-source group, no EXPORT).
The extracted C moves to the reference-only group
libobs.ported-source-filter-remove.
Tier 3 (filter_remove_parity, oracle source_filter_remove.c): the
original C and the Rust exports on noise-filled real-header sources with
real signal handlers on the source and a stand-in core, over every chain
of up to 7 filters, every listed filter plus an unlisted and a NULL one,
every callback pattern, both entry points and a proptest. It compares the
list, every target and parent, the return value, each signal, callback,
release and log line in order with the lock state, every other byte, the
lock after and the last log line, and rejects five mutants. Registration
test in obs-build; rust/README row.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795738856,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":93,"stamp":"ba11c38a1247292e7e8373dddcb206f2","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738856,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":93,"stamp":"3858c593921ddb13e53e51245f4cb096","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738856,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":93,"stamp":"57a59905ae1ff0e1773f143f1717ad03","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738856,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":93,"stamp":"b27a4e8ac2c0b5ed447daa129859142b","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"general/all/client-lint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"b3afd9b8b7e893491cd72891b37fbbf1","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738856,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":93,"stamp":"590ea97ee986a2d9e69b23c7dc7a9b91","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"589619d13392f5dabb32744c3c42dd1e","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"672d936ed0350f2ab24043cd9f6b7c13","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"5912a82e1966552649da42495c5eae3d","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"09694a266210772b011cb8771f329267","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"8c0d1f5cde93980c9ec80fe089842328","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"3c436070c0da829129537d6728d54bd4","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"6c5402bc20da5e004f2012d4ec409345","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"09fad6e10779d932c0f5fef3af93d286","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"fda12635b9867bb22c83f8fc759897ac","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"d1f0828f57c5e5bb8cdc7a5eff4eb352","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"1e62a589de6e3c3f187a19a93129b443","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795738762,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"1148efbc40c1b76fbfcbc3b64d6fc8605bbd15ec9f8305831c68242928b6e630","lane":"client-lint","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":74,"stamp":"83f7db4458cb1c1eb2979237279929cc","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Ci-Attestation: {"at":1795739142,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"47fbe766174d79b3310ea69595a66f74931f27ceb7c7554c50cdd49e46e4c7e3","lane":"client-test-x86_64-unknown-linux-gnu","parents":["084f6411e32a9f5ea69af897ae0e77476affa818"],"secs":286,"stamp":"191b60a63cd4334c3d7ad1b62ae25db4","tree":"03be075205fc84779b490d42a62cdf97cf454600","v":1,"via":"run"}
Client-Checks: {"checks":{"base":"b60190ad98359dd62cc0dc47ed12bc6772c3431e","coverage":"all-tracked-applicable-files","diff":[".github/workflows/build-project.yaml","build-aux/flatpak/ninja.cmake","build-aux/io.github.obs_rust.OBSStudioRust.json","ci.toml","ci/cache_metrics.py","ci/flatpak_cache_probe.py","ci/flatpak_compiler_cache.py","ci/flatpak_compiler_diagnostics.py","ci/flatpak_pch_probe.py","ci/flatpak_pruned_build_probe.py","ci/scope_exemptions.txt","ci/test_cache_metrics.py","ci/test_ci_toml.py","ci/test_flatpak_build_script.py","ci/test_flatpak_compiler_diagnostics.py","ci/test_hybrid_packaging.py","ci/test_zccache.py","docs/ci-speed-flatpak-pch-1760.md","docs/ci-tooling.md","docs/zccache-flatpak-migration-note.md","libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-filter-remove+.h.c","libobs/build/ported-source-sets/source-filter-remove.json","libobs/cmake/rust-exports.d/obs-source-source_filter_remove.txt","libobs/cmake/rust-hidden.d/obs-source-source_filter_remove.txt","libobs/obs-internal.h","libobs/obs-source-filter-remove-fields.c.h","libobs/obs-source-filter-remove.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_remove_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-filter-remove.list","rust/obs-c-oracle/oracle/source_filter_remove.c","rust/obs-source/Cargo.toml","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_filter_remove.rs","rust/obs-source/src/filter_remove.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/filter_remove.rs","rust/obs-source/tests/source/filter_remove_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_filter_remove.c","test/cmocka/tests.d/test_source_filter_remove.cmake"],"head":"30017f40584f9616a89745ea7f38a6a44711e15e","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":"d8fdf9ec4374988b123591abf56f4ab38483d30c4d9c4d846ca23fad52812cfe","tree":"03be075205fc84779b490d42a62cdf97cf454600"}}
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 #5795.
Ports
obs_source_filter_remove()toobs-source, together with its stepobs_source_filter_remove_refless().obs_source_destroy()still calls that step directly for a filter leaving its parent, so it stays reachable from C as a hidden entry: declared inobs-internal.hwithoutEXPORT, listed inrust-hidden.d/obs-source-source_filter_remove.txt. The retarget decision was already Rust (source_filter_chain::remove_retarget); the core reuses it.What stays C: the lock, the list read and
da_erase(), the target read and write, the calldata and both signals (one adapter, so a handler that rewrites the calldata is seen by the second signal as before), the debug line, thefilter_removecallback check and call, clearing the parent and target, andobs_source_release(). The Rust core reaches them through hidden, non-EXPORT adapters inlibobs/obs-source-filter-remove-fields.c.h, in the live core-source group. The extracted C builds in the reference grouplibobs.ported-source-filter-removefor Tier 3.The four commits, in order:
libobs: extract … verbatim): both functions move unchanged intolibobs/obs-source-filter-remove.c.h. The refless step loses itsstatic, andobs-internal.hdeclares it in place of the static forward declaration inobs-source.c.h. No behavior change.test: characterize …): new cmocka testtest_source_filter_remove, run through the real core against both hybrid libobs and the C reference. It covers:filter_mutexfree (probed from a second thread, since the mutex is recursive). Then the debug line, the callback with the parent (a type without one skips only the call), the parent and target cleared, and exactly one release (checked with a weak reference).test: RED … safe core): Tier 1 mirrors over atodo!()core.No public-header, existing-C-test, WebSocket or workflow edits. Tier 4 does not apply. No user-visible change, so no features ledger line.
One difference, unreachable: a NULL source passed to the hidden refless step returns
falsewithout a call. The original would follow the pointer, but its only caller (obs_source_destroy()) passesfilter_parentafter checking it is set.RED
GREEN
Tier 1 and Tier 3, on the pushed head (rebased onto #5794):
filter_remove_parity, withoracle/source_filter_remove.c, runs the original C and the Rust exports on noise-filled sources built from the real headers. The source and a stand-in core each have a real signal handler, andobs_source_release()is a recording stand-in. It records every signal (calldata source and filter, the list length), callback (the parent passed and the filter's parent field), release and log line in order, each with the lock state. It then compares those, the list, every filter's target and parent, the return value, every other fixture byte, the lock afterwards and the last log line.reduced, 1.09 s atfull(debug, including the isolated child for the log handler); peak RSS 13.6 MB; no threads of its own.Tier 2, the C tests run unchanged against both libraries:
Run directly under
xvfb-run,test_source_filter_removeshows[ PASSED ] 6 test(s)against both libraries, none skipped. I got the same result on the characterization commit, with nothing swapped.Registration:
./lintpasses../pushran the client lint and test lanes, which passed. The final commit is not signed here, so the PR runs the full selected CI.🤖 Generated with Claude Code