Audio hw profiling supports USB cards
January 21, 2020 —
BarryK
I posted about audio hardware-profiling:
https://bkhome.org/news/202001/improved-hardware-profiling-for-audio.html
Today one of the USB audio "cards" arrived, purchased from eBay. It
works great, and hardware-profiling has been extended to include USB
devices. Here is how the hardware-profile is computed in /usr/sbin/mscw:
#200113 hardware-profile... 200115 improve...
SND_HW_PROFILE="${card}+"
AUDIO_IDS="$(lspci -d ::0403 -n | cut -f 1,3 -d ' ' | tr ' ' '|')" #ex: 00:1b.0|8086:1c20
CARD_PATH="$(readlink /sys/class/sound/card${card})"
#...ex: ../../devices/pci0000:00/0000:00:1b.0/sound/card0
echo "$CARD_PATH" > /tmp/10alsa-CARD_PATH
#200121 detect usb audio device...
USB_SUBPATH="$(grep -o '/usb[0-9]/[0-9.:-]*/[0-9.:-]*/' /tmp/10alsa-CARD_PATH)" #ex: /usb3/3-2/3-2:1.0/
#...ex: ../../devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb3/3-2/3-2:1.0/sound/card1
if [ -e /sys/bus/usb/devices${USB_SUBPATH}modalias ];then
aID="$(cut -c 6-14 /sys/bus/usb/devices${USB_SUBPATH}modalias)" #ex: 8086p0808
aID="${aID/p/:}"
SND_HW_PROFILE="${card}+usb+${aID}"
else
for aAID in $AUDIO_IDS
do
aPTH=":${aAID/|*/}/sound" #ex: :00:1b.0/sound
aID="${aAID/*|/}" #ex: 8086:1c20
if grep -q "${aPTH}" /tmp/10alsa-CARD_PATH;then
SND_HW_PROFILE="${card}+pci+${aID}"
break
fi
done
fi
echo "#SND_HW_PROFILE='${SND_HW_PROFILE}'" >> /etc/asound.conf
cp -a -f /etc/asound.conf /etc/asound.conf.${SND_HW_PROFILE}
An example profile for a USB card is "1+usb+8086:0808". Also, /etc/init.d/10alsa has been edited.
Tags: easy