虚拟机中声音断断续续通常是由驱动抖动引起的。在虚拟机中,这是最常见的,因为设备是模拟的。

解决方法:需要对WirePlumber进行如下配置

mkdir -p ~/.config/wireplumber/wireplumber.conf.d/
cd ~/.config/wireplumber/wireplumber.conf.d

然后在~/.config/wireplumber/wireplumber.conf.d/50-alsa-config.conf文件中写:
monitor.alsa.rules = [
{
matches = [
# This matches the value of the 'node.name' property of the node.
{
node.name = "~alsa_output.*"
}
]
actions = {
# Apply all the desired node specific settings here.
update-props = {
api.alsa.period-size = 1024
api.alsa.headroom = 8192
}
}
}
]

最后执行
systemctl --user restart wireplumber pipewire pipewire-pulse