I have a few webcam devices connected over USB and I want to record the audio from them using arecord. The device list is below (Cards 1 through 4):
t:~$ arecord --list-devices
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC Analog [ALC Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: TT [CA TT], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: TT_1 [CA TT], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 3: TT_2 [CA TT], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 4: TT_3 [CA TT], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
When I list the devices that PulseAudio sees, I have the following (partial list only showing the Webcams):
t:~$pactl list
Module #0
Name: module-device-restore
....
Card #11
Name: alsa_card.usb-VS_Inc_CA_TT-02
Driver: module-alsa-card.c
Owner Module: 38
Properties:
alsa.card = "1"
alsa.card_name = "CA TT"
alsa.long_card_name = "VS Inc CA TT at usb-0000:00:14.0-3"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:14.0-usb-0:3:1.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.2/sound/card1"
udev.id = "usb-VS_Inc_CA_TT-02"
device.bus = "usb"
device.vendor.id = "1a1a"
device.vendor.name = "Technology Inc."
device.product.id = "2a2a"
device.product.name = "CA TT"
device.serial = "VS_Inc_CA_TT"
device.form_factor = "webcam"
device.string = "1"
device.description = "CA TT"
module-udev-detect.discovered = "1"
device.icon_name = "camera-web-usb"
Profiles:
input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 60, available: yes)
input:iec958-stereo: Digital Stereo (IEC958) Input (sinks: 0, sources: 1, priority: 55, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: input:analog-stereo
Ports:
analog-input: Analog Input (priority: 10000, latency offset: 0 usec)
Part of profile(s): input:analog-stereo
iec958-stereo-input: Digital Input (S/PDIF) (priority: 0, latency offset: 0 usec)
Part of profile(s): input:iec958-stereo
Card #12
Name: alsa_card.usb-VS_Inc_CA_TT-02.2
Driver: module-alsa-card.c
Owner Module: 39
Properties:
alsa.card = "2"
alsa.card_name = "CA TT"
alsa.long_card_name = "VS Inc CA TT at usb-0000:00:14.0-4"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:14.0-usb-0:4:1.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4:1.2/sound/card2"
udev.id = "usb-VS_Inc_CA_TT-02"
device.bus = "usb"
device.vendor.id = "1a1a"
device.vendor.name = "Technology Inc."
device.product.id = "2a2a"
device.product.name = "CA TT"
device.serial = "VS_Inc_CA_TT"
device.form_factor = "webcam"
device.string = "2"
device.description = "CA TT"
module-udev-detect.discovered = "1"
device.icon_name = "camera-web-usb"
Profiles:
input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 60, available: yes)
input:iec958-stereo: Digital Stereo (IEC958) Input (sinks: 0, sources: 1, priority: 55, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: input:analog-stereo
Ports:
analog-input: Analog Input (priority: 10000, latency offset: 0 usec)
Part of profile(s): input:analog-stereo
iec958-stereo-input: Digital Input (S/PDIF) (priority: 0, latency offset: 0 usec)
Part of profile(s): input:iec958-stereo
Card #13
Name: alsa_card.usb-VS_Inc_CA_TT-02.3
Driver: module-alsa-card.c
Owner Module: 40
Properties:
alsa.card = "3"
alsa.card_name = "CA TT"
alsa.long_card_name = "VS Inc CA TT at usb-0000:00:14.0-1"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:14.0-usb-0:1:1.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.2/sound/card3"
udev.id = "usb-VS_Inc_CA_TT-02"
device.bus = "usb"
device.vendor.id = "1a1a"
device.vendor.name = "Technology Inc."
device.product.id = "2a2a"
device.product.name = "CA TT"
device.serial = "VS_Inc_CA_TT"
device.form_factor = "webcam"
device.string = "3"
device.description = "CA TT"
module-udev-detect.discovered = "1"
device.icon_name = "camera-web-usb"
Profiles:
input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 60, available: yes)
input:iec958-stereo: Digital Stereo (IEC958) Input (sinks: 0, sources: 1, priority: 55, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: input:analog-stereo
Ports:
analog-input: Analog Input (priority: 10000, latency offset: 0 usec)
Part of profile(s): input:analog-stereo
iec958-stereo-input: Digital Input (S/PDIF) (priority: 0, latency offset: 0 usec)
Part of profile(s): input:iec958-stereo
Card #14
Name: alsa_card.usb-VS_Inc_CA_TT-02.4
Driver: module-alsa-card.c
Owner Module: 41
Properties:
alsa.card = "4"
alsa.card_name = "CA TT"
alsa.long_card_name = "VS Inc CA TT at usb-0000:00:14.0-2"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:14.0-usb-0:2:1.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.2/sound/card4"
udev.id = "usb-VS_Inc_CA_TT-02"
device.bus = "usb"
device.vendor.id = "1a1a"
device.vendor.name = "Technology Inc."
device.product.id = "2a2a"
device.product.name = "CA TT"
device.serial = "VS_Inc_CA_TT"
device.form_factor = "webcam"
device.string = "4"
device.description = "CA TT"
module-udev-detect.discovered = "1"
device.icon_name = "camera-web-usb"
Profiles:
input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 60, available: yes)
input:iec958-stereo: Digital Stereo (IEC958) Input (sinks: 0, sources: 1, priority: 55, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: input:analog-stereo
Ports:
analog-input: Analog Input (priority: 10000, latency offset: 0 usec)
Part of profile(s): input:analog-stereo
iec958-stereo-input: Digital Input (S/PDIF) (priority: 0, latency offset: 0 usec)
Part of profile(s): input:iec958-stereo
Now, I am writing a shell script that reads the card number from a fixed config file and I don't want the card numbers in the arecord --list-devices to change if one of the webcams is unplugged. I want to make sure that the webcam connected to first USB port (/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.2) is always mapped to card 1, the second one to card 2 and so on. In other words, I want the mapping between Webcams/USB-port to the card number is fixed.
Is this possible?