Using sndio in place of pulseaudio

Like me, you might be struggling a lot with sound, ever since pulseaudio came up. However, there actually is an alternative that sparked out of the OpenBSD community. It's a light weight and just works.

Sadly it isn't what applications use per default, so one is currently forced to use ports instead of binary packages.

In /etc/make.conf (or /usr/local/etc/poudriere.d/make.conf if you are using poudriere) add the following options:
Code:
OPTIONS_SET=SNDIO # ... and what you might already have
OPTIONS_SET+=PORTAUDIO # Portaudio supports sndio, so more software supports sndio (gqrx is an example)
OPTIONS_UNSET=  PULSEAUDIO PULSE ALSA # ... and what you might already have

Now recompile your packages and that's it.

While the package comes with sndiod (via sysrc sndiod_enable=YES and service sndiod start) this isn't necessary for most users and I personally don't ever start it. See sndiod(8)for more details.

One reason to use sndiod is to control volumes per application. For this this simply activate it as described in the previous paragraph (sysrc and start it) and install the audio/aucatctl port (or package).

The little command is straight forward to use:

Run without arguments to list applications and current volums: aucatctl

Run with one or more arguments to set the volume: aucatctl master=85 mplayer0=100

Please keep in mind that the applications need to be connected with sndiod. In other words: The need to be started after sndiod, so if you initially don't see some application either restart it or restart your system (with sndiod enabled in rc.conf).

EDIT: Mention PORTAUDIO
EDIT2: Mention aucatctl(1)
 
Last edited:
Why do we need sndio at all? OSS just works.
I wonder. I heard all the best about sndio from the OpenBSD community.
And for example, www/firefox only has 3 sound options: alsa, pulseaudio, sndio. Well, what I do currently is choose pulseaudio option and afterwards delete the port. Works fine! But this is kind of dirty...
 
IMO too, all packages should be built with sndio instead of pulseaudio,
I'm too lazy (as most of other users, I think) to rebuild firefox, for example,
and other "huge" ports on my laptop, so I'm forced to use pulseaudio
 
I heard all the best about sndio from the OpenBSD community.
They don't have ALSA emulation layer as we do.
But this is kind of dirty...
I think that firefox should use 1 backend for sound. Probably, it should be ALSA.

Personally, I try to use something one. I mean, not to use alsa, pulseaudio and sndio at the same time. Common divisor for ports I have is alsa as java/openjdk8 doesn't have additional backend support (or at least option to disable sound at all, I don't need it). Until then, OPTIONS_UNSET= PULSEAUDIO SNDIO

But I'm still curious how one can 'struggle' with pulseaudio. Can OP name at least 1 port that have pulseaudio and sndio support only ?
 
The latest versions of Firefox only support pulseaudio.

So either one has to not use Firefox, or set up another computer to run things that don't like pulseaudio. I took the lazy way and set up another box for audio like ALSA and playout software.
 
I am running Firefox 53.0.2 with ALSA. I never used pulseaudio on FreeBSD (or Linux, but for a little testing time) and neither I have it installed, so unless it connects directly to OSS (IDK) it still need ALSA to work, since pulseaudio is just a proxy.

I didn't even need to configure asound.conf to have ALSA working, it was already configured to use OSS as output.

EDIT: my question would be why someone would use pulseaudio on FreeBSD, unless for eventual ports without a choices?

EDIT2: pulseaudio was created to allow several programs to use the same audio output at same time, with separated volume controls.

I do not know how ALSA would behave on FreeBSD, but on Linux if you install it and do not configure anything (assuming it was NOT configured already by distro), but eventually setting the default audio device output (if needed), ALSA will use the dmix plugin by default.

Dmix, a the ALSA built-in software mixer, allow several programs to use the same audio output at the same time, with separated volume controls.

You can ever use pulseaudio on something that force you to use it and still use ALSA for everything else without having any conflict. I do not remember ALSA configuration details, but NOT setting pulseaudio as default PCM should work.
 
IMO too, all packages should be built with sndio instead of pulseaudio,
I'm too lazy (as most of other users, I think) to rebuild firefox, for example,
and other "huge" ports on my laptop, so I'm forced to use pulseaudio

Firefox started requiring pulseaudio a few versions back for things like Webrtc support. Currently pulseaudio is needed at build time but is not required at runtime.

So for now the situation is that, if pulseaudio is not present at runtime, Firefox's sound output will just fallback on ALSA, which is what most users want.

