IMHO it’s not really good idea to clear the audio buffer in SDL_RunAudio()
everytime before calling the audio callback function. Wouldn’t it be
backward compatible if this buffer is initially cleared and then left
alone? In 99% of all cases it’s wasted bandwidth and you’re probably
trashing the cache, too. I’ve also noticed that
silence'' is an int but memset() obviously uses only the lower 8 bits. So, although you're trying to be compatible to several codecs, this probably won't work for all i.e., if the lower and the upper bits are not identical forsilence’’ (i.e., not 0xffff or 0x0000).
Also, the memcpy() if the sound is converted seems to be inefficient.
Why not directly pass the address of the converted data to PlayAudio()?
E.g., you could initialize a fake audio structure before the loop
and copy all members of the “real” structure into it. So later you
only have pass it’s buffer.
Just my 2 cent,–
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Size: 186 bytes
Desc: not available