Latency in mixer demo

Hello -

I have been writing a little game using SDL and the mixer lib from
SDL-demos. While the SDL-dx5 version seems to run perfectly, there is a
small (~100ms) latency in the sound output of the SDL-dib (win32) and
SDL-x11 (linux) versions.
I know this is not much info, but is there anything obvious that I could
be doing wrong to induce the sound latency? Is there any way to
"optimize" my sound routines using SDL without having to write my own
mixer? Any help is appreciated.

Max Watson
<@Max_Watson>

on Fre, 18 Jun 1999 Max Watson wrote:

Hello -

I have been writing a little game using SDL and the mixer lib from
SDL-demos. While the SDL-dx5 version seems to run perfectly, there is a
small (~100ms) latency in the sound output of the SDL-dib (win32) and
SDL-x11 (linux) versions.
I know this is not much info, but is there anything obvious that I could
be doing wrong to induce the sound latency? Is there any way to
"optimize" my sound routines using SDL without having to write my own
mixer? Any help is appreciated.

hmm, I am not sure, if the following will solve your problem:
In the SDL-demos the chunksize is usually set to 4096, this results under
linux x11 in a noticable latency; reducing the chunksize to 1024 solved this
problem for me. here some code …

/* choose low latency */
int chunksize = 1024; // low latency !

/* Open the audio device */
Mix_OpenAudio(audio_rate_, audio_format_, audio_channels_, chunksize);–
Karsten-O. Laux
klaux at student.uni-kl.de
http://www.rhrk.uni-kl.de/~klaux
UIN 21614933 (Bert)

Karsten-Olaf Laux wrote:

hmm, I am not sure, if the following will solve your problem:
In the SDL-demos the chunksize is usually set to 4096, this results under
linux x11 in a noticable latency; reducing the chunksize to 1024 solved this
problem for me. here some code …

/* choose low latency */
int chunksize = 1024; // low latency !

/* Open the audio device */
Mix_OpenAudio(audio_rate_, audio_format_, audio_channels_, chunksize);

Thanks! This was exactly my problem. I reduced the chunksize to 1024,
and both the X11 and the DIB versions sound great.

Max Watson
<@Max_Watson>

/* choose low latency */
int chunksize = 1024; // low latency !

/* Open the audio device */
Mix_OpenAudio(audio_rate_, audio_format_, audio_channels_, chunksize);

Thanks! This was exactly my problem. I reduced the chunksize to 1024,
and both the X11 and the DIB versions sound great.

Even 512 seems to be a good value. Don’t reduce it below that! :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec