延迟不适用于 Linux 上的 PulseAudio

延迟不适用于 Linux 上的 PulseAudio

我有两个扬声器。第一个连接到 PCI 卡,第二个通过蓝牙连接。声音在 PCI 卡上播放得稍早一些,所以我想增加一些延迟。我下载了脉冲音频 GUI,我有这个:

在此输入图像描述

如您所见,我在“Audio Interne”(PCI 卡)上添加了 2 秒的偏移量。

我检查了命令pactl list cards,我有这个用于内部卡:

Card #1
        Name: alsa_card.pci-0000_00_1b.0
        Driver: module-alsa-card.c
        Owner Module: 8
        Properties:
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0xf7f10000 irq 27"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:1b.0"
                sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "1e20"
                device.product.name = "7 Series/C216 Chipset Family High Definition Audio Controller"
                device.form_factor = "internal"
                device.string = "0"
                device.description = "Audio interne"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        Profiles:
                input:analog-stereo: Entrée Stéréo analogique (sinks: 0, sources: 1, priority: 65, available: yes)
                output:analog-stereo: Sortie Stéréo analogique (sinks: 1, sources: 0, priority: 6500, available: yes)
                output:analog-stereo+input:analog-stereo: Duplex stéréo analogique (sinks: 1, sources: 1, priority: 6565, available: yes)
                output:analog-surround-21: Sortie Surround analogique 2.1 (sinks: 1, sources: 0, priority: 1300, available: yes)
                output:analog-surround-21+input:analog-stereo: Sortie Surround analogique 2.1 + Entrée Stéréo analogique (sinks: 1, sources: 1, priority: 1365, available: yes)
                output:analog-surround-40: Sortie Surround analogique 4.0 (sinks: 1, sources: 0, priority: 1200, available: yes)
                output:analog-surround-40+input:analog-stereo: Sortie Surround analogique 4.0 + Entrée Stéréo analogique (sinks: 1, sources: 1, priority: 1265, available: yes)
                output:analog-surround-41: Sortie Surround analogique 4.1 (sinks: 1, sources: 0, priority: 1300, available: yes)
                output:analog-surround-41+input:analog-stereo: Sortie Surround analogique 4.1 + Entrée Stéréo analogique (sinks: 1, sources: 1, priority: 1365, available: yes)
                output:analog-surround-50: Sortie Surround analogique 5.0 (sinks: 1, sources: 0, priority: 1200, available: yes)
                output:analog-surround-50+input:analog-stereo: Sortie Surround analogique 5.0 + Entrée Stéréo analogique (sinks: 1, sources: 1, priority: 1265, available: yes)
                output:analog-surround-51: Sortie Surround analogique 5.1 (sinks: 1, sources: 0, priority: 1300, available: yes)
                output:analog-surround-51+input:analog-stereo: Sortie Surround analogique 5.1 + Entrée Stéréo analogique (sinks: 1, sources: 1, priority: 1365, available: yes)
                output:iec958-stereo: Sortie Stéréo numérique (IEC958) (sinks: 1, sources: 0, priority: 5500, available: yes)
                output:iec958-stereo+input:analog-stereo: Sortie Stéréo numérique (IEC958) + Entrée Stéréo analogique (sinks: 1, sources: 1, priority: 5565, available: yes)
                off: Éteint (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: output:analog-stereo
        Ports:
                analog-input-front-mic: Microphone avant (priority: 8500, latency offset: 0 usec, available)
                        Properties:
                                device.icon_name = "audio-input-microphone"
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:analog-surround-21+input:analog-stereo, output:analog-surround-40+input:analog-stereo, output:analog-surround-41+input:analo
g-stereo, output:analog-surround-50+input:analog-stereo, output:analog-surround-51+input:analog-stereo, output:iec958-stereo+input:analog-stereo
                analog-input-rear-mic: Microphone arrière (priority: 8200, 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:analog-surround-21+input:analog-stereo, output:analog-surround-40+input:analog-stereo, output:analog-surround-41+input:analo
g-stereo, output:analog-surround-50+input:analog-stereo, output:analog-surround-51+input:analog-stereo, output:iec958-stereo+input:analog-stereo
                analog-input-linein: Entrée ligne (priority: 8100, latency offset: 0 usec, available)
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:analog-surround-21+input:analog-stereo, output:analog-surround-40+input:analog-stereo, output:analog-surround-41+input:analo
g-stereo, output:analog-surround-50+input:analog-stereo, output:analog-surround-51+input:analog-stereo, output:iec958-stereo+input:analog-stereo
                analog-output-lineout: Sortie ligne (priority: 9900, latency offset: 2000000 usec, available)
                        Part of profile(s): output:analog-stereo, output:analog-stereo+input:analog-stereo, output:analog-surround-21, output:analog-surround-21+input:analog-stereo, output:analog-surround-40, output:analog-surround-40+inp
ut:analog-stereo, output:analog-surround-41, output:analog-surround-41+input:analog-stereo, output:analog-surround-50, output:analog-surround-50+input:analog-stereo, output:analog-surround-51, output:analog-surround-51+input:analog-stereo
                analog-output-headphones: Casque audio (priority: 9000, latency offset: 2000000 usec, not available)
                        Properties:
                                device.icon_name = "audio-headphones"
                        Part of profile(s): output:analog-stereo, output:analog-stereo+input:analog-stereo
                iec958-stereo-output: Sortie numérique (S/PDIF) (priority: 0, latency offset: 0 usec)
                        Part of profile(s): output:iec958-stereo, output:iec958-stereo+input:analog-stereo

我尝试着这样做pactl play-sample bell.ogg alsa_output.pci-0000_00_1b.0.analog-stereo。它似乎总是瞬间的。我设置的延迟似乎没有改变任何东西,即使当我播放音乐时也是如此。

我能做些什么?

编辑

通过pactl list sinks,我看到了这一点:

Latency: 2039815 usec, configured 40000 usec 

所以看起来延迟设置正确,但当我播放声音时它似乎是瞬时的。我想应该有延迟。有什么我不明白的吗?

答案1

我猜你的屏幕截图中的延迟偏移只是 Pulsaudio 计算给定采样频率的缓冲大小的时间,并尝试使用 ALSA 安排此参数。更改延迟偏移量没有显示效果可能只是 ALSA 驱动程序不支持多种缓冲区大小。

要获得额外的缓冲区,您可以添加一个空接收器来使用模块循环包的 latency_msec像这样:

pactl load-module module-null-sink sink_name=delayed
pactl load-module module-loopback latency_msec=2000 source=delayed.monitor sink=alsa_output.pci-0000_00_1b.0.analog-stereo

然后您必须将零接收器与蓝牙音频结合起来。

在测试这个简单的设置时,我遇到了预期的巨大延迟模块组合接收器像这样:

paplay someaudio.ext --device delayed

答案2

您需要 Haut-parluer(扬声器)的延迟,而不是 Sortei ligne(线路输出或耳机插孔)的延迟。或者,只要蓝牙不是插入耳机插孔的设备,您就可以在两者上设置延迟,因为这会进一步增加延迟。

  • 声音是瞬时的,因为内置扬声器的延迟为 0。而耳机插孔的延迟为 2 秒。

答案3

这是一个更简单的单行形式解决方案与module-loopback不使用额外的模块或接收器:

pactl load-module module-loopback latency_msec=2000 source=bluez_sink.F8_DF_15_BB_6D_F5.a2dp_sink.monitor sink=alsa_output.pci-0000_00_1b.0.analog-stereo

源应该是蓝牙设备,接收器应该是您想要延迟的设备。然后只需在系统托盘中或您的机箱中的 中选择蓝牙设备pactl play-sample bell.ogg bluez_sink.F8_DF_15_BB_6D_F5.a2dp_sink.monitor,就可以开始了。唯一的缺点是音量按钮只能控制蓝牙设备,GUI 不能再只选择未组合的蓝牙设备。一切都是一步完成的module-loopback,不需要额外的module-combine-sinknor module-null-sink

相关内容