我试图在运行时在同一个 ALSA 卡上的两个 ALSA 设备之间切换:
>>> [blake@e530 ~]$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CX20590 Analog [CX20590 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
设备 0 是我的笔记本电脑的板载声音,设备 3 是其 HDMI 输出。
安装 PulseAudio 服务器后(希望有更精细的运行时管理选项),只有设备 0 出现在我的pacmd list-sinks
:
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9959
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: 20.40 ms
max request: 3 KiB
max rewind: 344 KiB
monitor source: 0
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 20.00 ms; range is 0.50 .. 2000.00 ms
card: 0 <alsa_card.pci-0000_00_1b.0>
module: 6
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "CX20590 Analog"
alsa.id = "CX20590 Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
有没有办法使用 PulseAudio 或本机 ALSA 在运行时实现这种输出切换行为?
答案1
我的问题类似,我列出了多个设备,aplay -l
但 PulseAudio 只列出了我的扬声器pacmd list-sinks
;它错过了我的耳机。
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC898 Analog [ALC898 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC898 Digital [ALC898 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: A20 [Astro A20], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: A20 [Astro A20], device 1: USB Audio [USB Audio #1]
Subdevices: 0/1
Subdevice #0: subdevice #0
对于此输出,我运行以下命令将我的耳机添加到 PulseAudio。然后我使用 pasystray 选择耳机作为默认接收器,并打开一个音乐应用程序。之后一切工作正常。
pactl load-module module-alsa-sink device=hw:1,1
然后为了使这种情况在重新启动后持续存在,我添加到load-module module-alsa-sink device=hw:1,1
了/etc/pulse/default.pa
.
答案2
导致此问题的原因可能有多种,但就我而言,此问题是在从 Ubuntu 18.04 升级到 20.04 后开始出现的。问题是我需要将自己融入到pulse
团队中/etc/group
而不是pulse-access
。