Repository navigation
obs-source: Port the transition audio render - #4095
Merged
Merged
Conversation
rdoupe
force-pushed
the
fix/rust-port-port-the-rest-of-the-t-701
branch
from
November 9, 2026 03:14
5bd0c1a to
595463b
Compare
test_source_transition_audio pins the rest of obs-source-transition.c through the real libobs before it is ported: obs_transition_audio_render() called directly, with no audio subsystem, on a test transition whose children's audio timestamp, pending and duplicated flags and buffers the test sets, with mix callbacks that count their calls and record each sample's time. It pins the copy of slot A's whole block while idle; no timestamp (no child, a pending, removed or zero-timestamp child) writing nothing; the mix of each valid child with its callback by mixer mask and channel on top of the mix; a pending or duplicated child skipped; the place of a child's audio (a partial block, past the block, timestamp 0); each sample's time in manual and auto mode; the audio stop for each step, with the slot shift and the stop signal; a removed child the stop leaves in slot A giving no timestamp (#2185); and the state obs_transition_init() leaves. It passes 13/13 on the C build, the hybrid build and the C reference, and 30 runs in a row on the C build. Transitions need core video, so it is Linux only and skips without a display, like the other transition characterization tests. Refs #4092.
RED for #4092. obs_source::transition_audio has its API and docs, with todo!() bodies: init(), free() and audio_render() (obs_transition_init(), obs_transition_free() and obs_transition_audio_render() with the helpers it calls), generic over a Transition trait that extends transition_stop's with one method per further field read or write, mutex call, child read, buffer access and libobs call. tests/source/transition_audio.rs runs them on a fake transition that records every read and write (with the lock state), mutex, lock, graphics and libobs call and child read in order, and the time each mix callback call gets. It pins init's calls and early returns, free's order, the argument check, the copy of slot A while idle, the mix of each child by mixer mask and channel, the skip of a pending or duplicated child, the place of a child's audio, each sample's time in manual and auto mode, the audio stop for each step with the stop's slot shift under the lock and its signal after, the second read of the children after a stop (#2185), and that the mix reads only the clock copied under the lock (#3499). All 19 fail on the stubs (obs-tests-core, source::transition_audio). Refs #4092.
obs_transition_audio_render() of obs-source-transition.c is Rust, EXPORT through obs.h (rust-exports.d), and so are obs_transition_init() and obs_transition_free(), which a source's create and destroy call, hidden (rust-hidden.d). With them go the helpers the render calls: transition_live_sources(), transition_calc_min_ts(), transition_process_audio() and mix_child(). The file has no C left. The export sets of the C, hybrid and C reference builds are unchanged (1767), with init and free local. obs_source::transition_audio makes the C's reads and calls in the C's order: under transition_mutex the live children and their earliest timestamp, the clock at it, the audio stop (transition_stop's calc_time, stop and handle_stop, called in Rust), the second read of the children after a stop (#2185) and the state copy; after the lock the mix of each child with its callback, by mixer mask and channel, from the copied clock only (#3499), or the copy of slot A's whole block, then the releases and the stop's callback and signals. Init returns on a failed mutex before it makes the texrenders; free destroys the mutexes before it enters the graphics context. The shims never mirror struct obs_source: every field, flag, mutex, child audio flag and the context data go through the transition seam, on the stop shims' Seam. The libobs calls go through Calls, which extends the stop shims': obs_source_removed(), obs_source_get_audio_timestamp(), obs_source_get_audio_mix(), obs_source_get_ref(), the graphics context and the texrender calls. struct obs_source_audio_mix is mirrored as obs-source.h lays it out. The file moves from libobs.core-source into its own ported group, libobs.ported-source-transition, whose precompiled header is obs-internal.h with the transition headers it uses. Its _Static_asserts on the Rust rules' constants move verbatim into obs-source-transition-seam.c, which every build still compiles. oracle/source_transition_links.c gives obs-tests-core the libobs calls the shims name that no oracle defines (obs_source_removed(), the audio timestamp and mix reads, gs_enter_context() and gs_leave_context()), for the Windows link. Tier 1: 19/19. Tier 2: the transition, slideshow, stinger, Studio Mode, group-hide, fade and scene canvas tests pass on the C build (45 tests) and, with the _rust variants, on the hybrid and C reference builds (50 tests, 365 cases each, 0 skipped). Refs #4092. Co-Authored-By: Lain Bailey <[email protected]>
oracle/source_transition.c builds the rest of the original obs-source-transition.c renamed oracle_*, on the slots oracle's graph of test sources. Its stop helpers are the stop oracle's C, renamed after the group's headers, so the C side is the original C throughout. Its libobs calls go to recording stand-ins: the slots oracle's get_ref() and release(), and here obs_source_removed(), the audio timestamp and mix reads, the texrender create and destroy and the graphics context; a child gets a timestamp, flags and an audio block of its own. The type's mix callbacks record their calls, a hash of the times and context data they got and whether the lock was held, and can rewrite the clock, audio flag and context data on every call, as another thread may once the render lets the lock go. transition_audio_parity.rs runs the C and the Rust shims (handed the same stand-ins) on the same graph. After every call they agree on the result and ts_out, the caller's whole mix bit for bit, the slots, flags, clock, alignment and texrenders, the held mutexes, the reference and link counts, the callbacks' records and every call in order: the characterization test's cases, every audio stop step and place, a child in both slots or being destroyed, the argument check, init and free with each texrender missing, the writes after the lock, and a proptest over random graphs and requests. A layout test pins struct obs_source_audio_mix and the constants the shims pass. No intentional differences. Left out, as libobs never passes them: a sample rate of 0, more than MAX_AUDIO_CHANNELS channels and NULL mix callbacks, where the C divides by zero, reads past data[] or calls NULL. Mutation: 18 mutants planted in the core (the second read after a stop, the copied clock, the callbacks' slots, the frame offset, the mixer mask, the copy of A, the releases, the stop's place and step, the duplicated check, the order of the mix read, the empty-slot get_ref, the context data read, the pending check of the timestamps, the copied flag, and init's and free's steps); the parity test catches all 18. Refs #4092.
rust/README.md gets the row of obs-source-transition.c (its core, shims, locking, what moved to the seam file and its tiers) and names it in the obs-source and obs-source-seam rows; naming.md lists it among the seam crate's C files. The two crates' descriptions, lib.rs docs and the seam crate's README table name it too. No features line: the port changes no behaviour. Fixes #4092.
The audio callback port (#4071) added oracle/audio_callback_links.c, which defines obs_source_removed() for the same test binaries. With both, obs-tests-core fails to link on MSVC and the Linux gates with a duplicate symbol. The transition audio links keep the four calls no other oracle defines, and name where the fifth comes from. Refs #4092.
rdoupe
force-pushed
the
fix/rust-port-port-the-rest-of-the-t-701
branch
from
November 9, 2026 04:28
595463b to
2f823a4
Compare
rdoupe
marked this pull request as ready for review
November 9, 2026 05:39
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 9, 2026
This was referenced Nov 9, 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.
Fixes #4092
What and why
Ports the rest of
libobs/obs-source-transition.c.hto Rust:obs_transition_audio_render()(obs.h,EXPORT) with the helpers it calls (transition_live_sources(),transition_calc_min_ts(),transition_process_audio(),mix_child()), andobs_transition_init()/obs_transition_free(), which a source's create and destroy call (declared inobs-internal.h, hidden). Every transition plugin's audio goes through the render: scene transitions, stingers, fades and the Studio Mode T-bar. After this the file has no C left.test_source_transition_audio(new characterization test, its own commit, before RED) callsobs_transition_audio_render()directly, with no audio subsystem, on a test transition whose children's audio timestamp, flags and buffers it sets: the copy of slot A while idle, the mix of each valid child by mixer mask and channel, the place of a child's audio, each sample's time, the audio stop for each step and the removed child a stop can leave in slot A (libobs: Transition audio can take its timestamp from a removed child after the audio stop #2185), andobs_transition_init()'s state.obs_source::transition_audiois the safe core, generic over aTransitiontrait that extendstransition_stop's with one method per further field read or write, mutex call, child read, buffer access and libobs call, so each function makes the C's reads and calls in the C's order and under the C's lock. The rules it asks are the Rust ones the C asked (transition_render's audio plans,transition_sample_time,transition_clock::min_ts), and the stop helpers (transition_stop::calc_time,stop,handle_stop) are called in Rust.obs-source-seam(ffi::source_transition), on the stop shims'Seam: every field, flag, mutex, child audio flag and the context data go through the transition seam;struct obs_sourceis never mirrored.obs_source_removed(), the audio timestamp and mix reads,obs_source_get_ref(), the graphics context and the texrender calls go through aCallstrait that extends the stop shims', so the parity test can hand in the oracle's recording stand-ins.struct obs_source_audio_mixis mirrored, with a layout test against the header.transition_mutex(bug: libobs: transition audio block mixed with two clocks #3499); the children'saudio_pendingandaudio_is_duplicatedare read undertransition_mutexalone; slot A's copy is oneTOTAL_AUDIO_SIZEcopy from itsaudio_output_buf[0][0]; init returns on a failed mutex before it makes the texrenders; free destroys the mutexes before it enters the graphics context.libobs.core-sourceinto its own ported group,libobs.ported-source-transition(ported-source-sets/source-transition.json), whose precompiled header isobs-internal.hwith the transition headers it uses. Its_Static_asserts on the Rust rules' constants move verbatim intoobs-source-transition-seam.c.h, which every build still compiles.ci/test_ported_sources.pyno longer lists the file as unported C. The shims' fragments arerust-exports.d/andrust-hidden.d/obs-source-seam-source_transition.txt;oracle/source_transition_links.cgivesobs-tests-corethe libobs calls the shims name, for the Windows link.No intentional differences from C. The functions are Lain Bailey's upstream code; the port commit credits them. No
port_comparisonbench entry, as for the other seam ports. No upstream issue.RED → GREEN
obs-tests-core source::transition_audio: all 19 fail on thetodo!()core. On it,--lane lintpassed and--test-diffran 7416 tests with exactly those 19 failing (6 skipped).test_source_transition_audio13/13 on the C build, hybridlibobsandlibobs-c-reference, and 30 runs in a row on the C build.source::transition_audio): init's calls and early returns, free's order, the argument check, the idle copy, the mix by mixer mask and channel, the pending and duplicated skips, each place, each sample's time in manual and auto mode, the audio stop for each step with the stop's slot shift under the lock and its signal after, the second read after a stop, a child being destroyed, and that a callback rewriting the clock mid-mix changes no sample's time._rustvariants, on hybridlibobsandlibobs-c-reference(50 tests, 365 cases each, 0 skipped), under a private Xvfb. Export sets identical on the C, hybrid and C reference builds (1767),obs_transition_init/obs_transition_freelocal (t); the hybrid compiles no C for the unit. Two audio tests outside the unit (test_source_audio_settings,test_v4l2_vcam_audio) fail the same way on the plain C build in the sandbox (no sound server, no v4l2 loopback device).ts_out, the caller's whole mix bit for bit, the slots, flags, clock, alignment and texrenders, the held mutexes, reference and link counts, the mix callbacks' records (calls, a hash of every time and context data they got, calls with the lock held) and every call in order: the characterization test's cases, every audio stop step and place, a child in both slots or being destroyed, the argument check, init and free with each texrender missing, a callback that rewrites the clock, audio flag and context data on every call (as another thread may after the lock), and a proptest over random graphs and requests. Left out, as libobs never passes them: a sample rate of 0, more thanMAX_AUDIO_CHANNELSchannels and NULL mix callbacks. Mutation: 18 mutants planted in the core; the parity test catches all 18.ci/quick checks,./lint,--lane lint,--lane dylintand--lane crossok;soldr cargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets --locked -- -D warningsclean;soldr cargo test -p obs-c-oracle --locked --bench port_comparisonok; export sets again identical (1767); the local gate's full Tier 2 suite 816/816 against bothlibobs-c-referenceand hybridlibobs, and its Linux Rust tests 7456/7456 (6 skipped) and 914/914. The head is not stamped: the gate's rust-test lane stops in the MinGW build oforacle/output_pause_queries.c, which this PR does not touch (the open issue on the pthread probe macro redefinition, bug: obs-c-oracle: pthread probe macro redefinition blocks Fast Gate #4069), so PR CI runs the full suite. Before the rebase (runs were on 7b80a5321):--test-diff7424/7424 (6 skipped), andci/windows_link_check.pylinked every test binary. The seam parity tests passed 40 runs in a row in one process, and every transition test 30.obs_source_removed()link stand-in, so the merge result defined it twice (duplicate symbolin the Windows link check, Fast Gate and the Windows Rust tests). Rebased onto 43f2136 and dropped this PR's copy (2f823a4). Runs were on 2f823a4:ci/windows_link_check.pylinked every test binary,--test-diff origin/master7517/7517 (6 skipped),--lane lintok, export sets identical (1767), and the transition Tier 2 set 50/50 on hybridlibobsandlibobs-c-reference.reduced(0.55 s atfull) in the debug build, peak RSS 23 MB and 13 MB over 20 runs, no own threads.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)