diff --git a/core/archipelago/src/music/tags.rs b/core/archipelago/src/music/tags.rs index 5997da21..ff415635 100644 --- a/core/archipelago/src/music/tags.rs +++ b/core/archipelago/src/music/tags.rs @@ -165,10 +165,16 @@ mod tests { /// 64kbps, 44100Hz, mono, padded — the exact byte pattern lofty's own /// test suite uses as a known-good frame header /// (`mpeg/header.rs::tests::rev_search_for_frame_header`). Its computed - /// frame length (samples * bitrate * 125 / sample_rate + padding) is - /// 210 bytes. + /// frame length matches lofty's `Header::read` exactly: + /// `samples * bitrate * 125 / sample_rate` truncates *before* the + /// padding byte is added — `1152 * 64 * 125 / 44100 = 208`, `+ 1` + /// padding = **209** bytes. The frames written below must be exactly + /// this long, because lofty confirms a frame sync by comparing the + /// candidate header against the bytes found exactly `len` later + /// (`find_next_frame`/`cmp_header`); an off-by-one frame length makes + /// the whole file "contain an invalid frame". const MP3_FRAME_HEADER: [u8; 4] = [0xFF, 0xFB, 0x52, 0xC4]; - const MP3_FRAME_LEN: usize = 210; + const MP3_FRAME_LEN: usize = 209; fn mp3_frame() -> Vec { let mut frame = MP3_FRAME_HEADER.to_vec();