[SDL] Audio callback function is not called in time sometimes

Jukka-Pekka Manninen jmanninen at digitalchocolate.com
Tue Dec 4 06:09:51 PST 2007


Just guessing here, and assuming you have a busy main loop running…

 

Do you have any SDL_Delay calls in your main loop? If not, and your app is using up all the CPU time it can get, Windows might tag your program as a resource hog and give it less CPU time especially when other processes are busy. Like minimizing/maximizing etc.

 

Hoping it’s of any help,

 

-- 

Jukka-Pekka Manninen

 

 

________________________________

From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On Behalf Of Mine
Sent: 4. joulukuuta 2007 16:00
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] Audio callback function is not called in time sometimes

 

Anyone know about that?
Here's some data about the delay of audio_callback function:
1) when it's playing normally, the interval between two audio_callback function is about 25‾31 ticks in SDL (get from SDL_GetTicks ); 
2) when the sound is fitful, the interval between two audio_callback is totally variable from 40 to 80, or larger sometimes.

My question is, how does this problem come? And how to resolve it if possible?

On Nov 30, 2007 9:33 PM, Mine <mine260309 at gmail.com> wrote:

Hi All,
    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 did some investigation about this problem. 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);
    I put some log in audio_callback function, and find that when the phenomenon occurs the audio_callback function is not called in time, which cause a split of the audio. And continuously not in time called audio_callback causes the fitful sound. 

    My OS is Windows XP, and generally this phenomenon occurs when there're task switches, like focus on other windows, minimum/maximum a window or something like that. And if there's no such task switch, the sound is smooth. 
    Do you know anything about that?
-- 
Mine 




-- 
俺たちが乗った列車は途中下車はできないんだ! 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071204/5cab8345/attachment.html 


More information about the SDL mailing list