Hacker News new | ask | show | jobs
by jojo14 2093 days ago
Firefox is my browser of choice and I gladly appreciate much of the improvement the devs put in it. However under Linux an improvement would be to get rid of Pulseaudio and to directly interface with ALSA. The benefit would be that installing FF wouldn't require unwanted dependencies and audio quality would be improved.
4 comments

>and audio quality would be improved

Only one audio stream at a time can use ALSA, how would that be an improvement?

I don't have PA on my system and I am able to play audio from many sources at the same time using ALSA only. Not sure if this requires hardware/driver support or something, I don't have any special ALSA config.

I don't know about the audio quality improvement though, unless OP is talking about avoiding latency that comes from going through PA.

I avoided PA for years because "alsa just works". It is not until one tries to build a native linux app that you see the issue with alsa once you venture into the alsa library docs.

Indeed, alsa only supports one audio stream. This was the purpose of all the other sound daemons (arts, esd, etc) of times past. Alsa added "native" software mixing via a "dmix" [0] plugin. The end user is left with a setup that can handle multiple streams to a single sound card, however, one looses the ability to better tune how those streams are mixed.

For instance, most sound cards only support sample rates of 48khz. What happens when you have one application playing 44.1khz 16bit sound with another playing 44.1khz 32bit all while something else is playing 48khz sound? Dmix will resample and mix them into one 48khz stream, but it does so in the sloppiest way. It can be tuned somewhat, but that just makes the application linked into the alsa library consume even more CPU cycles.

Pulseaudio is much more better in this situation. It can change its sample rate on the fly. For the above scenario, it could have upsampled the one 44.1khz 16bit stream to 32 bit, and resampled the 48khz stream to 44.1khz and then piped this single 44.1khz stream to the sound card (if it supports 44.1khz audio) at much better efficiency and less work. There is really no reason to fight it anymore.

[0]: https://www.alsa-project.org/main/index.php/Asoundrc#dmix

You may have hardware support or dmix in your config.
ALSA supports software mixing (dmix) for more than 15 years and uses it as a default output for more than 10 years.
I believe on Gentoo you can compile Firefox without pulseaudio by disabling the USE flag. I'm not sure if that forces it to use ALSA or disables audio entirely though. I do use pulse, so I've never disabled it globally/for Firefox.

https://packages.gentoo.org/packages/www-client/firefox

https://packages.gentoo.org/useflags/pulseaudio

The hate for PA is as unqualified as it was for systemd. Time will tell.
I don't hate it, it just randomly stops working for me.
Tis true. Now and then,

pulseaudio -k

Both Firefox and Chromium can be built without PA support so that they use ALSA directly.