SDL_sound icon indicating copy to clipboard operation
SDL_sound copied to clipboard

Let decoders claim a sound file

Open icculus opened this issue 3 years ago • 1 comments

We need to let decoders signal that they own a given sound file.

For example, the .WAV decoder might hit this legitimate failure case (if given a 24-bit audio file, which we don't yet support)...

BAIL_MACRO("WAV: Unsupported sample size.", 0);

But then SDL_sound will try other decoders, which appropriately fail because the file isn't .mp3/.voc/whatever, eventually setting the error message to "Sound format unsupported."

So what we need is a way for decoders to say "this is definitely a .WAV (or whatever) file, but I can't open it (i/o issue, corrupted, some unsupported thing)," so that SDL_sound can report a more meaningful error and also know to stop trying other decoders.

icculus avatar Mar 27 '22 16:03 icculus

The alternative generic way of testing formats is through something like magic: https://github.com/file/file/blob/3021bd5ae3494c7c9193e7c95f3afcb2c2d22d4a/magic/Magdir/audio#L956

What can be done here that would be easier is if you are deeper in the decoding and understanding of some header of the file format then it would raise some flag that says "yes I am the correct decoder" and from that point on it would both fail with more meaningful errors and not fallback to trying other decoders.

ericoporto avatar Feb 17 '24 19:02 ericoporto