Skip to content

rust: Port obs_source_restore_filters to obs-source #5801

Done

Description

@rdoupe

Port the public obs_source_restore_filters() from libobs/obs-source.c.h into obs-source. Callers: the filters dialog's undo/redo and the paste-filters path (frontend/utility/filter-clipboard.c.h, frontend/widgets/OBSBasic_Clipboard.cpp.hpp). Its partner obs_source_backup_filters() is already Rust (obs-source::filter_backup), and the two chain decisions it uses (obs_source_filter_chain_restore_matches(), _restore_step()) are already Rust in obs-source::source_filter_chain; this entry is the C orchestration left. It is the last filter-list entry still in C apart from the by-name/by-UUID lookups and obs_source_filter_set_index(), which stay out of this unit.

Contract to keep (pinned by a new cmocka characterization against hybrid libobs and the C reference):

  • Invalid source or NULL array: the usual obs_source_valid / obs_ptr_valid log (source checked first), nothing locked or changed.
  • Under filter_mutex: every current filter is copied aside in order, its filter_parent and filter_target cleared, and source->filters freed; then the lock is dropped.
  • With the lock free, for each array item in order: a current filter whose name matches (restore_matches; a NULL current name never matches) is reused through obs_source_get_ref(); if none matches, or the reference fails (a dying filter), the item is loaded through restore_step: private (obs_load_private_source()) in hybrid libobs since rust: Port the source filter chain rules to obs-source #2981, public (obs_load_source()) in the C reference; the characterization does not pin which. Each new filter becomes the previous one's filter_target; the item is released.
  • The last restored filter targets source; then every restored filter's filter_parent is set to source (only after all targets are set, libobs: A filter's size query can follow a NULL target during filter restore or removal #2172), and the new list is moved into source->filters under filter_mutex.
  • Afterwards each old filter is released once, in old order, and the copy freed. No signals, no logs on the success path. Duplicate names in the array reuse the same current filter each time, as today.

Stays C (reached through hidden, non-EXPORT adapters in a *-fields.c.h in the live core-source group): the lock, the filters array reads, writes and move, the name read, obs_source_get_ref, the two loaders, obs_source_release, and the obs_data_array item reads.

Plan: extract the entry verbatim into its own file in a live group, characterize, Tier 1 RED against todo!(), then the Rust swap through the field adapter, a Tier 3 differential against the original C (chains of 0 to 6 current filters, arrays reusing, loading, duplicating and dropping filters, a failed reference, NULL names), and Tier 2 unchanged. No public-header, existing-C-test, WebSocket or workflow edits. Tier 4 does not apply.

Activity

  1. added
    port
    on Nov 27, 2026
  2. rdoupe commented on Nov 27, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: I'll extract, characterize and swap it RED then GREEN, stacked on the filter_add port (#5800) so the two don't conflict in obs-source.c.h and the test graph; I'll retarget to master once #5800 merges.

  3. added
    ready
    on Nov 27, 2026
  4. moved this from In progress to In review in obs-rust Multiviewon Nov 27, 2026
  5. added a commit that references this issue on Nov 29, 2026
    e1df443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

portready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions