Skip to content

perf: obs-audio-mix: add only into the active mixes #3189

Closed

Description

@zackees

What

obs_audio_mix_add (libobs/obs-audio-mix.c.h:41-52, Rust rust/obs-core/src/audio_mix.rs:192) adds every root source into all 6 mixes under audio_buf_mutex, though audio_callback gets the active mixers mask and typical setups use 1-2 tracks. Inactive mixes are never read (audio-io.c.h:126).

Proposed change

Pass mixers through mix_audio and skip unset bits. Output unchanged. Expected ~3-6x less mix-add work. Check no other caller relies on all 6 being filled.

Acceptance criteria

  • Before/after numbers (audio_mix bench with a mask sweep: 1 vs 6 mixes, 4/16/32 sources) in the PR; nothing lands unmeasured.
  • RED then GREEN; Tier 3 parity stays bit-exact unless this issue says otherwise.

Found by a read-only code scout and not yet measured. Parent: #3176.

Activity

  1. vpacher commented on Oct 31, 2026

    @vpacher
    Member

    Claiming: #3189

    Plan (one PR):

    1. Check every reader of the six mix buffers between mix_audio() and the outputs (audio-io.c.h, monitoring, the clamp), so a skipped mix is never read.
    2. RED: obs_audio_mix_add() takes the active mixers mask; Tier 1 tests that an inactive mix is left untouched and an active one is added as before, and an audio_mix bench sweep (1 and 6 active mixes, 4, 16 and 32 sources).
    3. GREEN: audio_callback() passes its mask through mix_audio(); the Rust core and shim skip unset bits. Tier 3 parity bit-exact with the mask, and record.py before/after numbers in the PR.

    First PR within a day.

  2. added
    ready
    on Oct 31, 2026
  3. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Note for whoever implements this: obs_audio_mix_add ships as Rust (libobs/cmake/rust-hidden.txt, rust/obs-core/src/ffi/audio_mix.rs), so the C in obs-audio-mix.c.h is only the Tier 3 reference. The mixers mask has to reach the Rust mix_into (rust/obs-core/src/audio_mix.rs), and the caller mix_audio in obs-audio.c.h (still C) has to pass it.

  4. vpacher commented on Oct 31, 2026

    @vpacher
    Member

    Covered in #3227: the shim obs_audio_mix_add_mixers() skips the mixes outside the mask (mix_active() in rust/obs-core/src/audio_mix.rs) before mix_into(), and audio_callback() in obs-audio.c.h passes its mask through a new mix_audio_mixers(); mix_audio() stays the all-mixes form because test_audio_buffering_subsample calls it. The C in obs-audio-mix.c.h changed only as the Tier 3 reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions