SDL_MixAudio(Uint8 *dst, Uint8 *src, Uint32 len, int volume)

hi,

I used this function in my audio callback function,
just like the SDL document’s example:
void audio_callback(void *udata, Uint8 stream, int len)
{
/
Only play if we have data left /
if ( audio_len == 0 )
return;
/
Mix as much data as possible */
len = ( len > audio_len ? audio_len : len );
SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME)
audio_pos += len;
audio_len -= len;
}

but the audio output seems a little strange, sometimes speedy, sometimes
slow,
not just like the pitch I input,
the document says the callback function’s para *stream is for output data,
is this means it points to the sound card’s buffer?
and when is the callback function be called?

the parameter I set is
desired->freq=8000 ;
desired->format=AUDIO_S16LSB;
desired->samples=2048;
desired->callback=my_audio_callback;
desired->userdata=NULL;

If somewhere can get this respect’s information, please tell me.

Thanks.

If somewhere can get this respect’s information, please tell me.

This all looks good. What operating system and audio drivers are you using?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

If somewhere can get this respect’s information, please tell me.

This all looks good. What operating system and audio drivers are you
using?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

I use Linux RedHat 7.2
Audio driver catched by SDL_AudioDriverName( )  shows "esd"

An issue is that this playing function is in a thread,
by real-time get audio bitstream from network,
I use a buffer to save this data, like this :

 void my_audio_callback(void *userdata, Uint8 *stream, int len)
{
             len = ( len > _audio_len ? _audio_len : len );
            SDL_MixAudio(stream,(Uint8 *)userdata , len,

SDL_MIX_MAXVOLUME);

             _audio_len -= len;
             memmove( userdata, (Uint8 *)userdata + len, _audio_len ) ;
}

where userdata points to my audio data buffer, whenever mix a audio
clip, I rearrange the buffer ( audioBuf[16000] ),
next time receive audio data, put it to buffer like
memcpy(audioData+ _audio_len,  clipBuffer, clipSize) ;
is any problem in the code?

Thanks.