[AD] Alsa driver hogs CPU

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I just noticed that Allegro programs using the Alsa driver take all the
CPU (actually, ps says exactly 50% for some reason) as soon as
install_sound is called, even if nothing else is done. The OSS and ESD
drivers stay at 0%. gdb tells me that the problem is in some thread
being busy inside alsa_update all the time.

Since other ALSA using programs don't do this - it doesn't seem to be a
problem with my ALSA version. I'm wondering if anyone knows what is
going on? Should Allegro send data to ALSA in a different way? Or just
put a [nano]sleep() call into alsa_update? Just asking here before
looking into it - in case someone already knows how to fix it :)

That's the code I used for testing:

#include <allegro.h>

int
main (void)
{
   allegro_init ();
   set_gfx_mode (GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
   install_sound (DIGI_ALSA, MIDI_NONE, NULL);//DIGI_OSS DIGI_ESD
   while (1)
   {
      struct timeval tv = {0, 1};
      select (0, NULL, NULL, NULL, &tv);
   }
}
END_OF_MAIN ();

Btw., this reminds me, wouldn't it be useful to have a function
al_sleep()? It would be like rest(), but work like yield_timeslice().
Just a platform independent way to release the CPU for some time.
al_sleep(0) would do the same as yield_timeslice() - which could be
deprecated.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/