jl.blog()

Whatever crosses my mind.

2005-07-10

Avoiding audio skipping in Linux 2.6

After upgrading to the 2.6 kernel series in Debian Sarge I had terrible problems with sound skipping when switching desktops or tabs in Firefox, or basically when doing anything that takes a significant amount of CPU. Adding a larger buffer to xmms, killing artsd or switching audio drivers didn't help.

The reason was actually a combination of two factors:

First of all, when using the 2.6 scheduler, it is advisable to run the X server at nice value of 0, instead of -10, which is the default after installation. If X is at -10 heavy X operations (like Firefox redrawing a web page) will make lower priority apps starve.

Second, zsh has the option bgnice, which makes commands started in the background with & to be run at nice 5. This option is on by default, unlike in, for example, bash.

So, if you start xmms with the command "xmms &" and run X at -10, the result is that sound will skip horribly.

The remedy was quite simple: run 'dpkg-reconfigure xserver-common'. This will explicitly ask for the nice value for the X server and will explain that 0 is the appropriate value when running under kernel 2.6. Too bad this wasn't done or suggested by default when upgrading to 2.6.

For more information, see http://ck.kolivas.org/audio_hints.txt or this kernel mailing list posting.