Repository navigation
libobs: Move the transition settings and slots - #3537
Merged
Merged
Conversation
transition_valid(), transition_active() and valid_scale_type() move from obs-source-transition.c into obs-source-transition-seam.c, the private seam between the transition code and the transition fields of struct obs_source. Their bodies are unchanged; they lose only `static inline`, so the transition settings and child slot files that move out next can call them. obs-source-transition-seam.h declares them, hidden in libobs (not EXPORT), and libobs.pch.h includes it with the other transition headers. The seam is live C in libobs.core-source, ahead of the transition file, as effect-parser-lifecycle-adapter.c is in libobs.graphics. No other file of the group defines these names. No behaviour change: the export sets of the C, hybrid and C reference builds are unchanged (1767), with the three functions local. Refs #3528.
The seam gets one get and one set per transition field of struct obs_source that the transition code reads or writes (the two slots and their active flags, the video and audio flags, the clock and manual fields, the sizes, alignment, scale type, fixed duration, matrices and texrenders), and lock, unlock and trylock of transition_mutex and transition_tex_mutex. Each is a single field read or write, a matrix4_copy() for the matrices, or a single pthread_mutex_*() call returning its result; none checks its arguments or takes a lock of its own. They let the later ports of the transition settings and child slots to rust/obs-source reach the fields without the struct layout. Nothing calls them yet. Outside the transition file, libobs reads only transitioning_audio and transitioning_video (obs-scene.c) and transition_actual_cx and transition_actual_cy (obs-source.c); those reads stay as they are. The export sets of the C, hybrid and C reference builds are unchanged (1767), with the 48 accessors local. Refs #3528.
Characterization before the transition settings functions of obs-source-transition.c (obs_transition_is_active(), the scale type, alignment and size setters and getters, obs_transition_save() and the fixed duration switch) move to their own file and are ported. test_transition_scale_type pins the scale type through the drawn matrix; nothing pinned the other getters after their setters, their defaults, or what obs_transition_save() writes. test_source_transition_settings creates transitions through the real libobs. 10 cases pin: - a new transition's values: aligned left and top, 0x0, MAX_ONLY, no fixed duration, not transitioning; - each getter after each setter, any alignment and size stored as given, and out-of-range scale types stored as MAX_ONLY; - the fixed duration switch on and off, with and without a duration; - obs_transition_is_active() from the start until obs_transition_set() or obs_transition_clear() ends it; obs_transition_force_stop() only signals and leaves it transitioning (characterized, not endorsed); - NULL and a source that is not a transition: the setters do nothing and the getters return their defaults (get_size zeroes both); - the six transition_ keys obs_transition_save() writes (through obs_save_source(), as it is not exported): "" with no child, slot B while transitioning, A again once it ends, and each field read again on each save; the fixed duration is not saved. Transitions need core video, so it builds on Linux only and runs under xvfb-run, as the other transition tests; without a display the cases skip. It passes on the C, hybrid and C reference builds. Refs #3529.
obs_transition_is_active(), the scale type, alignment and size setters and getters, obs_transition_save(), obs_transition_enable_fixed() and obs_transition_fixed() move verbatim from obs-source-transition.c into obs-source-transition-settings.c, ahead of their port to rust/obs-source. They call the seam's transition_valid(), transition_active() and valid_scale_type(). The file has its own copy of lock_transition() and unlock_transition(), #undef'd at its end (BUILD.md), and is live C in libobs.core-source, after the seam. No behaviour change: every moved function's text is byte-identical to origin/master's, the export sets of the C, hybrid and C reference builds are unchanged (1767), and the transition tests, with test_source_transition_settings, pass on all three. Refs #3529.
Characterization before the child slots of obs-source-transition.c (obs_transition_clear(), obs_transition_enum_sources() and the swap of obs_transition_swap_begin(), copy_source_state() and obs_transition_swap_end()) move to their own file and are ported. test_transition_swap, test_transition_swap_active and test_transition_swap_cycle pin the swap's running state and its refusal of a cycle; nothing pinned what clear and enum_sources do with the slots, or which transition holds a reference after a swap. test_source_transition_slots creates transitions through the real libobs and sees a child's last reference go through a weak reference. 6 cases pin: - clear empties both slots, ends the transition and drops both references; clearing an empty transition, NULL or an input does nothing; - enum_sources reports slot A, then slot B, with the transition as the parent, and skips an empty slot; - the swap: between begin and end both transitions hold both children; the end clears the old one, so the new one holds the only references, running as the old one was; - what the new transition held before the swap is dropped, and an empty slot of the old one empties the new one's; - a swap of a transition with itself does nothing and returns; - the new transition, held in a slot of the old one, is not stored in itself. The swap is called as the frontend calls it, begin then end on the same pair. Transitions need core video, so it builds on Linux only and runs under xvfb-run; without a display the cases skip. It passes on the C, hybrid and C reference builds. Refs #3530.
obs_transition_clear(), obs_transition_enum_sources(), copy_source_state(), obs_transition_swap_begin() and obs_transition_swap_end() move verbatim from obs-source-transition.c into obs-source-transition-slots.c, ahead of their port to rust/obs-source. obs_transition_clear() calls the seam's transition_valid(). The file has its own copy of lock_transition(), unlock_transition(), lock_textures() and unlock_textures(), #undef'd at its end (BUILD.md), and is live C in libobs.core-source, after the settings file. The swap still takes the texture locks in begin and drops them in end, source before destination. No behaviour change: every moved function's text is byte-identical to origin/master's, the export sets of the C, hybrid and C reference builds are unchanged (1767), and the transition tests, with test_source_transition_settings and test_source_transition_slots, pass on all three. Fixes #3528. Fixes #3529. Fixes #3530.
test_source_transition_slots checked the slots, references and the running flags the swap hands over, but not the clock it copies in obs_transition_swap_begin() or the render targets it exchanges in obs_transition_swap_end(). Three more cases pin them through the real libobs: - the textures: render2 draws the old transition's children into two textures; after the swap the new transition draws into those same two; - the auto clock: once a frame has come after the start, the new transition reads the same time as the old one at the same video time (read old, new, old, retried until no frame came in between); - the manual state: a manual transition at 0.25 with a torque of 0 is handed over with its mode (saved), its value (read at once) and its target (the value stays 0.25 over the ticks that follow, where a target of 0 would snap it to 0). The clock cases wait for the tick they need, not a fixed time. Each case fails when its field is left out of the swap in libobs (the texrender exchange, start_time, manual_val, manual_target, the mode), and all 9 cases pass on the C, hybrid and C reference builds. Fixes #3528. Fixes #3529. Fixes #3530.
rdoupe
marked this pull request as ready for review
November 3, 2026 07:58
This was referenced Nov 3, 2026
This was referenced Nov 3, 2026
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.
Refs #3528
Refs #3529
Refs #3530
Fixes #3528
Fixes #3529
Fixes #3530
What and why
Three steps of "Extracting a function before porting it" for the rest of
libobs/obs-source-transition.c.h, batched in one PR because the last two use the first. There is no Rust and no change in behaviour; the ports of the settings and the child slots torust/obs-sourcecome next, each in its own PR.transition_valid(),transition_active()andvalid_scale_type()move into the newlibobs/obs-source-transition-seam.c.hwith their bodies unchanged. They lose onlystatic inline, so the other transition files of the group can call them.struct obs_source, and lock, unlock and trylock oftransition_mutexandtransition_tex_mutex. Each is one field read or write, amatrix4_copy()for the matrices, or onepthread_mutex_*()call returning its result. Nothing calls them yet: the ports will reach the fields through them without the struct layout.libobs/obs-source-transition-seam.his inlibobs.pch.hwith the other transition headers. It is marked "private adapter, not a new public API", and nothing in it is EXPORT.obs_transition_is_active(), the scale type, alignment and size setters and getters,obs_transition_save(),obs_transition_enable_fixed()andobs_transition_fixed()(ten functions) move verbatim intolibobs/obs-source-transition-settings.c.h.obs_transition_clear(),obs_transition_enum_sources(),copy_source_state(),obs_transition_swap_begin()andobs_transition_swap_end()move verbatim intolibobs/obs-source-transition-slots.c.h. The swap still takes the texture locks in begin and drops them in end, source before destination.All three files are live C in
libobs.core-source, ahead ofobs-source-transition.c.h, aseffect-parser-lifecycle-adapter.c.his inlibobs.graphics. The settings and slots files each have their own copy of the lock macros they use,#undef'd at their end (BUILD.md rule 5). No other file of the group defines the moved names.Characterization. Each move gets a test first. The tests create transitions through the real libobs (core video, so Linux under Xvfb, like the other transition tests). Odd behaviour is pinned as it is.
test_source_transition_settings(10 cases):obs_transition_is_active()up toobs_transition_set()orobs_transition_clear().obs_transition_force_stop()only signals and leaves it transitioning (characterized, not endorsed);transition_keysobs_transition_save()writes (throughobs_save_source(), since it isn't exported):""with no child, slot B while transitioning, slot A again once it ends.test_source_transition_slots(9 cases), watching each child's last reference through a weak reference:Each of the last three fails in the real libobs when its field is dropped from the swap (the texrender exchange,
start_time,manual_val,manual_target, the mode).Checked against origin/master's functions. A scratch harness (not committed) extracts master's 18 functions, with the lock macros, and the three new files whole. It builds each as its own program over one logging stand-in for
struct obs_sourceand every call they make. That covers the validity checks, the scriptedobs_source_add_active_child()results, refs and releases, active children,obs_datawrites, the logs, each lock and trylock (scripted results) and the enum callback. Each call logs its arguments, and the program dumps every field of six sources after each call. The logs of 20,000 rounds of 12 random calls (240,000 calls; random fields, sizes, scale types from the edges ofint64_t, special floats, self-held slots and same-pair swaps) are byte-identical under gcc and clang at -O0, at -O2, and at -O1 with ASan and UBSan.Across compilers, the two
obs_source_get_name()arguments ofcopy_source_state()'sblog()evaluate in either order (unspecified in C), so the logs are compared per compiler. The new build also checks each accessor: its get returns what its set stored, it changes only its own field, and each lock wrapper holds only its own mutex.All 21 planted mutants are caught:
||to&&intransition_active();is_activereading only the video flag;manual_target, inverting the texture locks, keeping the source's textures or skipping the clear;Two of these planted in the real libobs (enum order, save cx/cy) also fail the new C tests.
Field inventory (accesses at this PR's head; the plan asks for it here and on #444). Outside the transition files, libobs only reads
transitioning_audioandtransitioning_video(obs-scene.c.h176) andtransition_actual_cxandtransition_actual_cy(obs-source.c.h2264 and 2286). The seam's two accesses per field are its get and set.transition_sourcesobs-source-transition.c.h26,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h1,obs-source-transition-slots.c.h7transition_source_activeobs-source-transition.c.h13,obs-source-transition-seam.c.h2,obs-source-transition-slots.c.h5transitioning_videoobs-scene.c.h1,obs-source-transition.c.h15,obs-source-transition-seam.c.h3,obs-source-transition-slots.c.h2transitioning_audioobs-scene.c.h1,obs-source-transition.c.h15,obs-source-transition-seam.c.h3,obs-source-transition-slots.c.h2transition_modeobs-source-transition.c.h7,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h1,obs-source-transition-slots.c.h1transition_manual_valobs-source-transition.c.h7,obs-source-transition-seam.c.h2,obs-source-transition-slots.c.h1transition_manual_targetobs-source-transition.c.h5,obs-source-transition-seam.c.h2,obs-source-transition-slots.c.h1transition_manual_torqueobs-source-transition.c.h3,obs-source-transition-seam.c.h2transition_manual_clampobs-source-transition.c.h2,obs-source-transition-seam.c.h2transition_start_timeobs-source-transition.c.h3,obs-source-transition-seam.c.h2,obs-source-transition-slots.c.h1transition_durationobs-source-transition.c.h3,obs-source-transition-seam.c.h2,obs-source-transition-slots.c.h1transition_cxobs-source-transition.c.h3,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h3transition_cyobs-source-transition.c.h3,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h3transition_actual_cxobs-source.c.h1,obs-source-transition.c.h2,obs-source-transition-seam.c.h2transition_actual_cyobs-source.c.h1,obs-source-transition.c.h2,obs-source-transition-seam.c.h2transition_alignmentobs-source-transition.c.h3,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h3transition_scale_typeobs-source-transition.c.h2,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h3transition_use_fixed_durationobs-source-transition.c.h1,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h2transition_fixed_durationobs-source-transition.c.h1,obs-source-transition-seam.c.h2,obs-source-transition-settings.c.h1transition_matricesobs-source-transition.c.h6,obs-source-transition-seam.c.h2transition_texrenderobs-source-transition.c.h13,obs-source-transition-seam.c.h2,obs-source-transition-slots.c.h4transition_mutexobs-source-transition.c.h5,obs-source-transition-seam.c.h3,obs-source-transition-settings.c.h2,obs-source-transition-slots.c.h2transition_tex_mutexobs-source-transition.c.h6,obs-source-transition-seam.c.h3,obs-source-transition-slots.c.h2No upstream issue.
RED → GREEN
f48febdc0,37aaffdf8,a40f94631) pass on origin/master's C.a40f94631.test_transition_*with their_rusttwins,test_group_hide_transition_audio, and the two new tests) pass on the C build (19 tests), the hybrid libobs (24) andlibobs-c-reference(24), with no case skipped, under a private Xvfb. The new tests run 10 and 9 cases on each. Once, under-j4,test_transition_removed_child_audioskipped itsstop_tick_ignores_removed_childcase on the C build (its own guard for when the video thread stops the transition first); alone it passed 3 of 3.t).--test-diff origin/masterpassed (workspace: 6344 passed, 6 skipped).--lane lintpassed every check but the Dylints, and--lane crosspassed its MSVC clippy but not its Dylints. This machine has no Dylint driver for the nightly master pinned on 2026-11-02, and building one fails. This PR changes no Rust.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)