Skip to content

libobs: characterize and extract obs_save_sources_filtered and obs_save_sources (Refs #5564) - #5566

Merged
rdoupe merged 2 commits into
masterfrom
test/5564-save-sources
Nov 24, 2026
Merged

rdoupe merged 2 commits into
masterfrom
test/5564-save-sources

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a live-core C characterization of obs_save_sources_filtered() and obs_save_sources(), the scene-collection save every frontend uses, then moves them verbatim from libobs/obs.c.h into libobs/obs-save-sources.c.h, a member of the core unity group (libobs/build/libobs.core+.h.c, alphabetical): obs_save_sources_filtered(), the static save_source_filter() and obs_save_sources(). test_save_sources is registered once in the canonical test graph with its tests.d marker. No behavior change; existing C tests and public headers are unchanged.

Refs #5564. This is the C-only prerequisite; the Rust swap is tracked separately.

What the test pins

Live core: obs_startup plus obs_reset_video with the OpenGL module, like test_task_queue_entry_points; it skips without a display.

  • an empty core: both calls return a new, empty array (not NULL) that the caller owns: two calls give two arrays, and an entry the caller pushes into one is not in the next;
  • obs_save_sources() saves every public input and scene in creation order, each entry equal to obs_save_source() of that source (name, uuid, id, versioned_id, and the whole entry's JSON);
  • it leaves out filters (an attached filter appears only in its parent's filters array), private inputs and scenes, hidden sources (obs_source_set_hidden; shown again, they are saved again in their place), sources after obs_source_remove while the caller still holds them, and sources whose last reference was released;
  • obs_save_sources_filtered(cb, param) calls cb once per candidate, in creation order, with param unchanged, never for an excluded source, and keeps exactly the sources cb returns true for (four keep masks, including none and all);
  • the save keeps each source's refcount: after repeated saves the sources are still alive while the caller holds them, and the caller's release destroys them (checked through weak references).

Two things the public API cannot pin directly:

  • The filter-type check on its own. obs_source_create() always makes a filter private, so the info.type != OBS_SOURCE_TYPE_FILTER condition is only observable together with the private check (see the mutation check below, where dropping the private check still leaves filters out).
  • The window between a source's last release and its removal from the source list. It is not reachable through the public API, so "released" is pinned once the source is gone. The video thread takes a short reference on every source each tick, so the test waits (bounded, 10 s) for a released source through a weak reference rather than counting references.

Evidence

  • RED (4d68dc68b): adds the characterization without registering it, as in libobs: characterize and extract the task queue entry points (Refs #5560) #5561. git show 4d68dc68b:test/cmocka/build/test-graph.json | grep -c test_save_sources prints 0, so the build has no test_save_sources target.
  • GREEN (2cff0dd7d): registers the test and extracts the three functions. The new file's body after its 2-line header is lines 2045-2084 of origin/master's obs.c.h, byte for byte (diff <(git show origin/master:libobs/obs.c.h | sed -n '2045,2084p') <(tail -n +3 libobs/obs-save-sources.c.h) prints nothing).
  • OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 --tests test_save_sources: full Linux Tier 2 passed against the C reference (100% tests passed, 0 tests failed out of 1094) and hybrid libobs (100% tests passed, 0 tests failed out of 1094), then test_save_sources passed 3 repeats against each (100% tests passed, 0 tests failed out of 1, twice). It takes about 1.0 s.
  • To prove the cases ran rather than skipped, I ran the built binary from the kept build volume (docker run --init, xvfb-run -a, in the ctest working directory): [ PASSED ] 5 test(s) against /build/tree/libobs/libobs.so.30 and again with LD_LIBRARY_PATH=/build/tree/libobs-c-reference; ldd confirmed each library, and nothing was skipped.
  • Mutation check: with !source->context.private && dropped from obs_save_sources_filtered() and both libraries rebuilt in the kept volume, the binary failed against each: leaves_out_filters_private_hidden_removed_and_released (5 != 3: the private input and scene were saved; the filters stayed out through the type check), filtered_calls_back_per_candidate_and_keeps_true and save_keeps_refcount ([ FAILED ] tests: 3 test(s), both libraries). After reverting, both passed 5 of 5 again.
  • ./lint passed.

Not run locally: native Windows/macOS (the test is Linux/OpenGL only, like the other live-core graphics tests). Tier 1/3 and Tier 4 do not apply to a C-only extraction. No docs/features.md line: nothing a user can notice changes.

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 24, 2026 01:39
…sources, not yet registered (Refs #5564)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…im (Refs #5564)

Moves obs_save_sources_filtered(), the static save_source_filter() and
obs_save_sources() unchanged from obs.c.h into obs-save-sources.c.h, a
member of the core unity group, and registers test_save_sources in the
canonical test graph so it runs against hybrid libobs and the C reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795503360,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":93,"stamp":"c063988138b574cd52484d013c9abbd3","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503360,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":93,"stamp":"1c9d90624566159813874b3ac9815fb9","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503360,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":93,"stamp":"e63d8a667553c58e50b68fd2475bdd74","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503360,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":93,"stamp":"5f3c981e56877afa0287ba2ac632fc59","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"general/all/client-lint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"9344eb47b5b47fb11f84be530090ebdd","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503360,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":93,"stamp":"1cdaaf1a2667a8ae6d87f0f8c763ae2b","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"e8e9762dd5316dec211ec0e20ff77bda","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"b5d1950d124f3959e4a697c585f0e555","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"26f65209b0b0a6398b2a423d5bb274cd","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"a8d0f3b7e3090bbc77a42459a8fdd696","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"73a051bf824aa71f6777cdcce065ee28","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"a11fe66f1f33b3599efad401564a8d50","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"f74cb8e60925f1a866f1a8a0380a0ef5","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"cb78619eee036971b5c7ca4490eb1047","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"33848b3600e56b8a0d849c51f92f7f10","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"aeca5aaff660745fed768123c173e16f","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"ad7e58f10fe9c0aabf778b8886c70115","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503266,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"47d311b24a3d811e40bbeb5fad2934e54a55b103715d1af8435e56d1ff5a1085","lane":"client-lint","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":11,"stamp":"47d48cb15c1e9e7fc33c38d37f7d6182","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}
Ci-Attestation: {"at":1795503608,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"3e69d4966083b2f99c916eca736a836ce9317f6f0325f323c5346d304e600b26","lane":"client-test-x86_64-unknown-linux-gnu","parents":["4d68dc68bff11212d56a365207e5d2be01f17e4a"],"secs":247,"stamp":"7a8f655997cb5c901fbee361ae9d6fbe","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"b8c66a35f8f8eb9eade5750253ace32b4b33cef3","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/obs-save-sources.c.h","libobs/obs.c.h","test/cmocka/build/test-graph.json","test/cmocka/test_save_sources.c","test/cmocka/tests.d/test_save_sources.cmake"],"head":"01164ee1df708bcca197c345c06d8b54c48da82e","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":"8354f7750d32302112d58bd5081689ea0c096eab06c48519e2485b01ac896cae","tree":"a6ed50fbff4298b7cf8b1ddc16b16f66b232b99e"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 24, 2026 07:00
@rdoupe rdoupe changed the title libobs: extract obs_save_sources_filtered and obs_save_sources verbatim (Refs #5564) libobs: characterize and extract obs_save_sources_filtered and obs_save_sources (Refs #5564) Nov 24, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 24, 2026
Merged via the queue into master with commit 7481a12 Nov 24, 2026
46 checks passed
@rdoupe
rdoupe deleted the test/5564-save-sources branch November 24, 2026 08:00
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.

1 participant