[SDL] SDL Audio, strange timing problem

Sebastien Braun sebb at yellowhippy.org
Mon Jul 16 17:07:13 PDT 2007


Dear List,

I have the following problem with SDL audio output.

I'm trying to program a little program which should do nothing more than 
receive decompressed audio data from the network and output it to the sound 
card. But I can't manage to get SDL to play the sound seamlessly.

Even though the networking code is not active, the sound card produces hiccup 
sounds about everytime my audio callback is called by SDL.

The callback looks like this:

        extern "C" void __sdlCallback(void*a, Ice::Byte* buf, int blen) {
            if(__sdlbuf != 0 && bufinsdl) {
                memcpy(buf, __sdlbuf, blen);
                bufinsdl = false;
            }
            else
                cerr << "!";
        }

Judging from the output (no "!") it does not have to wait for a fresh buffer 
(which is filled from a separate thread) even once, so I can't imagine that 
the problem is in the availability of data.

Also, I can't see how I can make that code much faster than it is now.

The problem persists at all sample frequencies, in mono and in stereo, with 
8-bit and 16-bit samples, and at all SDL_AudioSpec.samples values that I 
tried.

I can't understand this. Or maybe I'm just too dense. Googling around and 
asking in IRC did not turn up any hints.

Can anyone on this list help?

Thanks in advance,
Sébastien Braun


More information about the SDL mailing list