diff --git a/crates/rutster-media/src/opus_codec.rs b/crates/rutster-media/src/opus_codec.rs index 6a47428..dae5708 100644 --- a/crates/rutster-media/src/opus_codec.rs +++ b/crates/rutster-media/src/opus_codec.rs @@ -42,6 +42,15 @@ pub struct OpusDecoder { // Reusable decode buffer: avoids allocating 480 i16s per frame on the // hot path. `Option` would also work; a flat array keeps the // reuse obvious. + // + // F9 (adversarial review, cleared): the buffer is exactly 480 i16 = + // 20 ms @ 24 kHz mono. libopus is initialized with `SAMPLE_RATE = + // 24_000` and `Channels::Mono`, so a 20 ms frame decodes to exactly + // 480 samples and fits. A 40/60 ms frame (Chrome doesn't send these + // by default but Opus allows them) yields `OPUS_BUFFER_TOO_SMALL` + // โ†’ `decode()` returns `Err` โ†’ the `Option`-shaped `decode` wrapper + // routes to `None` โ†’ drop+observe per ยง3.8 (already the documented + // correct behavior; this comment makes the 20-ms assumption explicit). pcm_buf: [i16; SAMPLES_PER_FRAME], }