问题

问题

问题

我的新麦克风的 Pulse Audio 配置有问题。ALSA 可以完美处理该设备,而默认的 PulseAudio 模块没有声音。

测试

通过以下测试,我想说明我怀疑默认配置的问题所在。请注意底部的设置详细信息。

  1. 为 AlSA 和 Pulse Audio 定义相应的设备和源名称。
DEV_ALSA_DEF=hw:2,1
DEV_PULS_DEF=alsa_input.usb-Generic_USB_Audio-00.iec958-stereo
  1. 取消卡和源的所有通道的静音并提高其音量。
amixer -c2 set Mic,0 0
amixer -c2 set Mic,0 100%
amixer -c2 set Mic,1 0
amixer -c2 set Mic,1 100%
pacmd set-source-mute   $DEV_PULS_DEF 0
pacmd set-source-volume $DEV_PULS_DEF 65536
  1. 使用 ALSA 和 Pulse Audio 推荐的 API 录制传入的声音。
arecord -f dat -r 48000 -D $DEV_ALSA_DEF -d 10 out_alsa_def.wav
timeout 10 pacat -r --channels=2 --file-format=wav --device $DEV_PULS_DEF out_puls_def.wav

分析

我在重新启动后和启动后测试了此代码pavucontrol,以确保脉冲音频服务正常运行。结果:out_alsa_def.wav是准确清晰的记录,同时又out_puls_def.wav是完全沉默/空洞/空白。我的第一个问题:为什么 Pulse Audio 无法连接到 ALSA 的通道?

解决方法

我能够使用从 ALSA 卡创建的新源找到解决方法。

测试

  1. $DEV_PULS_DEF通过“手动”加载与卡对应的脉冲音频源模块来创建“克隆” $DEV_ALSA_DEF
pacmd load-module module-alsa-source device=$DEV_ALSA_DEF
DEV_PULS_MAN=alsa_input.hw_2_1
  1. 取消音源静音并提高音量。
pacmd set-source-mute   $DEV_PULS_MAN 0
pacmd set-source-volume $DEV_PULS_MAN 65536
  1. 记录传入的声音。
timeout 10 pacat -r --channels=2 --file-format=wav --device $DEV_PULS_MAN out_puls_man.wav

分析

这次的输出文件out_puls_man.wav是完美的记录。我的结论是,“手动”加载的源获取 ALSA 的通道,而默认创建的源无法访问它。对我来说,这意味着自动脉冲音频配置中的某些内容发生了故障。我的第二个问题:为什么手动加载源码更成功?

但…

文档建议反对使用并建议尽可能module-alsa-source使用。module-udev-detect然而,$ pacmd load-module module-udev-detect并没有解决问题。第三个问题:如何仅使用推荐的工具正确修复此问题以及此解决方法可能会出现什么问题?

设置

麦克风

问题麦克风是通过 USB-C 连接的新型 HP E27d G4 内置网络摄像头的一部分。麦克风是立体声的,并使用数字立体声 (IEC958) 输入配置文件。视频传输开箱即用。

系统

$ inxi -SA
System:
  Host: rivendell Kernel: 6.1.80-1-MANJARO
    arch: x86_64 bits: 64
  Desktop: i3 v: 4.23
    Distro: Manjaro Linux
Audio:
  Device-1: Intel Cannon Lake PCH cAVS
    driver: snd_hda_intel
  Device-2: NVIDIA driver: snd_hda_intel
  Device-3: HP USB Audio
    driver: hid-generic,snd-usb-audio,usbhid
    type: USB
  API: ALSA v: k6.1.80-1-MANJARO
    status: kernel-api
  Server-1: PulseAudio v: 17.0
    status: active

音频配置

脚本执行后创建。

$ aplay -l
**** List of PLAYBACK Hardware Devices ****

  [some more output]

