Converting audio players to use SDL (fwd)

This is specific information for Civ, but might be useful for people
porting audio code to SDL…

Forwarded message: -------------------Date: Mon, 05 Apr 1999 13:39:07 -0700
From: @slouken (slouken)
Subject: Converting audio players to use SDL

Essentially the process is this:

SDL uses a separate audio thread to fill the audio device. This thread
periodically calls the audio callback, and passes it a pointer to a
temporary audio buffer and the length of that buffer. The callback is
expected to completely fill that buffer as quickly as possible and
return. The frequency at which this callback is called is
freq/chunksize. We use a frequency of 22050 Hz, samplesize of 2
(16-bit) and a chunksize of 512, for a total of 43 callbacks per
second. The audio output has a latency of approximately 1 chunk, or 23
ms.

So, one way to implement the audio player is to implement a callback of
the form:
void mix_mpeg(void *udata, Uint8 *stream, int len);
which is called by the mixer at each sound interrupt, updates the
internal playback progress and fills the audio buffers. You can pass
this callback directly to SDL_OpenAudio() for testing. We can support
this in the mixer later.

    -Sam Lantinga                           (hercules at lokigames.com)

Lead Programmer, Loki Entertainment Software: http://www.lokigames.com/

Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

------------------- end forwarded message.