Closed fuelsoft closed 1 year ago
This is a known limitation with the Vorbis decoder. I haven't been able to find a good way to retrieve the length via stb_vorbis so it needs to return 0. If you want to determine the length, you'll need to read-and-discard until you reach the end, accumulating the number of frames read as you go, then seek back to the start. Obviously this will be time consuming so you'd need to do it during an initialization routine and cache it.
Returning 0 is a valid situation which you should be handling if you want complete robustness. Should probably do another pass on the documentation and make that clearer.
Ah, that's unfortunate. I think I'll go with my plan B then, thanks for the reply.
Hi,
I'm not sure if I'm doing something wrong but I can't seem to get the length of a .ogg file -
ma_sound_get_length_in_seconds
(and the corresponding pcm_frame version) both set the length return parameter to 0. This is not an issue with .mp3 or .wav files.Playback works correctly for all file types and the function returns MA_SUCCESS.
I have tried the current miniaudio.h on master as well as the dev branch, to be safe, and both exhibit this behaviour. I was testing on Windows under MSYS Clang with
clang test.c -o test
. The smallest working example is below, most of it is copied from the SDL example.