card 2: Audio [USB Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
$ amixer -c2
Simple mixer control 'PCM',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Mic',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 47
  Front Left: Capture 47 [100%] [0.00dB] [on]
  Front Right: Capture 47 [100%] [0.00dB] [on]
Simple mixer control 'Mic',1
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 47
  Front Left: Capture 47 [100%] [0.00dB] [on]
  Front Right: Capture 47 [100%] [0.00dB] [on]
$ pacmd list-sources
5 source(s) available.

[some more output]

    index: 1
    name: <alsa_input.usb-Generic_USB_Audio-00.iec958-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9047
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max rewind: 0 KiB
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
    card: 1 <alsa_card.usb-Generic_USB_Audio-00>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "USB Audio"
        alsa.id = "USB Audio"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "2"
        alsa.card_name = "USB Audio"
        alsa.long_card_name = "Generic USB Audio at usb-0000:00:14.0-4.4, high speed"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:00:14.0-usb-0:4.4:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4/1-4.4:1.0/sound/card2"
        udev.id = "usb-Generic_USB_Audio-00"
        device.bus = "usb"
        device.vendor.id = "03f0"
        device.vendor.name = "HP, Inc"
        device.product.id = "086d"
        device.product.name = "USB Audio"
        device.serial = "Generic_USB_Audio"
        device.string = "iec958:2"
        device.buffering.buffer_size = "384000"
        device.buffering.fragment_size = "192000"
        device.access_mode = "mmap+timer"
        device.profile.name = "iec958-stereo"
        device.profile.description = "Digital Stereo (IEC958)"
        device.description = "USB Audio Digital Stereo (IEC958)"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-usb"
    ports:
        iec958-stereo-input: Digital Input (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
            properties:
                
    active port: <iec958-stereo-input>

[some more output]

  index: 4
    name: <alsa_input.hw_2_1>
    driver: <module-alsa-source.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9040
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max rewind: 0 KiB
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
    module: 25
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "USB Audio #1"
        alsa.id = "USB Audio"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "1"
        alsa.card = "2"
        alsa.card_name = "USB Audio"
        alsa.long_card_name = "Generic USB Audio at usb-0000:00:14.0-4.4, high speed"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:00:14.0-usb-0:4.4:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4/1-4.4:1.0/sound/card2"
        udev.id = "usb-Generic_USB_Audio-00"
        device.bus = "usb"
        device.vendor.id = "03f0"
        device.vendor.name = "HP, Inc"
        device.product.id = "086d"
        device.product.name = "USB Audio"
        device.serial = "Generic_USB_Audio"
        device.string = "hw:2,1"
        device.buffering.buffer_size = "384000"
        device.buffering.fragment_size = "192000"
        device.access_mode = "mmap+timer"
        device.description = "USB Audio"
        device.icon_name = "audio-input-microphone-usb"
$ pactl list cards
 [some more output]

Card #1
    Name: alsa_card.usb-Generic_USB_Audio-00
    Driver: module-alsa-card.c
    Owner Module: 7
    Properties:
        alsa.card = "2"
        alsa.card_name = "USB Audio"
        alsa.long_card_name = "Generic USB Audio at usb-0000:00:14.0-4.4, high speed"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:00:14.0-usb-0:4.4:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4/1-4.4:1.0/sound/card2"
        udev.id = "usb-Generic_USB_Audio-00"
        device.bus = "usb"
        device.vendor.id = "03f0"
        device.vendor.name = "HP, Inc"
        device.product.id = "086d"
        device.product.name = "USB Audio"
        device.serial = "Generic_USB_Audio"
        device.string = "2"
        device.description = "USB Audio"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-usb"
    Profiles:
        input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 65, available: no)
        input:iec958-stereo: Digital Stereo (IEC958) Input (sinks: 0, sources: 1, priority: 32823, available: yes)
        output:analog-stereo: Analog Stereo Output (sinks: 1, sources: 0, priority: 39268, available: yes)
        output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (sinks: 1, sources: 1, priority: 6565, available: yes)
        output:analog-stereo+input:iec958-stereo: Analog Stereo Output + Digital Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 39323, available: yes)
        output:iec958-stereo: Digital Stereo (IEC958) Output (sinks: 1, sources: 0, priority: 38268, available: yes)
        output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 5565, available: yes)
        output:iec958-stereo+input:iec958-stereo: Digital Stereo Duplex (IEC958) (sinks: 1, sources: 1, priority: 38323, available: yes)
        output:iec958-ac3-surround-51: Digital Surround 5.1 (IEC958/AC3) Output (sinks: 1, sources: 0, priority: 300, available: yes)
        output:iec958-ac3-surround-51+input:analog-stereo: Digital Surround 5.1 (IEC958/AC3) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 365, available: no)
        output:iec958-ac3-surround-51+input:iec958-stereo: Digital Surround 5.1 (IEC958/AC3) Output + Digital Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 33123, available: yes)
        off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    Active Profile: input:iec958-stereo
    Ports:
        analog-input-mic: Microphone (type: Mic, priority: 8700, latency offset: 0 usec, not available)
            Properties:
                device.icon_name = "audio-input-microphone"
            Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:iec958-stereo+input:analog-stereo, output:iec958-ac3-surround-51+input:analog-stereo
        iec958-stereo-input: Digital Input (S/PDIF) (type: SPDIF, priority: 0, latency offset: 0 usec, availability unknown)
            Part of profile(s): input:iec958-stereo, output:analog-stereo+input:iec958-stereo, output:iec958-stereo+input:iec958-stereo, output:iec958-ac3-surround-51+input:iec958-stereo
        analog-output-headphones: Headphones (type: Headphones, priority: 9900, latency offset: 0 usec, available)
            Properties:
                device.icon_name = "audio-headphones"
            Part of profile(s): output:analog-stereo, output:analog-stereo+input:analog-stereo, output:analog-stereo+input:iec958-stereo
        iec958-stereo-output: Digital Output (S/PDIF) (type: SPDIF, priority: 0, latency offset: 0 usec, availability unknown)
            Part of profile(s): output:iec958-stereo, output:iec958-stereo+input:analog-stereo, output:iec958-stereo+input:iec958-stereo

 [some more output]

失败的方法

  1. $ pacmd load-module module-udev-detect
  2. $ systemctl --user restart pulseaudio.service$ systemctl --user restart pulseaudio.socket
  3. $ pacmd load-module module-remap-source master=$DEV_PULS_DEF
  4. $ ffmpeg -f pulse -i $DEV_PULS_DEF output.wav
  5. $ pamac reinstall pulseaudiopamac build pulseaudio
  6. pavucontrol(无可见振幅)

相关内容