Micro-stuttering sound Fedora 37

When playing music using Spotify, I get some minor distortion every few minutes or so. It’s not obnoxious, lasts probably just a few milliseconds, but it’s noticeable.

Spotify always plays at 44.1 kHz, and my sound output only accepts 48kHz, so there has to be a sample rate conversion.

I haven’t noticed any issues playing from other applications, like Chrome and Firefox, (but it’s harder to notice in videos than music, so can’t be sure).

I’m using HDMI output through a TV, then optical SPDIF from the TV to an amplifier (I will try to get a dedicated sound card with SPDIF, but I don’t have any such output at the moment). It is a virtual machine on a host with a quite old server CPU, VGA passthrough. It’s had no issues on pulseaudio based distros and on a Windows VM.

I’ve tried the trick from here - Audio playback stuttering in Fedora 35 Spin LXDE - with quanta up to 16k. No difference.

pw-metadata -n settings 0 clock.min-quantum 1024  

You might try enabling low-latency during boot.
Fedora is considering making this a default in future.
[1][2]

$ man grubby
$ cat /etc/default/grub
$ sudo grubby --args="preempt=full" --update-kernel=ALL
$ cat /etc/default/grub
$ systemctl reboot

[1] Dynamic Preemption Support Sent In For The Linux 5.12 Kernel - Phoronix
[2] Issue #228: Enable full preemption - fedora-workstation - Pagure.io

Thanks for the answer. This didn’t solve my problem, but I will keep it.

I’ve installed a PCIe sound card (with passthrough to the VM), so I can use 44.1kHz directly to the DAC now. I also had to enable the sample rate in the pipewire config. It seems like a significant improvement, but there’s still some xruns, happening only about once every 5 mins.

$ cat .config/pipewire/pipewire.conf.d/samplerate.conf

context.properties {
        default.clock.quantum       = 1024
        default.clock.allowed-rates = [44100, 48000, 96000]

}

There ERR counter in pw-top increases on the app-side, in bursts of 1 to 4 units. I see that it’s negotiated a 8k QUANT for the music player, which is good - no latency requirement there.

S   ID  QUANT   RATE    WAIT    BUSY   W/Q   B/Q  ERR FORMAT           NAME
S   28      0      0    ---     ---   ---   ---     0                  Dummy-Driver
S   29      0      0    ---     ---   ---   ---     0                  Freewheel-Driver
S   40      0      0    ---     ---   ---   ---     0                  Midi-Bridge
S   45      0      0    ---     ---   ---   ---     0                  alsa_output.pci-0000_00_09.0.hdmi-stereo
R   46   1024  44100 333.5us  24.6us  0.01  0.00    0    S32LE 2 44100 alsa_output.pci-0000_00_0a.0.iec958-stereo
R   59   8192  44100 154.4us  43.0us  0.01  0.00    4    F32LE 2 44100  + spotify
S   47      0      0    ---     ---   ---   ---     0                  alsa_input.pci-0000_00_0a.0.analog-stereo