However the bad news is that ALSA support is going away very soon (version 54). At that point you will need either pulseaudio or sndio, and I guess most people will want to switch to the later. I think the maintainer is aware that pulseaudio is not very popular here, so it's likely that the default sound option will be switched at some point.
 
I do not know how ALSA would behave on FreeBSD
Better than on linux. It's just a wrapper/proxy that redirects actual work to OSS. We have all nesessary mixing in kernel.
Firefox started requiring pulseaudio a few versions back for things like Webrtc support.
This is not true. Firefox doesn't need pulseaudio on build or runtime. Package options defaults to pulseaudio, but can be changed.
Officially, latest version of firefox use pulseaudio by default, but alsa code was not removed [yet]. Build option what backend to use exists as well.
 
Firefox started requiring pulseaudio a few versions back for things like Webrtc support. Currently pulseaudio is needed at build time but is not required at runtime.

So for now the situation is that, if pulseaudio is not present at runtime, Firefox's sound output will just fallback on ALSA, which is what most users want.

However the bad news is that ALSA support is going away very soon (version 54). At that point you will need either pulseaudio or sndio, and I guess most people will want to switch to the later. I think the maintainer is aware that pulseaudio is not very popular here, so it's likely that the default sound option will be switched at some point.

That is not correct. ALSA and PA are disabled here. I can even verify that sound is actually controlled via sndio by connecting it to sndiod. So it's certainly not bypassing sndio.

Also disabling pulseaudio and enabling sndio which is achieved by the conig above will disable the pulseaudio build/runtime dependency.

I don't build pulseaudio package at all on my poudriere. Sound works like a charm in Firefox. That's actually the reason why I wrote this mini-howto. Because it really *does* work and is actually really simple, even though a lot of people seem to think it doesn't.
 
Because it really *does* work and is actually really simple, even though a lot of people seem to think it doesn't.

ALSA really does work? But you said that it's disabled for you? Now I'm really confused. Also, I think the question is whether Firefox actually will require pulseaudio.
 
Yes, pulseaudio is not required now, to install firefox,
as it was some time ago, but even now firefox is built with pulseaudio support —
% pkg info -f www/firefox:
Code:
Options        :                                                                                                                                                                         
        [b]ALSA           : on[/b]                                                                                                                                                              
        BUNDLED_CAIRO  : on                                                                                                                                                              
        CANBERRA       : off                                                                                                                                                             
        DBUS           : on                                                                                                                                                              
        DEBUG          : off                                                                                                                                                             
        DTRACE         : on                                                                                                                                                              
        FFMPEG         : on                                                                                                                                                              
        GCONF          : off                                                                                                                                                             
        GNOMEUI        : off                                                                                                                                                             
        INTEGER_SAMPLES: off                                                                                                                                                             
        LIBPROXY       : off                                                                                                                                                             
        OPTIMIZED_CFLAGS: on                                                                                                                                                             
        PGO            : off                                                                                                                                                             
        PROFILE        : off                                                                                                                                                             
        [b]PULSEAUDIO     : on[/b]
        RUST           : on
        [b]SNDIO          : off[/b]
        TEST           : off
So the point was, that it is much better to use sound server from the BSD world, in BSD OS — FreeBSD (in my opinion, of course),
than to emulate GNU/Linux audio architecture (ALSA) and to use GNU/Linux sound server (PULSE) from the systemd developer,
Lennart Poettering, a Harry Potter from the *NIX world…
ViaWqW2.jpg
 
Struggling? I always thought that sound servers exist to overcome limitations of ALSA on Linux. Why do we need sndio at all? OSS just works.
Yes, struggling. I end up having noises in the background, horrible performance, stuttering, bugs, etc. Yes, OSS is great, but doesn't work with all the software I use (firefox for example). Everyone/everything seems to want pulseaudio these days.

So I was really excited to see there is sndio support for every port I ever installed. No pulseaudio, just simply working sound. And since I feel compassion for others [1] and wanted to share that it's really just disabling pulseaudio and enabling sndio in make.conf for no more headaches.

Btw. this is not about ideology or "it's a Linux tool". It just choosing between something that doesn't work and something that does work. I would totally us a Linux distribution which can use sndio for everything instead of pulseaudio. However, while sndio is ported to Linux things don't just work. And yeah, compiling ports/using poudriere isn't for anyone, but I've always been doing that, so it's really just turning that switch.

I am really happy for that, so huge thanks to all the people that made that possible.

