2016: Pulseaudio sucks because.. reasons.
I lived through the days of horrible sound support on Linux - I think it was my main desktop until my first Mac around ~2007. Playing video or games was a crapshoot. Hot-plugging audio wasn't even in the realm of possibility.
It makes sense to have some user-space audio layer. Software mixing, sample rate conversion, and a few other things just make sense in user space, and we can expose only bona fide hardware capabilities through the device interface. Of course, most desktop audio chipsets have hardware mixing, which means that most people think that you can just use OSS (or ALSA on Linux), and it will work. It just doesn't work on everybody's hardware.
In short, there's a hardware jungle out there and software layers like PulseAudio smooth over the differences. It's a shame that it doesn't always work well, and most people think PulseAudio is the source of the problem because most people have hardware mixers.
By comparison, if you just use OSS (or ALSA on Linux) on my computer you might see that incredibly basic features like volume control or the ability to play audio from multple apps don't even work without PulseAudio.
Not that it matters, as Wayland and systemd slowly eradicate all cross-compatability in software complex enough to care.
Which is kind of ironic, when you think about it...
Lots of comments saying ALSA doesn't do mixing. This is false. ALSA has always supported mixing through dmix, and it's enabled by default.
Lots of comments saying ALSA doesn't do hotplugging. This is also false - hotplugging works like any other hardware on Linux. Plug it in and it shows up. To configure that card as the default requires changing a configuration file. You can make this happen automatically with udev.
Lots of comments saying ALSA doesn't work with bluetooth headsets. Google "bluez-alsa" folks. FFS.
Now, that's not to say that all of this worked seamlessly. Configuring everything through /etc/asound.rc or .asoundrc was a pain, in large part because there were no GUI tools to do so. And because applications read .asoundrc on startup, there was no way of switching a playing stream to a different card, live. THAT is the use case that a userspace daemon solves.
The upsetting thing is we already had two userspace daemons, aRts and ESD [KDE and GNOME respectively], that more or less worked fine. Instead we suffered with years of broken audio.
Honestly, I'm surprised DfBSD even supported PulseAudio (or vice-versa) in the first place.
It doesn't reinvent the wheel and for anything more complex you can always use JACK, like if you really want to go low-latency.
The problem is that most people complaining about Pulseaudio don't offer realistic alternatives. Saying Pulseaudio sucks and that everyone should use ALSA is a joke. Pulseaudio does a plethora of things that ALSA does not handle. Not to mention that ALSA is a low-level system, and PA actually sits on top of ALSA.
In all of the vitriol that people spew about Pulseaudio, this is the first time that I've seen anyone point to sndio. I think that says something about the "pulseaudio complainers" crowd.
That said does sndio provide the following features:
- Support for bluetooth audio devices
- Support for streaming audio over a network.
- Support for user-land mixing of audio sources (i.e. don't need root).
- Mixing of multiple audio streams at the same time (e.g. Can your system play an alert sound without interrupting your music?)
- Per application volume settings
- Per application input/output source settings
> Per application input/output source settings
No, but the input/output device is selectable per application via the AUDIODEVICE environment variable.
> bluetooth audio devices
OpenBSD has no bluetooth support, so no. I'm also wondering why the kernel wouldn't create audio devices from these that the userland daemon can then just transparently use? Does an audio daemon need special support for bluetooth audio devices?
The sndio daemon has more features. Give the man page a read if you're interested: http://man.openbsd.org/OpenBSD-current/man8/sndiod.8
Can you name a single feature or use case addressed by PulseAudio that isn't addressed by ALSA?
* 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.
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).