GTKC Knowledgebase
A little bit of wisdom
Linux USB audio - multiple devices
Posted by  Admin on
My MPD player has multiple USB interfaces, and I needed to maintain device order across reboots.

The output of lsusb: The first 4 characters are the vendor ID (vid) and the second 4 are the product ID (pid)
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 004: ID 04b4:930b Cypress Semiconductor Corp.
Bus 002 Device 003: ID 16d0:071a MCS
Bus 002 Device 002: ID 2622:0040
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Take note of the numbers in bold (obviously your system will be different)

Device 04b4:930b is a hiFace USB to SPDIF adapter
Device 16d0:071a is a Combo384 Amanero USB to I2S adapter
Device 2622:0040 is an Audiolab QDAC DAC

To maintain device order across reboots, the order must be set in /etc/modprobe.d/usb-audio (you need to create this file)
Add the following line: (with your own vid and pid and desired device order)
options snd_usb_audio vid=0x04b4,0x2622,0x16d0 pid=0x930b,0x0040,0x071a device_setup=0x9 index=0,1,2

This results in:
#
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: hiFace [hiFace], device 0: USB-SPDIF Audio [USB-SPDIF Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: A20 [AUDIOLAB USB Audio 2.0], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: Amanero [Combo384 Amanero], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

bash alsa-capabilities
0) Digital alsa audio output interface `hw:0,0'
- device name       = hiFace
- interface name    = USB-SPDIF Audio
- usb audio class   = (n/a)
- character device  = /dev/snd/pcmC0D0p
- encoding formats  = can't detect formats or rates because device is in use
                      by command `/usr/bin/mpd --no-daemon' with PID 457.
- monitor file      = /proc/asound/card0/pcm0p/sub0/hw_params
- stream file       = (n/a)

1) USB Audio Class Digital alsa audio output interface `hw:1,0'
- device name       = AUDIOLAB USB Audio 2.0
- interface name    = USB Audio
- usb audio class   = 2 - isochronous asynchronous
- character device  = /dev/snd/pcmC2D0p
- encoding formats  = S32_LE
- monitor file      = /proc/asound/card2/pcm0p/sub0/hw_params
- stream file       = /proc/asound/card2/stream0

2) USB Audio Class Digital alsa audio output interface `hw:2,0'
- device name       = Combo384 Amanero
- interface name    = USB Audio
- usb audio class   = 2 - isochronous asynchronous
- character device  = /dev/snd/pcmC3D0p
- encoding formats  = S32_LE
- monitor file      = /proc/asound/card3/pcm0p/sub0/hw_params
- stream file       = /proc/asound/card3/stream0


NOTE: You will need to rebuild the initial ramdisk after making this change.

On Debian: update-initramfs -u
On Void Linux: xbps-reconfigure -f linux
Arch Linux + CentOS etc. use dracut: dracut --regenerate-all

Now reboot.

Now your USB devices should retain the same ID across reboots, and can be reliably used in mpd.conf




Tags: Audio , Linux

Return to home page: Home