molluskandClaude Opus 4.8 fa3d785997 refactor(core): extract pure mixer fns + add saturation unit tests
Pull the audio mixer's inline math out of the async mixer-task closure into
three pure, testable functions — mix_frames (sample-by-sample sum with i16
saturation), apply_volume (per-peer scale + clamp, unity-skip fast path), and
frame_level (normalized RMS for the UI meter). Behavior-preserving: the loop
now calls them and the full suite still passes.

Adds 12 #[cfg(test)] unit tests, notably the saturation guards: a loud mix or
a volume boost clamps to i16::MAX/MIN rather than wrapping (a plain cast would
wrap a 2x-full-scale sum to a large negative value). Also covers sum, ragged
peer-frame lengths, no-peers silence, volume unity/zero/half, and RMS bounds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 05:41:25 -04:00
2026-06-01 05:08:25 -04:00
2026-05-29 15:36:55 -04:00
2026-05-29 15:36:55 -04:00
S
Description
No description provided
MIT
16 MiB
2026-08-22 19:08:47 +00:00
Languages
Rust 98.8%
Shell 0.4%
Nix 0.4%
Inno Setup 0.2%
Python 0.2%