Audio callback function is not called in time sometimes

I'm new to SDL. I'm developing a media player using SDL, and now I met the problem that the audio callback function is sometimes not called in time, and cause the audio a little fitful.

I use such piece of code to open the audio device:

wanted_spec.xxx = xxx;
wanted_spec.callback = audio_callback;    //audio_callback is my audio callback function
SDL_OpenAudio(&wanted_spec, &spec);

My OS is Windows XP.

Do you know anything about that? Can someone suggest how to synchronize data feeding to callback function with 0 latency.

My Problem is instead of providing whole wav file through SDL_LoadWAV, I want to pass PCM samples (probably 1024 samples).(Design is like this I will be getting PCM samples)

But issue is, callback function is not called in time or calling is delayed which causes the sound to be fitful. I'm not able to syn passing of data to callback function.

Can you please suggest a way to synchronize passing data (Samples) to callback function or provide some application where data is passed in samples?


We need real values to fully answer your question.

What is your attempted buffer size?

Also realize that it is common for SDL to not give you what you want, so check what the actual spec buffer size is.

I've been using a binary mingw32 port of SDL on windows that won't give me buffers smaller than one second no matter what I request.

链接地址: http://www.djcxy.com/p/5792.html

上一篇: C ++

下一篇: 音频回调功能有时不被调用