Repository navigation
libobs: Move the scene item visibility audio ramp into obs-scene-audio-actions.c - #1815
Merged
zackees merged 2 commits intoOct 22, 2026
Merged
Conversation
Characterization before the visibility audio ramp of obs-scene.c (apply_scene_item_audio_actions, apply_scene_item_volume and process_all_audio_actions) moves to its own file and is ported to obs-scene. test_preview_only_hide, test_group_hide_transition_audio and test_group_active_refs check that a hide is applied and what it deactivates, but none checks the sample it lands on. test_scene_audio_actions links the real libobs, plays constant-level tones in the program scene, and captures the program mix (track 1) with obs_add_raw_audio_callback(). It reads only the item's active_refs, its queued actions and the source's activate_refs besides the public API, as test_group_hide_transition_audio does, so it also runs the hybrid libobs. The action time is taken inside obs_sceneitem_set_visible(), so each case brackets the call with os_gettime_ns() and accepts exactly the samples a time in that bracket maps to (floor((t - tick) * rate / 1e9)): the check does not depend on how fast the machine is, and the waits only bound how long it waits for the audio thread. 4 cases pin: - a hide of the only audible item: the mix is the tone up to that sample and silent from it on, the ticks contiguous; the item's one active reference is dropped and the source deactivated; - a hide of one of two items: only its part of the mix stops, on its sample; - a show over a second item: its part starts on its sample, and the show takes its active reference at once, not when it is applied; - hide, show, hide back to back: all three are applied, the item ends hidden and the mix silent, and the two hides drop both references (one from the add, one from the show), so the source is deactivated. Applying the actions needs core video and audio, so it builds on Linux only and runs under xvfb-run, like test_group_hide_transition_audio; without a display the cases skip. Refs obs-rust#1814
…o-actions.c Behavior-neutral extraction before the Rust port: the three functions of obs-scene.c.h that apply the queued show/hide actions of a scene item on the samples they fall on move verbatim into libobs/obs-scene-audio-actions.c.h: - apply_scene_item_audio_actions(): consumes the actions in the tick, fills the 0/1 gain buffer and drops one active reference per hide; - apply_scene_item_volume(): applies them when the first one falls in the tick; - process_all_audio_actions(): applies every queued action. The only change is that they lose static: scene_video_tick() and scene_audio_render() stay in obs-scene.c.h and call them. They are declared in obs-internal.h without EXPORT, so -fvisibility=hidden keeps them local symbols, and the forward declaration before scene_video_tick() goes. The lock, the active_refs decrement and obs_source_remove_active_child() stay in the moved code for now; the accessor and the port come after. The new file joins libobs.core-source just before obs-scene.c.h, with libobs.pch.h. No group, PCH or source-sets.json change, and the exported symbols are unchanged (1766). New test test_scene_audio_action_steps compiles the moved file (ASan and UBSan, no libobs core) and calls only the three functions, with a fake scene item (the real struct, zeroed) whose scene has no source, so obs_source_remove_active_child() only logs its NULL parent and the test counts the removals from the log. 15 cases pin, as exact buffers, queues and counts: - the change on each of the 1024 frames at 48 kHz, and on chosen frames at 11 rates from 8 kHz to 192 kHz; one nanosecond earlier is one frame earlier; - an action on frame 1024 stays queued; one before the tick lands on frame 0; several in one tick, two on one frame; later ones stay queued in order and the next tick places them from its start; - the hide count: one reference per hide, the child removed once at 0; - ts 0 (the preview-only path) and process_all_audio_actions() apply everything, future actions included; - apply_scene_item_volume(): nothing queued, the window of ts plus the rounded-down tick duration, the first action only, ts 0; - that nothing is written past the tick. Characterized, not endorsed: actions out of time order (a change timed before the previous one does not reach the buffer but is counted, and a due action waits behind one that is not); an action at ts + duration at 44.1 kHz falls on frame 1023 but waits for the next tick; more hides than references go below 0. It is in the obs-build C test manifest. test_scene_audio_actions passes unchanged. Refs obs-rust#1814
This was referenced Oct 22, 2026
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 22, 2026
…tick (obs-rust#1835) test_scene_audio_actions (obs-rust#1815) failed now and then on a loaded machine, for example hide_only_item seeing the hide on sample 0 instead of 833. Each case requires every tone of the scene to have its audio in each tick it captures. When a tone's thread wakes too late for a tick, libobs marks the tone's audio pending and leaves it out of that tick. If that tone is the scene's only audible source, the scene has no audio in the tick and libobs applies every queued action at once (process_all_audio_actions(), characterized in obs-rust#1815), so a hide lands on sample 0. Otherwise the tick's mix is missing that tone. Neither says where the action would have landed. The capture now records, in the raw audio callback, which tones of the scene libobs left out of each tick. The callback runs on the audio thread right after the tick is rendered, so it reads that tick's audio_pending, which comes from the tone's buffer, not from the ramp code under test. A toggle whose capture has such a tick is undone (toggled back, the mix back at its level) and tried again, up to the test's existing deadline. The checks are unchanged, on the try whose ticks all had their tones' audio. show_over_other_item now shows through toggle() too, so its show is retried the same way; its first hide only sets up the case. Fixes obs-rust#1834
This was referenced Oct 22, 2026
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 23, 2026
Ports libobs/obs-scene-audio-actions.c.h, the core of the scene item visibility audio ramp (obs-rust#1825), to the audio_actions module of rust/obs-scene. The item side stays C in obs-scene-item-audio-actions.c.h: actions_mutex, the active reference dropped per hide and obs_source_remove_active_child(), apply_scene_item_volume() and process_all_audio_actions(). The hybrid libobs drops the C core and links the Rust shims in its place. Safe core (src/audio_actions.rs): apply() reads the queue in order, places each action on frame floor((timestamp - ts) * rate / 1e9) through util_mul_div64 as the C computes it on each host, a late one on frame 0, stops at the first one on frame 1024 or later (with ts 0 it takes them all), fills the gain buffer with the visibility before each change and the rest of the tick with the last one, and returns the actions consumed (a prefix), the visibility and the hide count. action_due() is the window, ts plus 1024 frames in ns rounded down, with the C's wrapping sum. It keeps no state, takes no lock, and denies clippy's panic, indexing and arithmetic lints. obs-scene does not depend on obs-util: util_mul_div64 and the darray erase are written out in this crate. test_scene_bounds_place_rust links the staticlib for obs-scene alone, and the obs-util objects bring in that crate's system libraries (libuuid, GIO, winmm and the base log handler on Windows), which that test does not link. Shim (src/ffi/scene_audio_actions.rs): obs_scene_audio_actions_apply() and obs_scene_audio_action_due() keep the C signatures. The queue is the item's obs_scene_item_action_array_t, mirrored with the layout of struct darray and read in place. The consumed actions are erased from the front one at a time, each as the C's da_erase(*actions, i--) with i 0 does (num minus one, then a memmove of the rest down by one item), so the memory left in the array, stale items included, is the C's. The erase allocates and frees nothing. *visible is written only when an action was consumed. Kept, characterized, not endorsed (obs-rust#1815): actions out of time order are left out of the buffer but counted; the loop and the window stop at the first action that is not due; the window rounds the tick down to whole ns (44.1 kHz); every hide is counted, without bound; with ts 0 every action is applied. Intentional differences, where C has undefined behaviour and libobs never gets there: with ts 0 and a buffer, the C writes past the 1024 gains, and the Rust writes the same gains inside them and none past them; obs_scene_audio_action_due() with a rate of 0 (the C divides by 0) returns true, as apply() puts every action on frame 0 at rate 0; a null queue or visibility does nothing and returns 0; on MSVC x64, where the C's 128-bit util_mul_div64 faults (a rate above 1 GHz), the core saturates. C side: the file leaves libobs.core-source for its own group, libobs.ported-scene-audio-actions (LIBOBS_PORTED_SOURCES), whose PCH is obs-scene-audio-actions.h with media-io/audio-io.h and util/util_uint64.h. The two functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. The exported symbol sets are unchanged (1766). test_scene_audio_action_steps still compiles the C core into itself, unchanged; test_scene_audio_actions, test_preview_only_hide, test_group_hide_transition_audio, test_group_active_refs and test_item_transition_empty_source see the swap through the real libobs. ci/test_ported_sources.py checks the group on every host. Tier 1 scene::audio_actions passes 23/23. Refs obs-rust#1814
zackees
pushed a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 23, 2026
Ports libobs/obs-scene-audio-actions.c.h, the core of the scene item visibility audio ramp (obs-rust#1825), to the audio_actions module of rust/obs-scene. The item side stays C in obs-scene-item-audio-actions.c.h: actions_mutex, the active reference dropped per hide and obs_source_remove_active_child(), apply_scene_item_volume() and process_all_audio_actions(). The hybrid libobs drops the C core and links the Rust shims in its place. Safe core (src/audio_actions.rs): apply() reads the queue in order, places each action on frame floor((timestamp - ts) * rate / 1e9) through util_mul_div64 as the C computes it on each host, a late one on frame 0, stops at the first one on frame 1024 or later (with ts 0 it takes them all), fills the gain buffer with the visibility before each change and the rest of the tick with the last one, and returns the actions consumed (a prefix), the visibility and the hide count. action_due() is the window, ts plus 1024 frames in ns rounded down, with the C's wrapping sum. It keeps no state, takes no lock, and denies clippy's panic, indexing and arithmetic lints. obs-scene does not depend on obs-util: util_mul_div64 and the darray erase are written out in this crate. test_scene_bounds_place_rust links the staticlib for obs-scene alone, and the obs-util objects bring in that crate's system libraries (libuuid, GIO, winmm and the base log handler on Windows), which that test does not link. Shim (src/ffi/scene_audio_actions.rs): obs_scene_audio_actions_apply() and obs_scene_audio_action_due() keep the C signatures. The queue is the item's obs_scene_item_action_array_t, mirrored with the layout of struct darray and read in place. The consumed actions are erased from the front one at a time, each as the C's da_erase(*actions, i--) with i 0 does (num minus one, then a memmove of the rest down by one item), so the memory left in the array, stale items included, is the C's. The erase allocates and frees nothing. *visible is written only when an action was consumed. Kept, characterized, not endorsed (obs-rust#1815): actions out of time order are left out of the buffer but counted; the loop and the window stop at the first action that is not due; the window rounds the tick down to whole ns (44.1 kHz); every hide is counted, without bound; with ts 0 every action is applied. Intentional differences, where C has undefined behaviour and libobs never gets there: with ts 0 and a buffer, the C writes past the 1024 gains, and the Rust writes the same gains inside them and none past them; obs_scene_audio_action_due() with a rate of 0 (the C divides by 0) returns true, as apply() puts every action on frame 0 at rate 0; a null queue or visibility does nothing and returns 0; on MSVC x64, where the C's 128-bit util_mul_div64 faults (a rate above 1 GHz), the core saturates. C side: the file leaves libobs.core-source for its own group, libobs.ported-scene-audio-actions (LIBOBS_PORTED_SOURCES), whose PCH is obs-scene-audio-actions.h with media-io/audio-io.h and util/util_uint64.h. The two functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. The exported symbol sets are unchanged (1766). test_scene_audio_action_steps still compiles the C core into itself, unchanged; test_scene_audio_actions, test_preview_only_hide, test_group_hide_transition_audio, test_group_active_refs and test_item_transition_empty_source see the swap through the real libobs. ci/test_ported_sources.py checks the group on every host. Tier 1 scene::audio_actions passes 23/23. Refs obs-rust#1814
4 of 7 tasks
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 23, 2026
* obs-scene: Add Tier 1 tests for the scene audio action ramp port RED for the port of libobs/obs-scene-audio-actions.c.h, the core of the scene item visibility audio ramp, to a new module, audio_actions, of rust/obs-scene. The safe core is a stub (todo!()): ItemAction (the queued visibility and time), Applied (the actions consumed, the visibility after them and the hides among them), frame() (the frame of the tick an action falls on), apply() (obs_scene_audio_actions_apply(), over the queue in order, with an optional gain buffer), tick_duration() and action_due() (obs_scene_audio_action_due()). tests/scene/audio_actions.rs ports test_scene_audio_action_steps 1:1, under the same case names (steps_*), in the same order, with the same steps and expectations: all 17 cases. A small model repeats the C item side around the core: the queue, the visibility, the active references and the child removal at 0, apply_scene_item_volume() and process_all_audio_actions(). The buffer has one gain past the tick, which no case may write. New edge cases (edge_*): the frame helper (late, exact, one ns before, ts 0, rate 0, u64::MAX), the window wrapping at the end of the u64 range, the core reading no further than the first action past the tick, the exact 1.0 and 0.0 gains, and the two intentional differences: with ts 0 and a buffer the fill stops at the buffer end (the C writes past it), and a rate of 0 makes every action due (the C divides by 0). soldr cargo test -p obs-data --test obs-tests-core scene::audio_actions fails 22 of 23 with "not yet implemented". The one that passes, steps_volume_without_actions, never reaches the core. Refs obs-rust#1814 * obs-scene: Port the scene audio action ramp core Ports libobs/obs-scene-audio-actions.c.h, the core of the scene item visibility audio ramp (obs-rust#1825), to the audio_actions module of rust/obs-scene. The item side stays C in obs-scene-item-audio-actions.c.h: actions_mutex, the active reference dropped per hide and obs_source_remove_active_child(), apply_scene_item_volume() and process_all_audio_actions(). The hybrid libobs drops the C core and links the Rust shims in its place. Safe core (src/audio_actions.rs): apply() reads the queue in order, places each action on frame floor((timestamp - ts) * rate / 1e9) through util_mul_div64 as the C computes it on each host, a late one on frame 0, stops at the first one on frame 1024 or later (with ts 0 it takes them all), fills the gain buffer with the visibility before each change and the rest of the tick with the last one, and returns the actions consumed (a prefix), the visibility and the hide count. action_due() is the window, ts plus 1024 frames in ns rounded down, with the C's wrapping sum. It keeps no state, takes no lock, and denies clippy's panic, indexing and arithmetic lints. obs-scene does not depend on obs-util: util_mul_div64 and the darray erase are written out in this crate. test_scene_bounds_place_rust links the staticlib for obs-scene alone, and the obs-util objects bring in that crate's system libraries (libuuid, GIO, winmm and the base log handler on Windows), which that test does not link. Shim (src/ffi/scene_audio_actions.rs): obs_scene_audio_actions_apply() and obs_scene_audio_action_due() keep the C signatures. The queue is the item's obs_scene_item_action_array_t, mirrored with the layout of struct darray and read in place. The consumed actions are erased from the front one at a time, each as the C's da_erase(*actions, i--) with i 0 does (num minus one, then a memmove of the rest down by one item), so the memory left in the array, stale items included, is the C's. The erase allocates and frees nothing. *visible is written only when an action was consumed. Kept, characterized, not endorsed (obs-rust#1815): actions out of time order are left out of the buffer but counted; the loop and the window stop at the first action that is not due; the window rounds the tick down to whole ns (44.1 kHz); every hide is counted, without bound; with ts 0 every action is applied. Intentional differences, where C has undefined behaviour and libobs never gets there: with ts 0 and a buffer, the C writes past the 1024 gains, and the Rust writes the same gains inside them and none past them; obs_scene_audio_action_due() with a rate of 0 (the C divides by 0) returns true, as apply() puts every action on frame 0 at rate 0; a null queue or visibility does nothing and returns 0; on MSVC x64, where the C's 128-bit util_mul_div64 faults (a rate above 1 GHz), the core saturates. C side: the file leaves libobs.core-source for its own group, libobs.ported-scene-audio-actions (LIBOBS_PORTED_SOURCES), whose PCH is obs-scene-audio-actions.h with media-io/audio-io.h and util/util_uint64.h. The two functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. The exported symbol sets are unchanged (1766). test_scene_audio_action_steps still compiles the C core into itself, unchanged; test_scene_audio_actions, test_preview_only_hide, test_group_hide_transition_audio, test_group_active_refs and test_item_transition_empty_source see the swap through the real libobs. ci/test_ported_sources.py checks the group on every host. Tier 1 scene::audio_actions passes 23/23. Refs obs-rust#1814 * obs-scene: Check the scene audio action ramp port against the C Oracle (oracle/scene_audio_actions.c): the original obs-scene-audio-actions.c.h, unmodified, with its two functions renamed to oracle_*, plus the layout of struct item_action, of obs_scene_item_action_array_t and AUDIO_OUTPUT_FRAMES. da_erase and util_mul_div64 stay the header inlines, so the oracle erases with the C's darray code and the shim with the Rust port. Tier 3 (tests/scene/audio_actions_parity.rs): each run gives both sides the same queue (the same bytes in the same capacity, padding and spare slots included), visibility, tick, rate and gain buffer, and compares the hide count, the visibility, the darray (array not moved, num, capacity and every byte of the capacity), the gains bit for bit with a guard gain past the tick, and the window for every action's time. Runs: - the layout; - every queue of up to 3 actions over 8 chosen times (before the tick, frames 0, 1, 511, the last ns of 1023, 1024 and 2000, and the first time where since * rate wraps a u64), with each start visibility, with and without a buffer, at 48 and 44.1 kHz, on a tick and with ts 0: 69 904 runs; - 20 000 random queues of up to 40 actions in any time order, at 0, near the tick, near u64::MAX and at the wrap points, ticks at 0, near 0, anywhere and near u64::MAX, and rates from 8000 to 192000 plus 0, 1, odd ones, 1 GHz and (not on MSVC) rates where util_mul_div64 wraps; - 20 000 random windows, at the edge of the window too. Excluded, the intentional differences: with ts 0 and a buffer the C writes past the tick, so the oracle gets a buffer large enough for its writes or, past 64 Ki gains, runs once with no buffer (the state) and once on the queue up to its first action past the tick (the gains, which are what the C writes inside the tick); the Rust side may not write the guard. A rate of 0 in the window and a null queue or visibility are checked on the Rust side only. Mutation check (done once, not committed): 27 of 29 mutants fail Tier 3 or Tier 1. Core: a late action not clamped; frame 1024 counted as this tick; ts 0 breaking like a tick (steps_process_all then loops, the rest fail); a show counted as a hide; a span filled with the new visibility; the tail always 1.0; one frame late; a one-step product instead of util_mul_div64 (caught by the wrap-point times); util_mul_div64 as exact 128-bit math on every host; the visibility before a change not updated; frame_num not advanced; two hides per hide; <= in the window; no ts 0 case in the window; a 1023-frame window; a saturating window sum; rate 0 not due. Shim: no move on erase; one move of the rest by the consumed count (same items, different bytes left); one action too few erased; the visibility not written back; the start not read from *visible; the buffer ignored; the rate ignored; 0 hides returned; the window's arguments swapped; the queue read backwards. The two survivors are equivalent: a fill that writes one frame more (the next fill or the tail always rewrites that frame), and the erase without its num 0 check (the move is then of 0 items). Refs obs-rust#1814 * docs: Record the scene audio action ramp port The rust/README.md rows for rust/obs-scene (crate table and port table) now include libobs/obs-scene-audio-actions.c.h. The port row lists what stays C, how the shim reaches the item's queue, what the characterization pins and the port keeps, the intentional differences (ts 0 with a buffer stops at the buffer end; a rate of 0 makes every action due; a null queue or visibility does nothing), the MSVC overflow above 1 GHz, what Tier 3 compares, and why there is no _rust variant of the steps test. The naming.md row (libobs/obs-scene*.c.h) already covers the file. Fixes obs-rust#1814
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 #1814 (PR 1 of the plan: the characterization and the extraction. The accessor and the port follow.)
What and why
This is a behaviour-neutral extraction before the Rust port, as the testing policy asks for part of a large file. The scene item visibility audio ramp moves from
libobs/obs-scene.c.hintolibobs/obs-scene-audio-actions.c.h. When an item whose source has audio is shown or hidden,obs_sceneitem_set_visible()queues an action with the time of the call. These functions apply it on the sample of the scene's audio tick that the time falls on, through a 0/1 gain buffer, and drop one active reference per hide. The move comes with two characterization tests, because the existing tests check that a hide is applied but not where it lands. There is no Rust, no behaviour change and no public header change.apply_scene_item_audio_actions(),apply_scene_item_volume()andprocess_all_audio_actions(), verbatim. The only change is that they losestatic:scene_video_tick()(the preview-only path, libobs: Apply scene item visibility changes in scenes that are only shown #358) andscene_audio_render()stay inobs-scene.c.hand call them. The forward declaration beforescene_video_tick()goes.mix_audio_with_buf(),scene_mix_audio()), the queueing inobs_sceneitem_set_visible()andobs_scene_add_internal(), andset_visibility(). In this PR the lock, theactive_refsdecrement andobs_source_remove_active_child()are still inside the moved code. The accessor PR splits them out.obs-internal.hwithoutEXPORT, so-fvisibility=hiddenkeeps them local (t) symbols. The exported symbols are unchanged.libobs.core-sourcegroup just beforeobs-scene.c.h, withlibobs.pch.hlike every member of that group. The group, the PCH,source-sets.jsonand the CMake source lists of libobs are unchanged. No test compilesobs-scene.c.hitself, and the moved code has no platform conditional.Why the accessor is not in this PR: for the hotkey pair it was (#1799), because there it was two
boolpointers and one call wrapper. Here it is like the press state machine (#1779), whose accessor was its own PR. The moved loop reads and erases the item's darray in place, writesvisible, holdsactions_mutexaround it, and drops the active references after it, on the audio thread. The accessor changes how the moved code reaches every one of those, and where the lock and the removal live. So it gets its own review, as the plan has it.test_scene_audio_actions(new, its own commit before the move) links the real libobs, plays constant-level tones in the program scene, and captures the program mix (track 1) withobs_add_raw_audio_callback(). Besides the public API, it reads only the item'sactive_refs, its queue length and the source'sactivate_refs, astest_group_hide_transition_audiodoes. The structs stay C in the hybrid libobs, so it covers the hybrid too and will see the port. The action time is taken insideobs_sceneitem_set_visible(), so each case brackets the call withos_gettime_ns()and accepts exactly the samples that a time in that bracket maps to (floor((t - tick) * rate / 1e9)). The check does not depend on how fast the machine is. The waits only bound how long it waits for the audio thread. Its 4 cases:It needs core video and audio, so it builds on Linux only and runs under
xvfb-run, liketest_group_hide_transition_audio. It skips without a display.test_scene_audio_action_steps(new, with the move) compiles the moved file (ASan and UBSan, no libobs core) and calls only the three functions, so the port can link the same file against the Rust staticlib. It uses a fake scene item: the real struct, zeroed, with its actions, visibility, references and mutex set. Its scene has no source, soobs_source_remove_active_child()only logs its NULL parent, and the test counts the removals from the log. Its 15 cases pin exact buffers, queues and counts:ts0 (the preview-only path, rate 0) andprocess_all_audio_actions()apply everything, future actions included;apply_scene_item_volume(): nothing queued (false, buffer not written), the window oftsplus the tick duration rounded down to whole ns at 6 rates, the first action only, andts0;It is in the obs-build C test manifest.
Characterized, not endorsed (a comment in the tests, and in the issue). None is changed here, and the issue proposes no fix before the port:
obs_sceneitem_set_visible()and is pushed later, so this needs two threads toggling one item at once.active_refsbelow 0, and the child is removed only at 0.obs_sceneitem_set_visible()keeps them paired, so libobs does not get here.Found while reading, outside the moved code and not pinned here:
mix_audio_with_buf()inscene_audio_render()appliesbuf[i]to output samplepos + i, butbufis indexed from the scene's tick. So for an item whose audio startspossamples into the tick, its change ispossamples late (less than one tick). It is in the issue, as a possible fix of its own.RED → GREEN
RED commit: N/A, behaviour-neutral (no fix and no port).
3699009d8test: Characterize the scene item visibility audio rampaddstest_scene_audio_actionsand passes 4/4 on the unchanged C, against libobs with the C backend, the hybrid libobs and libobs-c-reference. The move iscd92afd58libobs: Move the scene item visibility audio ramp into obs-scene-audio-actions.c.GREEN:
test_scene_audio_actions4/4 andtest_scene_audio_action_steps15/15, against all three.Equivalence: apart from
staticand one trailing blank line, the moved text is identical to the three functions onorigin/master. A differential harness (local, not committed) compiles the originalstaticfunctions fromorigin/masternext to the moved file and runs both on the same random fake items: 2 000 000 trials over the three entry points, with action lists of 0 to 7 (unsorted, at 0, nearUINT64_MAX, on the tick boundaries), ticks at 0, near 0 and nearUINT64_MAX, and 13 rates (0, 1, 8 kHz to 192 kHz, 1 GHz). The buffers, return values, visibility, references, removals and remaining queues were identical in every trial.Mutation check of the two tests: 21 of 22 mutants fail at least one of them. Each mutant of
obs-scene-audio-actions.c.hwas built into libobs (C backend) and both tests. The differential harness flags all 21 too:ts0 path stopping at frame 1024 like a tick (it then never drains, andprocess_all_audio_actions()loops: both tests hang); rounding to the nearest frame; one frame late;<=instead of<(one ns more), nots0 case,falseafter applying, a 1023-frame duration, the last action peeked instead of the first;process_all_audio_actions()with a tick of 1 instead of 0.Seven of them (late action, frame 1024, rounding, removal at or below 0, the
<=window, the 1023-frame duration, the last action peeked) pass the real-libobs test and fail only the steps test, because they need a boundary or an order that wall-clock toggles do not hit. The survivor isprocess_all_audio_actions()calling once instead of looping. It is equivalent: withts0, one call consumes the whole queue, so the loop's second pass never has work (the harness also finds 0 differences).Local, two build trees:
OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON, both full builds. Fullctest -j4, headless (private Xvfb with-noreset, private D-Bus, fresh HOME):OBS_LIBOBS_BACKEND=CHYBRID,OBS_BUILD_C_REFERENCE=ONHYBRID,OBS_BUILD_C_REFERENCE=ONNothing was skipped or failed to run, and nothing needed a second run.
test_preview_only_hide(6/6),test_group_hide_transition_audio(4/4),test_group_active_refs(10/10) andtest_item_transition_empty_source(4/4) pass, unchanged, against all three.test_scene_audio_actionsalso passed 15 runs in a row while the lint lane ran beside it. After the final rebase ontoe1b649910(#1806), both trees were rebuilt, and the six scene audio tests, the symbol comparison,ci/test_build_groups.pyandci/test_ported_sources.pypassed again.uv run ci/local_gate.py --lane lintpassed, and--lane crosspassed.ci/test_build_groups.py,ci/test_ported_sources.pyandci/platform_ifdef_ratchet.pypass. clang-format 22.1.3 and gersemi 0.25.0 are clean on the changed files.Windows/macOS: not built there. The moved code has no host conditional.
test_scene_audio_action_stepsis built on every OS, liketest_context_name_helpers, and is portable C (no cmocka range assertions, nofail_msg()).test_scene_audio_actionsis Linux-only, like the other scene audio tests.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)