pub fn classify_wav(head: &[u8], file_len: u64) -> Option<WavWrapperKind>Expand description
Which of the engine’s three forms a .wav file takes.
head is the start of the file, at least WAV_CLASSIFY_LEN bytes of it
or the whole file when it is shorter, and file_len is the whole file’s
length. Nothing past WAV_CLASSIFY_LEN is read, so a caller checking many
files reads their headers rather than their audio.
A file starting with RIFF is MP3-in-WAV when its declared RIFF size plus
eight falls short of file_len, and plain otherwise. A file without RIFF
at the start is the prefixed form when RIFF sits at 0x1D6. These are
the engine’s own tests, laid out in docs/src/formats/audio/wav.md.
Returns None when neither test passes, so the engine takes the file as
none of the three. The forms are told apart here, not validated: a plain
file can still fail to parse.
§Panics
In debug builds, when head holds fewer bytes than the file has up to
WAV_CLASSIFY_LEN. A short head would hide the prefixed form’s RIFF
and answer None for a file the engine plays.