[1] Really, without any sarcasm. I know people spending days or weeks trying to get PA working without any issue and then they give up and going back to Windows or macOS, because basic stuff like sound is that huge issue on free systems.
 
That is not correct. ALSA and PA are disabled here. I can even verify that sound is actually controlled via sndio by connecting it to sndiod. So it's certainly not bypassing sndio.

When I mentioned the ALSA fallback it was for pulseaudio only, since sndio and pulseaudio/ALSA are mutually exclusive.
 
Ah, I completely misunderstood you then. Sorry!

I meant more that you can disable both, so you really don't have to compile them, neither as build nor as runtime dependency, if you switch over to pulseaudio.

I thought you meant that one cannot do that for Firefox. That's what the "not correct" is about. I've been running that setup for quite a bit now and thought that most people do that, but recently learned that most people didn't know you could replace it, even for big applications, like Firefox, but with that setup you will also have VLC, wine, etc. just working, without any configuration or manually setting things to OSS (not sure how well that works, in regards to blocking and so).
 
This is not true. Firefox doesn't need pulseaudio on build or runtime. Package options defaults to pulseaudio, but can be changed.
Officially, latest version of firefox use pulseaudio by default, but alsa code was not removed [yet]. Build option what backend to use exists as well.

I stand corrected, it looks it's possible to just use ALSA now. My information was obsolete. I do remember that building without pulseaudio became broken at some point and that was the reason for the default. Anyway, soon the options will be either pulseaudio or sndio and no ALSA.
 
From the OpenBSD Makefile for www/chromium and www/iridium:
GN_ARGS= enable_nacl=false \
is_debug=false \
enable_webrtc=false \
enable_one_click_signin=true \
use_kerberos=false \
use_sndio=true \
use_cups=true \
use_experimental_allocator_shim=false \
is_clang=true \
use_sysroot=false \
treat_warnings_as_errors=false \
clang_use_chrome_plugins=false \
use_allocator=\"none\" \
is_official_build=true \
fieldtrial_testing_like_official_build=true \
extra_cppflags=\"-idirafter ${LOCALBASE}/include -idirafter ${X11BASE}/include\" \
extra_ldflags=\"-L${LOCALBASE}/lib -L${X11BASE}/lib\"

Google can be little nosey so the fork iridium is also worth looking at. www/iridium has been ported to FreeBSD but it looks like the audio configuration options are Alsa or Pulseaudio.
 
BTW, how OpenBSD folks use openjdk ? It has hardcoded dependency on ALSA. Maybe we can use OpenBSD trick to avoid it ? It's the only port on my laptop without SNDIO option.
 
BTW, how OpenBSD folks use openjdk ? It has hardcoded dependency on ALSA. Maybe we can use OpenBSD trick to avoid it ?
AFAICT they simply don't build sound support. The OpenJDK build system is hardcoded to disable it on OpenBSD and it is easy enough to disable on FreeBSD too. See PR 219125.
 
Like me, you might be struggling a lot with sound, ever since pulseaudio came up. However, there actually is an alternative that sparked out of the OpenBSD community. It's a light weight and just works.

Sadly it isn't what applications use per default, so one is currently forced to use ports instead of binary packages.

In /etc/make.conf (or /usr/local/etc/poudriere.d/make.conf if you are using poudriere) add the following options:
Code:
OPTIONS_SET=SNDIO # ... and what you might already have
OPTIONS_UNSET=  PULSEAUDIO PULSE ALSA # ... and what you might already have

Now recompile your packages and that's it.

While the package comes with sndiod (via sysrc sndiod_enable=YES and service sndiod start) this isn't necessary for most users and I personally don't ever start it. See sndiod(8)for more details.
So, finally, do you argue that using SNDIO has any advantages over NOT using neither SNDIO nor PULSE/ALSA?

Because I use none of these, except that www/firefox has PA enabled (and therefore built with PA support) but I remove the pulseaudio package itself right after the installation, and everything works just fine with bare OSS. So do you argue that it will in some way work better with SNDIO? I'm about to try it, so if there are any advantages, I'd like to know.
 
So, finally, do you argue that using SNDIO has any advantages over NOT using neither SNDIO nor PULSE/ALSA?
Yes, it has a couple of advantages:

- It works, even when software drops OSS-Support
- License
- It has network features
- It doesn't mess up with multiple audio outputs

I am confused about your audio working though, as in there being no "go without" option if that works. As far as I know that should have stopped working recently, but maybe I am mistaken.
 
Back
Top