The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL Alsa and CPU load.
GrosBob LeBlanc
Guest

Hi SDL Gurus ,

I have just compiled and installed SDL 1.2.14 on my ubuntu 9.04 machine. Then i rebuild my emulator with the
new library. Every thing runs fine except that the emulator take 100% of the CPU time. I also notice one buffer
underrun warning coming from ALSA layer. After research, i noticed that everything runs as before if i disable
ALSA with the ./configure :  ./configure --enable-alsa=NO. There is no problem when SDL is using OSS for sound
system, the cpu load is around 15%.

Here is my question : Is it a know bug or is it a (feature?) normal thing, because ALSA is doing very accurate polling
to limit latency or something else ? Has anyone ever had the same problem ?

Regards
SDL Alsa and CPU load.
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
What's the output with the environment variable SDL_AUDIO_ALSA_DEBUG=1 ?

On Mon, Oct 26, 2009 at 10:42 AM, GrosBob LeBlanc wrote:
Quote:
Hi SDL Gurus ,

I have just compiled and installed SDL 1.2.14 on my ubuntu 9.04 machine. Then i rebuild my emulator with the
new library. Every thing runs fine except that the emulator take 100% of the CPU time. I also notice one buffer
underrun warning coming from ALSA layer. After research, i noticed that everything runs as before if i disable
ALSA with the ./configure :  ./configure --enable-alsa=NO. There is no problem when SDL is using OSS for sound
system, the cpu load is around 15%.

Here is my question : Is it a know bug or is it a (feature?) normal thing, because ALSA is doing very accurate polling
to limit latency or something else ? Has anyone ever had the same problem ?

Regards


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC
GrosBob LeBlanc


Joined: 27 Oct 2009
Posts: 2
Thanks for the fast answer.
Here is the output of the program after setting the environment variable SDL_AUDIO_ALSA_DEBUG=1

ALSA: period size = 64, periods = 16, buffer size = 1024

Then, several seconds later i got:

ALSA lib pcm.c:7228:(snd_pcm_recover) underrun occured

I have no more traces on the terminal. For information, i'm trying to play 22050hz AUDIO_S16LSB mono channel samples,
with a format.samples set to 512.

Regards
Additionnal information
GrosBob LeBlanc


Joined: 27 Oct 2009
Posts: 2
I have additionnal information:
I recompiled my emulator to use a larger sample buffer (1024 values instead of 512). The CPU load immediatly lowered to
more normal values, but i get a bigger latency. I can imagine that ALSA is more cpu intensive compare to OSS (?).
512 values at 22050Hz give 23 ms, this is quite an eternity for a cpu. Do you think this is a too optimistic value ?

Nevertheless, the CPU load is clearly lower using OSS.

Regards