Reading a track's length meant decoding the whole file: PcmAudio carried
duration, and nothing else did. For four minutes of 44.1 kHz stereo that
materializes 40 MB of samples to answer one question, which is the wrong trade
for a playlist, an upload check, or picking files to process.
Add audioInfo, oggInfo and mp3Info, returning an AudioInfo with sampleRate,
channels, frameCount and duration and allocating no PCM. Vorbis stores its
length in the container, so stb_vorbis is opened and queried. MP3 has no
total-length field, so the frame headers are still walked, but minimp3 parses a
frame and returns its sample count when the PCM pointer is null, so the
synthesis step and the output buffer both go away.
Measured on a one-second stereo fixture, warmed up and averaged: Ogg 107 us
against 511 us for a full decode, MP3 0.9 us against 217 us. Correctness is the
part that matters though, so the tests assert the reported sample rate,
channels, frame count and duration equal what decodeAudio returns, for every
fixture in both formats. 36 tests pass.