[SDL] Re: mcop error causing sound latency

rgc rgc at localhost.localdomain
Tue Jul 2 09:11:01 PDT 2002


An SDL_Delay(1) even seems to eliminate the latency....

rgc wrote:

> The mcop errors were caused by my failing to call
> SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) with the SDL_INIT_AUDIO
> portion.
> 
> But I was still getting a small sound latency, that seemed to occur only
> in
> my SDL/OpenGL apps.  The latency wass small, perhaps 1/2 second or less,
> but noticeable.  Finally, I noticed if I called SDL_Delay(10) within the
> game loop then there was no latency.
> 
> I believe the SDL_Delay() call schedules cpu time to the threads that are
> executing the audio, which they don't get if the app is running full
> speed. Does this sound accurate?
> 
> Thanks again for any comments or input as it is very helpful
> 
> Bob
> 
> Ryan C. Gordon wrote:
> 
>> 
>>> So my question boils down to getting no latency while the Sound Server
>>> is
>>> on.  There is no latency in Quake 3 even when the Sound Server is
>>> running. Is it possible to accomplish this with SDL?
>> 
>> Quake 3 doesn't use SDL at all, audio, video, or input.
>> 
>> The KDE sound server (artsd), as well as Esound, will always have latency
>> due to the nature of what they do; it's fine for bells and whistles from
>> KDE apps ("wow, it plays a sound when I maximize the window!"), but it
>> will always be unacceptable for real time video games.
>> 
>> The solution is to bypass the server; disable it or get a sound card that
>> allows multiple opens of /dev/dsp (the SB Live is one, there are others,
>> too). Other SDL audio targets, ("dsp", "dma", "alsa" under Linux) have
>> noticably less latency.
>> 
>> This is just a hard fact of life; sending audio streams over a socket,
>> mixing them in software, and then sending them to the audio device, all
>> while fighting for the CPU against a video game, will always be a losing
>> battle.
>> 
>> --ryan.




More information about the SDL mailing list