docs(slice-1): F9 — explicit 20-ms assumption on OpusDecoder::pcm_buf

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.
This commit is contained in:
opencode controller
2026-06-28 20:24:04 -04:00
parent 0f3ee99354
commit 8a3c9b08c7

View File

@@ -42,6 +42,15 @@ pub struct OpusDecoder {
// Reusable decode buffer: avoids allocating 480 i16s per frame on the // Reusable decode buffer: avoids allocating 480 i16s per frame on the
// hot path. `Option<PcmFrame>` would also work; a flat array keeps the // hot path. `Option<PcmFrame>` would also work; a flat array keeps the
// reuse obvious. // 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], pcm_buf: [i16; SAMPLES_PER_FRAME],
} }