[SDL] callback issue

chris.2.dobbs at bt.com chris.2.dobbs at bt.com
Tue May 1 10:17:54 PDT 2007


Must admit I just blindly used SDL_MixAudio() as it was in one of the
samples; as usual the devil is in the detail and lazyness has done for
me again...makes much more sense now.
Many thanks once again Ryan.

BTW do you know if there any plans to incorperate libSDL_audioin into
SDL proper? Or is it always going to be an external add on library?
-Chris

-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org]
On Behalf Of Ryan C. Gordon
Sent: 01 May 2007 09:50
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] callback issue


> network; Both are not present all the time so do I need to call
> SDL_MixAudio() if both are present? Or just memcpy both if and when 
> they are present?
> 
> Like this:
> 
> Got buff_A data?
>         memcpy(stream...
> Got buff_B data?
>         memcpy (stream...

If you memcpy() both in the same call, the second one will just
overwrite the first, of course. If you need two or more things to mix
together to be played back at the same time, you should memcpy() the
first thing and then use SDL_MixAudio() or something similar to add each
of the rest to the stream. Or memset() the stream and then mix all the
sources, if you find the code is cleaner and don't mind the extra memory
bandwidth.

But if you just have one data stream, using SDL_MixAudio is either
wasteful (since a memcpy() will be faster when mixing against silence),
or dangerous (if the stream we pass in ceases to be initialized for you
in the future).

--ryan.

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


More information about the SDL mailing list