几天前我设置了 Pi4,并能够让它将声音输出到第一个 HDMI 端口。自动更新后,由于 pulseaudio systemd 服务消失,它失去了此功能。
# systemctl status pulseaudio
Unit pulseaudio.service could not be found.
我对此没意见,因为 pulseaudio 似乎是解决简单问题的复杂解决方案。Alsa 更简单、更成熟,所以我运行了
apt remove pulseaudio
很好。遗憾的是,我似乎无法通过 HDMI 播放音频。
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
我想使用 hdmi0,它被列为 card1,所以我填充了 /etc/asound.conf,它之前不存在,
defaults.pcm.card 1
defaults.ctl.card 1
扬声器测试程序产生
speaker-test 1.2.6
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib pcm_direct.c:1206:(snd1_pcm_direct_initialize_slave) requested or auto-format is not available
ALSA lib pcm_dmix.c:1044:(snd_pcm_dmix_open) unable to initialize slave
Playback open error: -22,Invalid argument
运行speaker-test的用户属于audio组,所以如果root运行speaker-test也会产生同样的结果。
我相信 /boot/firmware/config.txt 包含正确的行。
hdmi_drive=2
hdmi_group=1
只是为了好玩,这里是“aplay -L”的输出
null
Discard all samples (playback) or generate zero samples (capture)
default
Default Audio Device
sysdefault
Default Audio Device
iec958
IEC958 (S/PDIF) Digital Audio Output
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Hardware device with all software conversions
default:CARD=Headphones
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
sysdefault:CARD=Headphones
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
dmix:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample mixing device
usbstream:CARD=Headphones
bcm2835 Headphones
USB Stream Output
hw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Hardware device with all software conversions
default:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
sysdefault:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
front:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Front output / input
iec958:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct sample mixing device
usbstream:CARD=vc4hdmi0
vc4-hdmi-0
USB Stream Output
hw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Hardware device with all software conversions
default:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
sysdefault:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
front:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Front output / input
iec958:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct sample mixing device
usbstream:CARD=vc4hdmi1
vc4-hdmi-1
USB Stream Output
你知道如何让这个 pi 将声音发送到 hdmi0 吗?
注意:raspi-config ->system options->audio 显示耳机是唯一的音频设备。没有 hdmi0 或 hdmi1 的选项。
答案1
发现问题了。Ubuntu 22.04.3 上当前随 Alsa v1.2.6 分发的文件 /usr/share/alsa/cards/vc4-hdmi.conf 不正确。
上述文件应包含以下内容:
#
# Configuration for the VC4-HDMI sound card using software IEC958
# subframe conversion
#
<confdir:pcm/hdmi.conf>
vc4-hdmi.pcm.hdmi.0 {
@args [ CARD AES0 AES1 AES2 AES3 ]
@args.CARD {
type string
}
@args.AES0 {
type integer
}
@args.AES1 {
type integer
}
@args.AES2 {
type integer
}
@args.AES3 {
type integer
}
type iec958
slave {
format IEC958_SUBFRAME_LE
pcm {
type hooks
slave.pcm {
type hw
card $CARD
device 0
}
hooks.0 {
type ctl_elems
hook_args [
{
name "IEC958 Playback Default"
interface PCM
optional true
lock true
preserve true
value [ $AES0 $AES1 $AES2 $AES3 ]
}
]
}
}
}
status [ $AES0 $AES1 $AES2 $AES3 ]
}
# default with plug
vc4-hdmi.pcm.default {
@args [ CARD ]
@args.CARD {
type string
}
type plug
slave.pcm {
type softvol
slave.pcm {
@func concat
strings [ "hdmi:" $CARD ]
}
control {
name "PCM Playback Volume"
card $CARD
}
}
}
这是在RPi 论坛。尽管发帖者说这个解决方案对他们不起作用,但对我来说却有效。