[SDL] Re: Converting push sound model to SDL
leob at mailcom.com
Thu Jun 23 19:07:57 PDT 2005
Drake Wilson <drake <at> libcom.com> writes:
> > Thanks, but unlikely (for one, it does not have locking). My
> > attempts to use SDL audio and mutexes resulted either in underflows
> > or in too much lag between a keypress and a keyclick. It seems that
> > except the sound buffer size there is no way to control the playback
> > parameters (namely, the number of yet unplayed fragments downstream
> > from the callback).
> The latter is true -- only more advanced audio APIs like the ALSA PCM
> API have parameter control like that.
> Re the first sentence, I'm not seeing the problem. If your audio
> buffer underruns, you have no choice but to supply the audio device
> with _something_ -- the DAC isn't going to wait for you. If the host
> CPU can't keep up, then you're dead already. Why is the lockless FIFO
The underflow problem could have been caused by thread interaction (without SDL
audio the CPU keeps up easily).
> then a problem?
My goal is to have a single point where the host speed is brought down to the
target speed. Locking on the write to the audio buffer that drains with a fixed
speed in real time is, IMO, the best way to do it. Explicit calls to SDL_Delay
can be detrimental because the OSes do not guarantee real-time return.
More information about the SDL