[SDL] Audio callback function is not called in time sometimes
Mine
mine260309 at gmail.com
Tue Dec 4 07:34:04 PST 2007
Thanks guys.
I sure have SDL_Delay in my main loop, or the CPU usage will be full.
I did further investigation, it looks like SDL_Cond_Wait/Signal takes the
most extra time, and SDL_Lock/Unlock_Mutex takes less extra time when the
problem occurs. I now use a while loop & SDL_Lock/Unlock_Mutext instead of
SDL_Cond_Wait/Signal, then it works better, there's less audio drop. But
sometimes there still is.
Is it possible that SDL_Lock/Unlock_Mutex will take about 30~40 ticks?
(I'm sure that my threads won't Lock a mutex for so long time.)
On Dec 4, 2007 10:11 PM, Christophe Pallier <christophe at pallier.org> wrote:
> All sorts of things can create latencies that will result in audio drop
> outs.
> As you mentionned in your first post: task swiches, windows minimisation,
> etc...
>
> To try and avoid this problem:
> Disable the power saving functions.
> If you can, kill all processes that are necessary.
> If you want to have task switches, increase the sound buffer length.
>
> Christophe Pallier
>
>
> On 12/4/07, Mine <mine260309 at gmail.com> wrote:
> > 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
> >
> >
> >
> > --
> > 俺たちが乗った列車は途中下車はできないんだ!
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> >
> >
>
>
> --
> Christophe Pallier (http://www.pallier.org)
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
--
俺たちが乗った列車は途中下車はできないんだ!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071204/6a17c1c2/attachment.htm
More information about the SDL
mailing list