From 8a3c9b08c70df670c847792f0f46d87010c56b33 Mon Sep 17 00:00:00 2001 From: opencode controller Date: Sun, 28 Jun 2026 20:24:04 -0400 Subject: [PATCH] =?UTF-8?q?docs(slice-1):=20F9=20=E2=80=94=20explicit=2020?= =?UTF-8?q?-ms=20assumption=20on=20OpusDecoder::pcm=5Fbuf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adversarial review F9 (Low, cleared as bug): RFC 7587 fixes the SDP at `opus/48000/2` regardless of internal rate; libopus self-describes internal rate, so the 24 kHz mono decoder is correct. A 40/60 ms frame would yield OPUS_BUFFER_TOO_SMALL and rutster's `Option`-shaped `decode` wrapper routes it to `None` → drop+observe per §3.8 — already the documented correct behavior. Adds the explicit 20-ms assumption as a comment so the boundary is visible to future readers. --- crates/rutster-media/src/opus_codec.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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], }