Can you name a single feature or use case addressed by PulseAudio that isn't addressed by ALSA?
Why write for ALSA when the distro ships with PA, and so all of its configuration tools are PA-focused?
Basically, if you want multiple sounds playing at the same time (e.g. music + desktop notifications) and you don't have hardware mixer (many common sound chips don't and rely on Windows drivers/sound system to provide the functionality), you are out of luck (no, the ancient dmix plugin is not a solution!). Bluetooth audio (headsets) doesn't really work without PA.
Configuring apps to use different devices (music should go to speakers and video conferencing to a headset ...) is a pain without PA - most applications don't let you select the input/output devices.
And many other things. ALSA is good, but without PA the sound support on a modern Linux desktop would be stuck right in the late 90s. Is it necessary? Not strictly, but it is one heck of a convenience that most don't even realize they have.
Here is a good post from 2008 explaining many of the issues PulseAudio solves and addressing some of the old FUD:
http://0pointer.de/blog/projects/jeffrey-stedfast.html
Unfortunately, there are tons of people with strong opinions about both PA and systemd but very little actual knowledge about what these components do and what issues they address in a modern Linux/Unix system. But that doesn't prevent them from spreading BS FUD and conspiracies about this or that group trying to dominate the market or take over the competing Linux distros.
Given that that's exactly what it's for, why isn't it?
If that really is the case you could use dmix and have audio played on both the headphone and speaker output. You would still have to mute the speakers when plugging in the headphones though.
You're stating that Pulseaudio isn't necessary because someone could do the same thing with a combination of dmix and manual intervention? Have you considered the possibility that someone might like the convenience of not needing to do manual intervention?
I just pointed out a possible solution/workaround with ALSA and dmix for redirecting the audio output to two devices/pcm outputs.
After years of using just ALSA and messing around with its config on different computers I am now using Pulseaudio too. Once it's running it's a lot easier to use and more flexible, especially when it comes to hot-plugging and switching between inputs and outputs.
* playing audio from/to another Bluetooth device (with bluez)
* playing audio on a PulseAudio server running somewhere on the network
* transparent encoding of audio output as DTS (for surround support over SPDIF)
I also seem to remember plain ALSA having trouble with multiple applications playing sound at the same time, which is just pathetic.
I'm sure some of these could in theory be built on top of ALSA, but fact is that today's Linux distributions use PulseAudio, and for me it always worked well.
Pulseaudio is a very finicky troublesome bit of open source software. The alternative (ALSA) is much more friendly to work with. Any seasoned sysadmin probably welcomes the death of Pulseaudio.
For every other case I've seen, ALSA is better and causes fewer problems.
If your audio chipset doesn't have a hardware mixer, and about of half of laptop chipsets don't, then you can't play more than one stream at a time. If you have an array microphone, the only way it'll work at all is with Pulseaudio. If you want Bluetooth audio, only Pulseaudio bothers to support it.
Pulseaudio uses ALSA anyway (and on DFBSD it uses OSS instead); it's not a replacement, it is the only unix sound server other than Apple's(and maybe OpenBSD's) which actually works. ALSA is an audio device driver ABI; it can only expose what your chipset supports in hardware.
The problem of Pulseaudio spinning, at least when it used to happen on Linux, is due to issues in the individual audio device drivers. The reason this is a big problem is that Pulseaudio needs to run at a low `nice` value in the scheduler, or you will get buffer underruns (which sound like pops and clicks). Unfortunately this means that if Pulseaudio goes into a hot loop, it will consume all of the available CPU resources until the loop breaks. This problem can be mitigated by running pulseaudio with a control group to limit CPU time (as is done with systemd on many Linux distros). Unfortunately, DragonFlyBSD doesn't have the same thing configured, assuming their kernel supports it, so you get 100% CPU spinning.
Furthermore, DragonFlyBSD doesn't have ALSA; they have OSS.
The reader is encouraged to download a KXStudio LiveUSB image, and see all the cool things JACK allows that PulseAudio cannot/will not catch up to.
For some things, but not for others. They are really not even competing to be in the same space. Such blanket statements do not help.
The obvious question, though, is: is there a emulation layer for JACK that supports the PulseAudio API?
That's not to say JACK isn't useful; but it isn't a solution to the desktop audio problem, it's a solution to the professional audio problem.
JACK also doesn't have the semantics and auto-configuration code which makes Pulseaudio work out of the box, and it is considerably more difficult to make JACK control clients. These are more reasons why even though JACK existed before Pulseaudio, it was not integrated with common user applications.
Not true. ALSA with dmix can do software mixing, and dmix is enabled by default.
I also really miss ESD, which also enabled software mixing (this was before dmix) but was far simpler and wasn't this over-complicated mess like PulseAudio.
You _can_ install OSS4 if you want to, at the expense of loosing proper power management support; not a big issue on Desktops, but it can reduce a laptops battery runtime significantly.
Either way PulseAudo does not know how to talk to audio hardware by itself (well, it sort of does as far as Bluetooth attached devices is concerned, but the whole Linux Bluetooth stack "BlueZ" is quite finicky on its own). It needs (just like Jack, esd, aRTs, Xaudio* and all the other sound servers out there (*= dead and burried)) some way to talk to the hardware. And that, at the moment usually is ALSA.
When ALSA was first developed the original plan was to implement all the must haves (mixing, resampling) though the userspace module support. Unfortunately it ended up in an unholy mess and never worked satisfyingly. To anyone who's spent considerable amount of time developing audio software (in hindsight) that's not a big surprise. Audio raises very hard and tight deadlines. The way ALSA dmix implements mixing through IPC mechanisms is extremely prone to buffer underruns because of some participating process not getty enough CPU cycles in time to complete to write out the next bunch of audio.
PA does plaster over the biggest cracks in the foundations of the Linux low level audio infrastructure. And given the circumstances it does an admirable job there; if it doesn't break things even more. But it's only treating the symptoms and not curing the underlying issues.
Here's the laundry list of what's required to fix the major bumps in the road (which also PA has to navigate):
- major simplification and cleanup of the kernel side driver model. Too many things are left optional for the drivers to implement
- tight requirements on how kernel drivers must behave (there's a lot of variation in the runtime behavior of certain drivers; some return immediately from read write functions, others have significant delay, timestamps reported may be increment coarsely based on a per-buffer-length base, others deliver smooth playhead/recordhead position updates)
- mixing / fanning _must_ happen in or close to the kernel (the reason for that is explained in the next point). The biggest issue here is that resampling may be required. As long as it's upsampling it's rather unproblematic actually (the only DSP challenge there is not creating artifact frequencies). Downsampling is a much harder problem, because it involves lowpass filtering, i.e. discarding information and the challenge is only to affect the stuff above the Nyquist frequency.
- the audio infrastructure must be able to reschedule processes based on the deadlines and time left until new samples are required. Audio is probably the most demanding of the soft realtime applications. A single missed sample is easily noticeable even to the most untrained pairs of ears. If your buffers underrun you get pops or crackles. However on an interactively used system acceptable audio timing mismatches are in the order of 5ms before an untrained brain is able to pick them up. Raising audio applications to realtime priority alleviates the issues, but the better solution is to keep statistics on the audio frame lengths read/write by a process, how much time it takes for a process to prepare the next frame and use that to augment the scheduling. However this raises the issue being able to circumvent priority privileges through the audio system; a mitigation would be that frame sizes are quantized to a minimum frame size that correponds to the amout of CPU time the process would be alotted in regular scheduling (that's a tough one and I've been strugling with it for some time).
When it comes to OSs with a monolithic kernel a very good question is, if the last two parts absolutely have to happen in the kernel or if it's possible to have them in userspace. If we want to implement it in userspace, then, because of the rescheduling issues this will require the addition of userspace based rescheduling capabilities the syscalls required for this.
Of course with a proper audio infrastructure present through standard kernel and/or driver interfaces the need for a system like PulseAudio vanishes; at least as far as mixing and resampling are concerned. It's still desireable to have an audio manager process that knows how to decide on which device to play certain audio (telephone calls go to the headset, music goes to the speakers and so on).