Skip to content

libobs: characterize and extract obs_enum_sources and the source/canvas enumerators (Refs #5493) - #5494

Merged
rdoupe merged 2 commits into
masterfrom
test/enum-sources-extract
Nov 23, 2026
Merged

rdoupe merged 2 commits into
masterfrom
test/enum-sources-extract

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a C characterization of obs_enum_sources, obs_enum_all_sources, obs_enum_canvases and obs_canvas_enum_scenes (on a non-main canvas), then moves them (with their static helper obs_enum_uuid) verbatim from libobs/obs.c.h into libobs/obs-enum-sources.c.h, a member of the core unity group (libobs/build/libobs.core+.h.c, alphabetical, right after obs-enum-scenes-fields.c.h). test_enum_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 #5493. This is the C-only prerequisite; the Rust swap follows separately (as obs_set_audio_monitoring_device did in #5490).

What the test pins

test_enum_scenes already pins obs_canvas_enum_scenes through the main-canvas wrapper obs_enum_scenes. The new test covers the rest. Each case starts its own core.

  • obs_enum_sources: of a public input, a private input, a scene, a filter, a group, a second public input, a private group and a private scene (created in that order), only the two inputs and the group are visited, in creation order. Each callback sees one reference held (count + 1), and every count is back where it was afterwards.
  • Early stop: a false return on the first input, on the group or on the last input ends the walk there, with every reference released.
  • A source with no reference left (the window between the last release and its removal, simulated by setting the count to -1) is skipped by obs_enum_sources and still visited by obs_enum_all_sources.
  • obs_enum_all_sources: every one of the eight sources, private ones included, in creation order, with no reference taken; a false return stops it at each position.
  • Transitions: a transition between two inputs is not visited by obs_enum_sources, and is visited by obs_enum_all_sources. A transition needs a graphics device to be created, so this one case resets video and checks only which sources are visited (the video thread references sources while it ticks them). The other cases run without a video thread, so their reference counts are exact.
  • obs_enum_canvases: with no other canvas, only the main canvas. With two public canvases and a private one: main, then the two public ones in creation order, no reference taken; a false return stops it. A removed canvas stays in the walk while it is still referenced and leaves it once destroyed.
  • obs_canvas_enum_scenes on a non-main canvas: its three scenes in creation order, each referenced for the call and released after, not a main-canvas scene created between them; a false return stops it. The main canvas walk sees only its own scene.

Like test_item_transition_empty_source, the target needs Linux with OpenGL (OS_LINUX, HAVE_OBS_OPENGL) and runs in the graphics suite.

The move

obs-enum-sources.c.h sorts before obs.c.h in the group. obs_enum_sources compares against group_info, which obs.c.h declares later in the group, so the new file declares extern const struct obs_source_info group_info; itself, as obs-scene-kind.c.h does. Nothing else in obs.c.h uses obs_enum_uuid. Only the group includes the new file.

Evidence

  • Characterization first (test: commit 5df6cdd): the test and its registration alone, against the C still in obs.c.h. OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_enum_sources|test_enum_scenes': full Linux Tier 2 passed on the C reference and hybrid libobs (1087/1087 each), then the two related tests again on each (2/2).
  • Move (libobs: commit 549404e): the 89 moved lines are identical (diff) to the lines removed from obs.c.h (plus one blank separator); the new file only adds the group's PCH include and the group_info declaration.
  • Same Tier 2 command on the final branch: 1087/1087 on each library, 2/2 on each repeat; exported symbols C vs Rust identical (1769).
  • Cases ran, none skipped: the binary run directly in the kept Tier 2 volume (under xvfb-run, from the graphics working directory) prints Running 8 test(s) and PASSED 8 test(s) on both libraries.
  • Mutation checks (rebuilt libobs and libobs-c-reference in the kept Tier 2 volume, run on both libraries, then reverted, then 8/8 again on both):
    • private skip dropped in obs_enum_sources (if (!s->context.private) → if (1)): enum_sources_visits_public_inputs_and_groups (5 visited instead of 3, line 281), enum_sources_stops_on_false and enum_sources_skips_source_without_references fail; 5 of 8 pass.
    • group branch dropped (strcmp(s->info.id, group_info.id) == 0 → false): the same three cases fail (2 visited instead of 3); 5 of 8 pass.
    • obs_enum_canvases ignores a false return: only enum_canvases_visits_named_canvases fails (3 visited instead of 1, line 426); 7 of 8 pass.
  • ./lint passes.

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 23, 2026 01:02
… (Refs #5493)

obs_enum_sources calls back for public inputs and public groups only,
never private sources, scenes, filters or transitions, in creation
order, with one reference held for each call and released after; a
source with no reference left is skipped and a false return stops the
walk with every reference balanced. obs_enum_all_sources visits every
source, private ones included, in creation order, without references.
obs_enum_canvases visits the named canvases, main first, without
references; private canvases are absent and a removed one stays until
destroyed. obs_canvas_enum_scenes on a non-main canvas visits only its
scenes, each referenced for the call. Each stops on false.

The transition case resets video, since a transition needs a graphics
device; the other cases run without a video thread so the reference
counts are exact. Linux with OpenGL, like test_item_transition_empty_source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efs #5493)

Moves obs_enum_sources, obs_canvas_enum_scenes, the static inline
obs_enum_uuid, obs_enum_all_sources and obs_enum_canvases verbatim from
obs.c.h into obs-enum-sources.c.h, a member of the core unity group
(alphabetical, after obs-enum-scenes-fields.c.h), ahead of their Rust
swap. Only obs_enum_all_sources used obs_enum_uuid. The new file sorts
before obs.c.h, which declares group_info, so it declares group_info
itself, as obs-scene-kind.c.h does. No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795415442,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":94,"stamp":"57e66c48c04eccfacd963133cb322c94","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415442,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":94,"stamp":"18fdb95a6ebc8779e3c8b19a32a9fe55","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415442,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":94,"stamp":"616172e95e74b813766b86749dd8f0cd","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415442,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":94,"stamp":"9d2249009c8f8992f679523104e92539","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415347,"gate":"general/all/client-lint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"d3b85a7d4eb8e81ad53d3ea0d9e0b35d","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415442,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":94,"stamp":"591deb6331b19cb88cc82e7e43b56b55","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"3ff4cccb7a995ab7df58ac81efd3e252","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"e4b6c29bf31b3324e88447e88b2a141a","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"d9e34914884568c873b6f6a77dd3737f","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"c16d2b639e9ddf34b205a754c0ec0ed2","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"0862e2e805238cf650a00f553830bcd2","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"71006449d4896789a3ddbf1a1cc31f59","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"a14222fdde5926211f446b7ca201b5c6","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"b2df45b63d6ff466fe7d7dcdadbaca25","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"9099bed971ed43ca0de844c9886a0e7a","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415348,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"e77da54850e886e5fb2524ebea454895","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415347,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"bcefa58dcf03c52d9e0a2779953fdc40","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415347,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b3cb196e06118f1b4e2123e11552f186419a7c599e1d02f74c3e81977f5da20b","lane":"client-lint","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":12,"stamp":"97ccfec233ca1c5f2ce5ce7b4fb10b5c","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}
Ci-Attestation: {"at":1795415663,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"04401f2f6eca1e9eaf972ce3d2cdb1ff94dbbca0795128855b10f4bc6b34c592","lane":"client-test-x86_64-unknown-linux-gnu","parents":["5df6cdde82469025e0180b0471ea195a7b90b704"],"secs":219,"stamp":"2d4544581ceb1f6f132d0b1e4b7d9e3b","tree":"83fc512dc146494862fe3cb0c42dc636459f5979","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"b0806bb796050bb254015051233dbebbd53440e2","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/obs-enum-sources.c.h","libobs/obs.c.h","test/cmocka/build/test-graph.json","test/cmocka/test_enum_sources.c","test/cmocka/tests.d/test_enum_sources.cmake"],"head":"da2ce0df533b10b5ee9785433be23ac5e6aa1e44","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":"9fcc2676a87752c0cc853ed0ac7bb602c1e97e92b039490b70443f41e1389222","tree":"83fc512dc146494862fe3cb0c42dc636459f5979"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 23, 2026 06:34
@rdoupe rdoupe changed the title libobs: extract obs_enum_sources and the source/canvas enumerators (Refs #5493) libobs: characterize and extract obs_enum_sources and the source/canvas enumerators (Refs #5493) Nov 23, 2026
@rdoupe
rdoupe enabled auto-merge November 23, 2026 06:34
@rdoupe
rdoupe added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit 81d3adb Nov 23, 2026
46 checks passed
@rdoupe
rdoupe deleted the test/enum-sources-extract branch November 23, 2026 07:17
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