SMPEG's use of SDL_MixAudio()

Torbjörn Andersson torbjorn.e.andersson at
Fri Jan 25 12:40:17 EST 2002

I don't know if anyone else is on the SMPEG mailing list yet, but here 
goes anyway. :-)

One (mis?)feature of SMPEG that has been causing mild headaches for the 
SDL_sound project is that SMPEG_playAudio(SMPEG *mpeg, Uint8 *stream, 
int len) not just decodes the audio stream into the 'stream' buffer, it 
actually *mixes* the decoded audio with whatever is already in the 
buffer. That is to say, it calls SDL_MixAudio().

Unfortunately, the SDL_MixAudio() function doesn't work too well unless 
it knows which audio format to mix to. If the audio sub-system has been 
initialized, it will pick the format that uses (which is undefined 
unless SDL_OpenAudio() has been called), otherwise it will simply guess.

Which means that any program using SDL_sound to decode MP3 has to call 
SDL_OpenAudio(), regardless of whether or not it means to actually play 
the resulting sound.

At least I *think* this is how it works.

I guess it would be quite rude to strip SMPEG of its mixing abilities - 
after all someone may depend on them - but perhaps it would be desirable 
if you could somehow tell it to just copy the decoded audio to the 
buffer. But is there any way of doing so without breaking the API?

Torbjörn Andersson

More information about the smpeg mailing list