Date: Tue, 03 May 2022 15:36:25 -0400 From: Mazin Fadl <mazen@illumed.net> To: freebsd-questions@freebsd.org Subject: get uaudio pcm/mixer device name using devd Message-ID: <8635hq1j8c.fsf@mars.illumed.net>
next in thread | raw e-mail | index | archive | help
Hi all, Using devd, is it possible to pass through to an action the pcm/mixer device name created when a usb audio device is attached? My objective is to set the default sound device to a specific usb audio device, which can't be hardcoded via sysctl 'hw.snd.default_unit' due to device order switching with multiple usb audio devices. I have a working configuration using the following devd.conf: notify 100 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "ATTACH"; match "vendor" "0x040d"; match "product" "0x340b"; action "/etc/set_usb_audio.sh"; }; and in set_usb_audio.sh: #!/bin/sh # get our preferred mixer cardnumber=$(mixer -a | grep -F 'snd_uaudio (play)' | grep -o '[[:digit:]]\+') if [ -n "$cardnumber" ]; then logger set_usb_audio.sh: found usb audio playback on dsp$cardnumber # set default audio card mixer -d "$cardnumber" >/dev/null # unmute our FX-AUDIO dac mixer -f /dev/mixer"$cardnumber" pcm2=1 >/dev/null fi mixer -a doesn't print the usb product names for my devices, its output is generic, like: pcm12:mixer: <USB audio> at ? kld snd_uaudio (play) ... pcm13:mixer: <USB audio> at ? kld snd_uaudio (rec) which makes my current matching method broad, hence the question about passing through the pcm/mixer device name variable from devd. Thanks, mazin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8635hq1j8c.fsf>