Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD sndio via ALSA on ARCH Linux works #200

Open
purple-mountains opened this issue Sep 17, 2017 · 3 comments
Open

OpenBSD sndio via ALSA on ARCH Linux works #200

purple-mountains opened this issue Sep 17, 2017 · 3 comments

Comments

@purple-mountains
Copy link

purple-mountains commented Sep 17, 2017

How to get OpenBSD sndio working through ALSA on Linux

I used ARCH Linux

$ sudo pacman -S sndio

$ cat /etc/conf.d/sndiod
OPTS="-f rsnd/1"

Assumes your bdwrt5677 card is the second device. If it's the first device, use

OPTS="-f rsnd/0"

but you won't get full audio from 0-max volume, on say mplayer or mpv.

Try it as an exercise - change your index in the .conf file in /etc.modprobe-d/, and notice the lower volume range to be much louder when it's our second device, versus setting it as the first device, "...index=0".

Start sndiod as user or root

$ sndiod -dddd -f rsnd/1

$ sudo sndiod -dddd -a on -f rsnd/1

For some reason, I need the "-a on" flag when starting it as root.

If I try

$ sudo sndiod -dddd -f rsnd/1

sndiod won't open it's first device when called upon to play audio, sndiod first device, snd/0, is mapped to rsnd/1 - our bdwrt5677 card.

If I try

OPTS="-a on -f rsnd/1"

in /etc/conf.d/sndiod, and start it through systemctl, sndiod won't open snd/0 for some reason. It won't open snd/0 either, if I try "-a off", or no -a option. Starting it through systemctl seems to be broken, or I'm missing something.

In the ARCH install, I manually added /var/lib/sndiod - doesn't seem to create it, on installation.

I only get success starting it as the same user, or sudo sndiod with -a on.

A copy of .asoundrc, see below, was made to /etc/asound.conf whilst getting sndiod to start via systemctl.

Thanks to http://billauer.co.il/blog/2014/04/alsa-pipe-playback-capture/ for hints on creating my asound.conf file. I couldn't work out why I was getting scrambled noise, till I read it.

$ cat $HOME/.asoundrc

pcm.sndio {
type asym
playback.pcm "sndio-play"

hint {
	show on description "OpenBSD sndio"
}

}

pcm.sndio-play {
type plug
slave {
pcm "sndio-raw"
rate 48000
format s16_le
channels 2
}
}

pcm.sndio-raw {
type file
slave.pcm null

format raw
file "| aucat -f snd/0 -i -"

}
pcm.default sndio

Note: We need "channels 2" in the config, else we get scrambled output, like it's played at twice the speed. Try commenting it out, and hear the difference.

$ aplay -L

should show our new OpenBSD sndio PCM device

If you don't want sndio as the default just comment out "pcm.default sndio"

Test it works

$ aplay -D sndio -i /usr/share/sounds/alsa/Side_Right.wav
$ aplay -D default -i /usr/share/sounds/alsa/Side_Right.wav
$ aplay -i /usr/share/sounds/alsa/Side_Right.wav

and watch the messages scroll in the window we started sndiod.

mplayer doesn't sink audio / video in time, but it illustrates sndio via ALSA works.

$ mplayer -ao alsa:device=sndio _VIDEO_AUDIO_FILE

if sndio is our default device

$ mplayer -ao alsa _VIDEO_AUDIO_FILE

Enjoy!

@purple-mountains
Copy link
Author

To run sndiod from systemd, we cannot have

User=sndiod /* this is wrong */

in sndiod.service

sndiod can be run either as any local user, or root, and not user "sndiod".

Either set

User=root

or remove User, defaults to root, on ARCH Linux.

@purple-mountains purple-mountains changed the title OpenBSD sndio via ALSA on Linux works OpenBSD sndio via ALSA on ARCH Linux works Sep 18, 2017
@unsafe-andrew-old
Copy link

Thank you so much! Finally got it working

@jobbautista9
Copy link

jobbautista9 commented May 18, 2022

I've found a way to improve the latency. It's still not perfect, but may be acceptable for some playing say Touhou in wine. Set both sndiod and aucat to use a buffer size of 512 (-b 512). This should give you a latency close to 20ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants