In-kernel audio mixing
Ever since PulseAudio started to be deployed by distributions the most common complaint I’ve seen about ALSA is that unlike current versions of OSS it doesn’t provide mixing of audio from multiple applications inside the kernel. Of course what it really comes down to is that people want the system to transparently allow multiple applications to play audio simultaneously.
The reason ALSA does things the way it does is that the ALSA APIs that applications interact with are actually implemented by a library. This library provides a plugin based way of defining sound cards, one of the options for which is that the audio can be routed to or from some hardware, but sound can also be routed to other places like networked speakers. This architecture also allows plugins to provide signal processing – mixing is the example most people notice but things like soft volume controls (not all sound hardware provides volume control) or EQ are also possible.
This could all be implemented in kernel space but there’s some serious drawbacks in doing so. There are some substantial restrictions on what kernel space code is allowed to do, one of the most relevant being the fact that floating point instructions can’t be used. It’s harder to develop kernel code, if for no other reason than the fact that kernel code can crash the system. The main benefit that people expect from pushing things into the kernel is performance but with the facilities available in Linux there’s no real reason why performance would be better with a kernel mode implementation, kernel and user threads are both scheduled together and shared memory is available.
So why are people running into issues with PulseAudio? Obviously some of them are just bugs in PulseAudio – the much wider deployment that cones with being used as standard in distributions means much wider testing – but that’s not all of it, especially now PulseAudio has been in distributions for a while. The other major source of issues is that due to the need to adapt to the different needs of the applications that it is mixing together PulseAudio is a very demanding user of drivers. This means that switching to PulseAudio can expose bugs in the drivers, often bugs that have existed for years. There’s a natural tendency to blame PluseAudio when this happens but the fixes that are needed are in the drivers.
None of this is terribly helpful if you’ve been bitten by one of the bugs of course, but hopefully it goes some way towards explaining why this implementation has been chosen and why there have been problems.