Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 May 2022 19:50:41 -0400
From:      Mazin Fadl <mazen@illumed.net>
To:        questions@freebsd.org
Subject:   Re: get uaudio pcm/mixer device name using devd
Message-ID:  <86y1ziyx6v.fsf@mars.illumed.net>
In-Reply-To: <8635hq1j8c.fsf@mars.illumed.net>
References:  <8635hq1j8c.fsf@mars.illumed.net>

next in thread | previous in thread | raw e-mail | index | archive | help
I've solved my problem by referencing the kernel log in the action
script to find the pcm/mixer device.

The updated configuration in case it is useful to someone else:

attach 100 {
        # find vendor and product ids to match against
        # from devinfo(8) or usbconfig(8)
        match   "vendor"        "0x040d";
        match   "product"       "0x340b";

        action "/etc/set_usb_audio.sh $device-name";
        # for our device gives "uaudioN"
};

in set_usb_audio.sh:

pcm=$(grep -F "$1" /var/log/messages | grep -o 'pcm[[:digit:]]\+' | tail -n1)

if [ -n "$pcm" ]; then
	logger set_usb_audio.sh: found usb audio playback on "$pcm"
	# set default audio card
	mixer -d "${pcm#pcm}" >/dev/null 2>&1
fi

Possible path not taken is to use devinfo(8) output, instead of the
message log, to find the pcm device but this was easiest.

Regards,

mazin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86y1ziyx6v.fsf>