Gentoo libSDL and Sound USE Flags

By Erik Letson, Dec 5th, 2020 (blog index)


I have been developing a PyGame application lately, and on my Gentoo machine I have been consistently running into a warning message from ALSA:

ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm.c:8545:(snd_pcm_recover) underrun occurred

I had encountered a similar error in the past, but at that time it was just a side effect of a deeper misconfiguration problem related to Xorg. Now, I was pretty sure I had all my configuration files in order. Whats more, It became evident that I was only getting this error when running SDL applications. This suggested a route of potential inquiry, and eventually I arrived at a promising solution - I needed to make some changes to the USE flags for my installs of libSDL and libSDL2.

On my Gentoo system, I use PulseAudio for sound, and as such I have both the pulseaudio and alsa USE flags enabled system-wide. This has produced correctly-configured applications for the most part, but it seems like enabling alsa in libSDL(2) caused the library to fall back on ALSA even if Pulse was the main sound server on the system. The solution was simply to disable the alsa USE flag for media-libs/libsdl and media-libs/libsdl2 in package.use. After a re-emerge, all seems to be functioning normally.

This is a bit of a strange issue, especially since I haven't run into it outside of Gentoo (this SDL application doesn't have this problem on Ubuntu, Manjaro, or Mint). It seems to be fixed now, however, and I am perfectly happy with this USE flag config, seeing as I have encountered no other problems thus far. We'll just have to see how it goes.

Return to blog index