[Openal-devel] just calling ALutInit(0,0) costs 20% of CPU

Chris Robinson chris.kcat at gmail.com
Sat Mar 7 01:28:18 PST 2009


On Saturday 07 March 2009 12:23:27 am jviklaus wrote:
> >It actually does pause. The snd_pcm_writei function will block until all
> > the given audio data is written to the card, which can only happen at a
> > defined speed (the playback frequency/sample rate).
>
> as I see, it doesn't seem to block...
> so I went to add a sleep when the state isn't AL_PLAYING

snd_pcm_writei itself will put the thread to sleep until all the data gets 
written. You can't really force a rest when all the sources aren't playing 
because something still needs to get written to the card or else it 
stalls/loops.

> and yes I'm using PulseAudio, even if I don't know much about it...
> but PulseAudio uses 40 % of my CPU when my app is using 20% for the
> sound...

PulseAudio is a sound server, which can take over ALSA so the app's sound goes 
through it instead of ALSA's user libs. PulseAudio's ALSA emulation has been 
known to cause numerous problems, including poor performance and lag.

The simplest way would be to check what the app is like with PulseAudio turned 
off. IIRC, this can be done by running the app like:
pasuspend my_app app_arguments...

If it runs well that way, it's likely a PulseAudio issue. If it still runs 
poorly, the issue is probably elsewhere.


More information about the Openal-devel mailing list