ALSA - Using slots with multiple snd_usb_audio drivers

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
Ulrich
Established Member
Posts: 13
Joined: Thu Jan 25, 2018 4:21 pm

ALSA - Using slots with multiple snd_usb_audio drivers

Post by Ulrich »

Hi,

Everything works fine on my system, but I find it annoying to make sure I'm booting up with my sound card on because ALSA will re-allocate the 0 index to my MIDI keyboard...

I'm using this alsa.conf for the loading order :

Code: Select all

options snd cards_limit=7

alias snd-card-0 snd-usb-audio
alias snd-card-1 snd-aloop
alias snd-card-2 snd-usb-audio
alias snd-card-3 snd-usb-audio
alias snd-card-4 snd-usb-audio
alias snd-card-5 snd-usb-audio
alias snd-card-6 snd-usb-audio

options snd-usb-audio index=0 vid=0x07fd pid=0x0005
options snd-aloop index=1 pcm_substreams=2
options snd-usb-audio index=2,3,4,5,6 vid=0x046d,0x0944,0x1c75,0x2321,0x2321 pid=0x0821,0x0115,0x0287,0x0008,0x0008
Not the most beautifully written ALSA file but hey... How can I re-arrange that to take advantage of the slot option and be able to hot plug ?

j_e_f_f_g
Established Member
Posts: 1090
Joined: Fri Aug 10, 2012 10:48 pm

Re: ALSA - Using slots with multiple snd_usb_audio drivers

Post by j_e_f_f_g »

Write a udev rule.

It should target the usb subsystem, and match the Vendor and Product IDs of your interface. The "action" should run some app that calls alsa apis to make the desired assignment.

This is a complicated topic. Too complicated to explain here,

Ulrich
Established Member
Posts: 13
Joined: Thu Jan 25, 2018 4:21 pm

Re: ALSA - Using slots with multiple snd_usb_audio drivers

Post by Ulrich »

The "action" should run some app that calls alsa apis to make the desired assignment.
This is where I don't know what to do. I understood I had to use a udev rule to detect the hot pug, but after that...

Musinux
Established Member
Posts: 39
Joined: Sun Jan 14, 2018 8:38 pm

Re: ALSA - Using slots with multiple snd_usb_audio drivers

Post by Musinux »

Ulrich wrote: This is where I don't know what to do. I understood I had to use a udev rule to detect the hot pug, but after that...

See "Writing udev rules" here:
https://alsa.opensrc.org/Udev

Run

Code: Select all

ls -lha /dev/snd/by-path
# or
ls -lha /dev/snd/by-id

# then ask udevadm about that device
udevadm info -a -p `udevadm info -q path -n /dev/YourPathOrIdHere`
Make a list of your cards with corresponding ID/Path.

In the end, you want something like this:
cat /etc/udev/rules.d/85-my-usb-audio.rules

Code: Select all

SUBSYSTEM!="sound", GOTO="my_usb_audio_end"
ACTION!="add", GOTO="my_usb_audio_end"
DEVPATH=="/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card?", ATTR{id}="NVidia_here"
DEVPATH=="/devices/pci0000:00/0000:00:1c.0/0000:02:00.1/sound/card?", ATTR{id}="NVidia_there"
LABEL="my_usb_audio_end"
Using udev you can do naming through the attributes of the device (s/n, name, device path etc.).
My config is static since I'm naming the audio output of my 2 gfx cards. Don't know if this works when plugged in after bootup (and I won't try).
It should, since there's "ACTION!="add"", but you have'll to try yourself.

Edit: I'm an idiot. You probably already have all that...

Is this what you need ?:

Use the device name = ATTR{id}="Nvidia_here" in commands/jack or as default device in your .asoundrc.

Code: Select all

speaker-test -c 2 -D hw:NVidia_here

Post Reply