[sdlsound] need help putting it all together (sdl_sound,sdl_m ixer,physfs)

torbjorn.e.andersson at tietoenator.com torbjorn.e.andersson at tietoenator.com
Tue Dec 3 08:48:49 EST 2002

I've been hoping for someone else to answer, but...

Eric Wing [ewing2121 at yahoo.com] wrote:

> First, FYI, I think there is a bug with the Init code
> and MikMod. If I initialize both SDL_Sound and
> SDL_Mixer (with Sound_Init() and Mix_OpenAudio(...)),
> my program hangs. I think it gets stuck in an infinite
> loop. If I interrupt the process with a debugger, I am
> left inside "mloader" which seems to be a park of
> MikMod. 

Oof, I think I see what's causing this. Both SDL_Mixer and SDL_sound will
call MikMod_RegisterAllLoaders(), and that function won't check if the
loaders have already been registered. This probably creates loops in what's
supposed to be a linked list of loaders.

I guess we could make the MikMod loader first check if MikMod_InfoLoader()
returns a non-empty string, but it's not what I'd call a pretty solution.

(It's also quite possible, but less likely, that we have the same problem
with registering drivers.)

> I tried several different types of files. Most of my
> files played something recognizable, but they played
> at the wrong speed. I was wondering how I can fix
> this. I also had some low quality WAV files which were unrecognizable. 

It sounds as if SDL_sound is decoding the audio to a different format than
SDL_Mixer expects it to. At least that would explain the wrong speed. I
don't know what'd cause the second bug though. If it was a problem with
byte order and/or signedness of the output, that should have been noticeable
with the other ones as well.

> But also, the DecodeAll option was taking a very long
> time to run on my MP3 files, and I presume it's also
> taking a lot of memory.

Yes, it will decode the entire MP3 into a memory buffer. You should probably
just decode a little bit at a time, like "playsound" does.

Mind you, I've never actually used SDL_sound (which is embarrassing since I
helped writing parts of it :-). Ryan has been threatening to rewrite
SDL_Mixer to use SDL_sound as a backend. This should make most of these
problems go away, but I understand he's been busy elsewhere lately.

Torbjörn Andersson

More information about the sdlsound mailing list