On Fri, Jan 24, 2020 at 04:04:40PM +0100, Thomas de Grivel wrote: > Hello misc, > > I have a USB M-Audio card which is very well supported by OpenBSD 6.6 amd64 > > My question is : how do I setup an USB audio card as the default audio > device whenever it is plugged in ? > > Also I did not manage to get audio output with environment variables > only, I had to swap /dev/audio0 and /dev/audio1 and then it worked. > Could it have something to do with sndiod not running for /dev/audio1 > ? > > In all cases I really like sndio, it is really easy to work with.
Hi, You could define the internal device the main one (-f option) and add the usb device as alternate device (-F option). In this case sndiod will use the usb one perferably and switch to the internal one when the usb one is disconnected. For instance set: sndiod_flags=-f rsnd/0 -F rsnd/1 in /etc/rc.conf.local and restart sndiod. There's no way to detect when the usb device is connected again. sndiod will start using it the next time it needs to open a device. As programs tend to keep the device open, you could force sndiod to reopen the devices (and thus switch to the usb one) by sending it a HUP signal. On 6.6 you have to "pkill -1 -x sndiod", on -current the rcctl script does it for you: rcctl reload sndiod HTH, -- Alexandre