tl;dr Having
sndiod_enable=YES set or starting the daemon is not necessary.
So I think there is some confusion here on the forums about how sndio, OSS, ALSA, etc. fit together.
Sndio has a layered architecture, and you can separate it into multiple components:
- libsndio provides an API for applications
- sndiod provides network transparency, splitting an audio device into multiple sub-devices, application level volume control, synchronized start/stops via MIDI messages, etc.
- the native audio device
Here are some of the basic example use cases and a representation of the data flows for each (-> means 'writes to' or 'reads from'):
- Use it without having sndiod running
Code:
sox
-> libsndio
-> sound(4)
- Using it with a local sndiod running
Code:
sox
-> libsndio (via aucat backend over UNIX socket)
-> sndiod
-> libsndio
-> sound(4)
- Play remotely by e.g. setting the AUDIODEVICE environment variable to something like e.g. snd@remotehost/0
Code:
sox
-> libsndio (via aucat backend over TCP/IP)
-> sndiod on remote host
-> libsndio
-> sound(4) or ALSA or audio(4)
The remote host can be one of the supported systems i.e. FreeBSD, Dragonfly, Linux, or OpenBSD.
You can also chain multiple sndiod instances together if you want to, so this can get way more complicated quickly.
libsndio is smart and has a strict and practical fallback order for
sio_open(3), so in the common case there is indeed nothing to configure:
- Is the AUDIODEVICE environment variable set? If yes use it to determine where audio should go and skip everything else here.
- Do we have a user local daemon running as device 0 unit 0 (i.e. snd/0)?
- Do we have a system daemon (i.e. a daemon started through the rc script or simply
sndiod
as root) running as device 0 unit 0 (i.e. snd/0)?
- If nothing of the above applies use /dev/dsp (the default device) directly. Note that this behavior is special to the FreeBSD port. I wanted it to just work in the common case. On Linux and OpenBSD it would fallback to the first device /dev/audio0 instead.
So armed with the information above we can actually start debugging the problem you have with sox. Start a user local sndiod instance as your user with
sndiod -dd
(add more
ds to make it more verbose) then run
sox
. Audio will go through your sndiod instance, so a message like
Code:
sox0: 44100Hz, s16le, play 0:1, 19 blocks of 470 frames
should appear in the terminal where sndiod is running when sox connect to the daemon. If necessary you can also set the
SNDIO_DEBUG environment variable to 1, 2, ... to increase verbosity of libsndio.
As a side note and only AFAIK, the packages on TrueOS UNSTABLE are all compiled with the SNDIO option turned on (and ALSA, JACK, PULSEAUDIO turned off). So that might be a faster or more convenient way to try it out with larger applications like e.g. Firefox or Chromium without having to recompile them.