Repository navigation
Closed
Labels
readyMeets the definition of Ready; claimable
Description
Unit
libobs/obs-source.c.h: the two volume kernels that scale a source's audio every audio tick, once per mix the source is in:
multiply_output_audio():out[i] *= voloverAUDIO_OUTPUT_FRAMES * channelssamples fromaudio_output_buf[mix][0], fromapply_audio_volume();multiply_vol_data():out[i] *= vol_data[i]for each channel, fromapply_audio_actions()when a volume, mute or push-to-talk action falls inside the tick.
They move to libobs/obs-source-volume-mul.c.h and are ported to rust/obs-source (module volume_mul, next to volume_apply and audio_place).
Phase and position
Phase 2 libobs core, sources (core-source group). This is the source half of #3007 under #3009. The decisions around these kernels are already ported: obs-source-volume.c.h (skip, clear or multiply, and which mixes) and obs-source-audio-place.c.h (each action's frame and the fill of vol_data). The scene mix kernels are a separate issue. Tracking: #4.
Dependencies and existing tests
- Depends on nothing open.
- Existing tests that run the kernels through the real libobs:
test_source_volume_mix(the volume as the mix applies it, out-of-range volumes included) andtest_source_volume_apply_steps. - No characterization of the kernels on their own yet.
test_source_volume_mul_steps(cmocka, the moved file on its own) lands first. It pins:- both kernels for 1, 2 and 8 channels;
- volumes 0, 1, 0.5 and 20;
- a
vol_dataramp across the tick; - NaN, infinities and -0.0;
- other mixes left alone.
Notes
- perf: libobs: vectorize scene audio mixing and source volume multiply when ported #3007 applies:
- a benchmark under
audio_mixfirst, with before and after numbers on a named x86_64 and a named aarch64 machine; - an assembly check that the kernels vectorize;
- a scalar fallback;
- bit-exact Tier 3 (multiplies only, so there is no fused multiply-add question).
- a benchmark under
- Vectorization: GCC 14 at
-O2(the Linux builds) leaves both loops scalar; clang vectorizes them. - Channel layout (characterized, not endorsed):
multiply_output_audio()treats a mix's channel buffers as one block from channel 0. That holds becauseallocate_audio_output_buffer()makes one allocation for all mixes, and each mix'saudio_output_buf[mix][ch]are consecutive blocks ofAUDIO_OUTPUT_FRAMESin channel order. The C function on plain pointers keeps that block; the characterization pins it. apply_audio_volume()andapply_audio_actions()keep the action queue and its mutex,get_source_volume(), thevol_datafill, the memset and the mix loop. Only the two kernels move, as functions on plain pointers and counts, hidden in libobs.
Metadata
Metadata
Assignees
Labels
readyMeets the definition of Ready; claimable
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 30, 2026
Claiming: #3080.
Plan (one PR, in this order):
multiply_output_audio()andmultiply_vol_data()move tolibobs/obs-source-volume-mul.c.has hidden functions on plain pointers and counts;apply_audio_volume()andapply_audio_actions()keep everything else in its order.test_source_volume_mul_steps(cmocka, the moved file on its own), with the cases listed in the issue.rust/obs-sourcemodulevolume_mulwith stubs and Tier 1 tests.audio_mixbenchmark against the C and the assembly check (perf: libobs: vectorize scene audio mixing and source volume multiply when ported #3007).Draft PR within 48 h.
libobs: Move source volume multiply kernels to own file
test: Characterize the source volume multiply kernels
obs-source: Add Tier 1 tests for the source volume multiply kernels
obs-source: Port the source volume multiply kernels
obs-source: Check the source volume multiply port against C
docs: Record the source volume multiply port
obs-source: Port the source volume multiply kernels (obs-rust#3080) (o…