Hacker News new | ask | show | jobs
by shiftpgdn 3586 days ago
This is a dumb comment and akin to predicting the iphone would fail because it doesn't have flash support.

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.

5 comments

Just so you and others know, the L in ALSA stands for Linux. It doesn't run on DragonFlyBSD. I think DragonFlyBSD uses a re-implementation of the OSS API that they inherited from FreeBSD. The other BSDs use /dev/audio, which was originally a Sun API.
Let's be fair: PulseAudio is the way to go if you have to have a partitioned audio system because you are using a multiheaded multiuser system where each seat has a monitor and keyboard and mouse and mic and speakers, and each user needs to be able to control their own volume mixing without root privileges.

For every other case I've seen, ALSA is better and causes fewer problems.

I have already encountered the need for multiheaded system. I wanted to run a second X server on my third screen in order to have a separate mouse. I have not found any website explaining this kind of setup. I have never succeeded: the mouses were active on both X servers.
You need to have a separate xorg.conf for your separate X instance. (Edit) and you need to hardcode each device, not allow autodiscovery.
ALSA is not an alternative to Pulseaudio.

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.

> 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.

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.

dmix is terribly broken.
JACK is a (better) alternative to PulseAudio, works in BSD, works with ALSA and OSS, and is superior in every way.

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.

JACK doesn't have Bluetooth support, nor array microphone support. It is also terrible on battery, and doesn't perform correctly on a non-realtime kernel.

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.

> JACK is a (better) alternative to PulseAudio

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.

I've played with JACK a bit, and I've always found it pretty obtuse, but that was a while ago.

The obvious question, though, is: is there a emulation layer for JACK that supports the PulseAudio API?

There is some limited interoperability by nesting PA within JACK: http://www.jackaudio.org/faq/pulseaudio_and_jack.html
JACK existed pre-Pulseaudio and it wasn't used by very much software. Most things only supported ALSA / OSS / eSound / whatever KDE's sound system was.
I wouldn't really consider ALSA as an alternative to PA, considering that PA generally sits on top of ALSA instead of replacing it. aRts and ESD of the olden days would be more comparable.
PulseAudio is not a replacement for ALSA. At the moment ALSA is the only kernel level API for talking with the hardware drivers that's fully supported by upstream (= the kernel devs).

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).