假设我有一张具有以下属性的卡:
index: 1
name: <alsa_card.pci-0000_00_1f.3>
driver: <module-alsa-card.c>
owner module: 7
properties:
alsa.card = "0"
alsa.card_name = "HDA Intel PCH"
alsa.long_card_name = "HDA Intel PCH at 0xf7240000 irq 129"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:1f.3"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "a170"
device.form_factor = "internal"
device.string = "0"
device.description = "Built-in Audio"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
profiles:
input:analog-stereo: Analog Stereo Input (priority 60, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060, available: unknown)
output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5400, available: unknown)
output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output + Analog Stereo Input (priority 5460, available: unknown)
output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 300, available: unknown)
output:hdmi-surround+input:analog-stereo: Digital Surround 5.1 (HDMI) Output + Analog Stereo Input (priority 360, available: unknown)
output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 300, available: unknown)
output:hdmi-surround71+input:analog-stereo: Digital Surround 7.1 (HDMI) Output + Analog Stereo Input (priority 360, available: unknown)
output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5200, available: unknown)
output:hdmi-stereo-extra1+input:analog-stereo: Digital Stereo (HDMI 2) Output + Analog Stereo Input (priority 5260, available: unknown)
output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5200, available: unknown)
output:hdmi-stereo-extra2+input:analog-stereo: Digital Stereo (HDMI 3) Output + Analog Stereo Input (priority 5260, available: unknown)
output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 100, available: unknown)
output:hdmi-surround-extra2+input:analog-stereo: Digital Surround 5.1 (HDMI 3) Output + Analog Stereo Input (priority 160, available: unknown)
output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 100, available: unknown)
output:hdmi-surround71-extra2+input:analog-stereo: Digital Surround 7.1 (HDMI 3) Output + Analog Stereo Input (priority 160, available: unknown)
off: Off (priority 0, available: unknown)
active profile: <output:hdmi-stereo-extra1+input:analog-stereo>
sinks:
alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1/#1: Built-in Audio Digital Stereo (HDMI 2)
sources:
alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1.monitor/#1: Monitor of Built-in Audio Digital Stereo (HDMI 2)
alsa_input.pci-0000_00_1f.3.analog-stereo/#2: Built-in Audio Analog Stereo
ports:
analog-input-headphone-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
analog-input-headset-mic: Headset Microphone (priority 8700, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: no)
properties:
analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-speakers"
analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: yes)
properties:
device.icon_name = "audio-headphones"
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "Inspiron 7459"
hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
我想将独特的音频流输出到模拟输出线路输出以及可能的所有 (hdmi-output-0、hdmi-output-1、hdmi-output2): 端口。有没有办法在 PulseAudio 中同时做到这一点?我知道在 ALSA 我可以做类似的事情:
gst-launch-1.0 audiotestsrc ! alsasink device="hw:0,0" gst-launch-1.0 audiotestsrc ! alsasink device="hw:0,3"
但我在 Pulse 中看到的表明我必须为“卡”设置一个“配置文件”,并且所有配置文件似乎都绑定到一个输出端口。
有没有办法做到这一点,或者 Pulse 在这方面只是受到根本限制?
答案1
您必须编写一个自定义配置文件,将您需要的所有 HDMI 输出公开为单独的接收器。
看一下简介在 Pulseaudio 文档中的文件中/usr/share/pulseaudio/alsa-mixer/paths/
,尤其是。中的评论analog-output.conf.common
。
不幸的是,所有这些都没有得到充分的记录。
尝试让它发挥作用:
修改/usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf
并附加如下内容:
[Profile output:analog-stereo+output:hdmi-stereo+output:hdmi-stereo+output:hdmi-stereo]
description = Foobar
output-mappings = analog-stereo hdmi-stereo hdmi-stereo-extra1 hdmi-stereo-extra2
input-mappings =
然后以常规桌面用户身份重新启动pulse:
pulseaudio --kill; sleep 1; pulseaudio --start
将卡设置为使用新配置文件:
pacmd set-card-profile 0 output:analog-stereo+output:hdmi-stereo+output:hdmi-stereo+output:hdmi-stereo
现在pacmd list-sinks
显示新配置文件中标识的每个端口的不同接收器。
最后需要做的事情是弄清楚如何不破坏系统文件。如果可能的话,最好通过文件来完成此操作~/.config/pulse
。
编辑
这里是描述如何为 M-Audio USB 设备设置新的配置文件。我还挖掘了我所做的事情,这是一个细微的变化(我不喜欢修改现有文件,它们往往会被软件包升级覆盖):
/etc/udev/rules.d/91-pulseaudio.rules
我添加一个包含以下内容的新文件:
# Custom Profile for onboard Intel 8086:12c0
SUBSYSTEM!="sound", GOTO="xpulseaudio_end"
ACTION!="change", GOTO="xpulseaudio_end"
KERNEL!="card*", GOTO="xpulseaudio_end"
SUBSYSTEMS=="pci", ATTRS{vendor}=="0x8086", ATTRS{device}=="0x1c20", ENV{PULSE_PROFILE_SET}="my-personal.conf"
LABEL="xpulseaudio_end"
这主要是来自 的副本/lib/udev/rules.d/90-pulseaudio.rules
。
由于这是板载声卡,这些规则必须在启动时执行,因此它们应该位于initrd
您的内核使用的规则中。我编译了自己的内核,并make-kpkg
复制了这些规则,所以这对我来说不是问题。
然后添加一个新文件/usr/share/pulseaudio/alsa-mixer/profile-sets/my-personal.conf
,您可以在其中列出所需的配置(从其他配置文件复制和修改)。
答案2
我在 Fedora 32 上使用 GeForce RTX 2070,并连接了 HTC Vive。通常,当有人在玩 VR 时,其他人也在显示器上观看。我将游戏音频配置为同时传输到 Vive 和显示器。
首先,使用 查找所有音频设备aplay -L
,然后测试这些设备以查看哪些设备已连接。例如,speaker-test -D hdmi:CARD=NVidia,DEV=1 -c2
。然而,该命令在 Nvidia 驱动程序中遇到了一个奇怪的错误:
$ speaker-test -D hdmi:CARD=NVidia,DEV=1 -c2
speaker-test 1.2.3
Playback device is hdmi:CARD=NVidia,DEV=1
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 8544000
Period size range from 32 to 4272000
Using max buffer size 8544000
Periods = 4
Unable to set hw params for playback: Cannot allocate memory
Setting of hwparams failed: Cannot allocate memory
显式设置较低的缓冲区大小可以解决该错误:
$ speaker-test -D hdmi:CARD=NVidia,DEV=1 -c2 -b10000
speaker-test 1.2.3
Playback device is hdmi:CARD=NVidia,DEV=1
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 8544000
Period size range from 32 to 4272000
Requested buffer time 10000 us
Periods = 4
was set period_size = 96
was set buffer_size = 480
0 - Front Left
^C 1 - Front Right
Time per period = 0.438162
确定哪些输出对设备有效后,通过创建文件将它们显式添加到pulseaudio .config/pulse/default.pa
。设备描述可以设置为您想要的任何内容。这是我的文件:
load-module module-alsa-sink device=hdmi:CARD=NVidia,DEV=0 sink_properties="device.description='NVIDIA HDMI Vive'"
load-module module-alsa-sink device=hdmi:CARD=NVidia,DEV=1 sink_properties="device.description='NVIDIA HDMI monitor'"
.include /etc/pulse/default.pa
通过运行重新启动pulseaudio systemctl --user restart pulseaudio.service
,然后验证设备是否显示在pavucontrol
.最后使用 paprefs 启用同时输出到所有音频设备。