Anyone tried stb_vorbis?

It doesn’t decode whole files for me…

When I first tried stb_vorbis it seemed like it wasn’t decoding the entire file, then I realized I was calculating the wrong buffer size when passing the result to OpenAL.

The function stb_vorbis_decode_filename() returns the number of samples it decoded; does it match what you expected?

This is what I use:

int16_t *audioData = nullptr;
ALsizei bufferLen = 0;
int channels = 0;
int sampleRate = 0;
int sampleCount = stb_vorbis_decode_filename(filename, &channels, &sampleRate, &audioData);
// error checking omitted
bufferLen = sampleCount * sizeof(int16_t) * channels;

bufferLen = sampleCount * sizeof(int16_t) * channels;

Indeed, thanks.