Skip to content

rust: Port the source volume snap and apply decisions in obs-source.c to obs-source #2158

Closed

Description

@rdoupe

Unit

Port the rest of the source volume decisions in libobs/obs-source.c.h to rust/obs-source, next to ptm_gate (#2089), as a new module volume_apply. These decisions move:

  • In get_source_volume:
    • the render-side gate: muted, disabled, push-to-mute and push-to-talk active, over the render-side fields (the stop-time updates already use ptm_gate);
    • the snap to 0 and 1 within 0.0001 (close_float).
  • In apply_audio_volume:
    • whether a pending audio action is due this tick (action.timestamp < audio_ts + duration);
    • the volume action: skip at 1.0, clear at 0.0 or with no mixers, otherwise multiply the mixes in both masks (audio_mixers & mixers).

These stay in C:

  • the action queue and its mutex, and apply_audio_actions;
  • conv_frames_to_time (C passes the duration);
  • the memset and the multiply loops.

Since #2128 the stored volume is finite and non-negative, but the core takes any f32.

Plan (one PR, separate commits)

  1. A behaviour-neutral move into libobs/obs-source-volume.c.h, as hidden functions.
  2. Characterization in test_source_volume_apply_steps. It covers:
    • every gate flag combination;
    • the snap at 0 ± 0.0001, 1 ± 0.0001, -0, NaN and ±inf;
    • each volume action, with every mixer mask edge;
    • the action-due compare at the threshold - 1, at the threshold and + 1, plus the u64 wrap.
  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-source-volume group. Exported symbols are unchanged.
  4. Tier 3 parity against the original C: exhaustive over the flags and masks, plus a proptest over f32 bit patterns and full-range u64 times. Also a deliberate-break check and port_comparison numbers.

These real-libobs tests must stay green on every lane: test_source_audio_ranges, test_source_volume_mix, test_source_ptm_gate_steps, test_audio_capture_mix_race and the scene item audio action tests.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2158.

  2. added
    claimed
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions