USB에서 ALSA 장치 목록으로의 고정 카드 매핑

USB에서 ALSA 장치 목록으로의 고정 카드 매핑

사용하려는 웹캠 장치가 USB를 통해 연결되어 있습니다 arecord. 장치 목록은 다음과 같습니다(카드 1~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

PulseAudio가 보는 장치를 나열하면 다음이 표시됩니다(목록의 일부에는 웹캠만 표시됨).

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

arecord --list-devices지금 저는 고정된 구성 파일에서 카드 번호를 읽는 쉘 스크립트를 작성하고 있는데 웹캠 중 하나가 분리될 때 카드 번호가 변경되는 것을 원하지 않습니다. 웹캠이 /devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.2웹캠의 첫 번째 USB 포트( ) 에 연결되어 있는지 확인하고 싶습니다.언제나카드 1에 매핑되고 두 번째 카드는 카드 2에 매핑되는 식입니다. 즉, 웹캠/USB 포트와 카드 번호 간의 매핑을 수정하고 싶습니다.

가능합니까?

답변1

카드 변경숫자동일한 USB ID를 가진 장치에서는 이 작업이 불가능합니다.

하지만 udev 규칙을 사용하여 카드를 변경할 수 있습니다.ID( TT_2위 등)과 함께 사용할 수도 있습니다 arecord. "두 개의 동일한 오디오 장치 인식"을 참조하세요.https://alsa.opensrc.org/Udev:

SUBSYSTEM!="sound", GOTO="my_usb_audio_end"
ACTION!="add", GOTO="my_usb_audio_end"

DEVPATH=="/devices/pci0000:00/0000:00:13.2/usb2/2-6/2-6.2/2-6.2:1.0/sound/card?", ATTR{id}="UA1A_A"
DEVPATH=="/devices/pci0000:00/0000:00:13.2/usb2/2-6/2-6.3/2-6.3:1.0/sound/card?", ATTR{id}="UA1A_B"

LABEL="my_usb_audio_end"
$ arecord -D default:UA1A_A something.wav

관련 정보