Skip to content

rust: port obs_source_audio_render and its custom, submix and tick steps to obs-source #5923

Done

Description

@rdoupe

obs_source_audio_render() in libobs/obs-source.c.h (~1881-2030 on master, bfc55e6) and its three static steps, custom_audio_render(), audio_submix() and process_audio_source_tick(), are still C. They are what the audio thread calls for each source every tick. Every decision in them is already Rust: the route and the per-mix plan (obs-source-audio-render.c, #2254) and the volume step (obs_source_apply_audio_volume(), #5916). What is left is the glue on the source's fields, the input deques, audio_buf_mutex and the source callbacks.

Behavior the port keeps, call for call:

  • obs_source_audio_render(): read audio_output_buf[0][0], then info.audio_render, then context.data, each only where the earlier checks reached it (432017b: the audio thread can render a source whose context.data is not set yet). Route PENDING sets audio_pending; CUSTOM runs the custom step; TICK runs audio_submix() when info.audio_mix is set, then the tick step.
  • custom_audio_render(): point the mix struct at the output buffers, clear each mix the plan says to clear before (reading audio_mixers once per mix), call info.audio_render outside the lock, then under audio_buf_mutex set audio_ts and audio_pending, return early when pending or unmixed, clear after per mix, then obs_source_apply_audio_volume().
  • audio_submix(): clear audio_mix_buf, call info.audio_mix, and on success hand the planar float block to obs_source_output_audio() with the tick's rate, frames, layout and timestamp.
  • process_audio_source_tick(): under audio_buf_mutex, mark pending when audio_ts is unset or the input is short; otherwise peek each channel into mix 0, copy or clear mixes 1.., then either stop (submix) or clear the main mix when the plan says and apply the volume. The input size is read only with a timestamp.

Plan, one PR into obs-source (the shape of #5916):

  1. Extract the four functions verbatim into libobs/obs-source-audio-render-steps.c.h (live core-source group). No behavior change.
  2. Tier 1 RED in obs-source's existing category binary against a todo!() core over a trait for the field reads/writes, the deques, the mutex and the callbacks.
  3. GREEN: safe core in obs-source, the export as C ABI in ffi/, a field shim with no EXPORT, the extracted file moved to a reference-only ported group.
  4. Tier 3 parity against the original C in obs-c-oracle: the same buffers, inputs, callbacks and mixers through both, comparing buffers, fields, deque contents, callback calls and lock order.
  5. Tier 2: a new cmocka test of custom, submix and tick sources (pending, short input, unset timestamp, each mixer mask, a failing callback) through the hybrid libobs and the C reference. The existing audio tests run unchanged.

Activity

  1. added
    enhancement
    port
    on Nov 29, 2026
  2. rdoupe commented on Nov 29, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #5923 port of obs_source_audio_render and its custom, submix and tick steps (extract, Tier 1 RED, GREEN, Tier 3 parity, Tier 2).

  3. added
    ready
    on Nov 29, 2026
  4. added a commit that references this issue on Nov 29, 2026
    fda94ec
  5. rdoupe commented on Nov 30, 2026

    @rdoupe
    CollaboratorAuthor

    Done in #5926 (merged 2026-11-29); the queue merge didn't close it.

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

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions