Unfortunately, I didn’t have too much time a month ago to play with bisecting, as I was getting issues with catppuccin flake, so I gave up, and stuck with 24.05 for a while.
Finally, I decided to go with 24.11 again, I updated flake.lock, switched to the new config, rebooted, and… there was no audio issue.
And… after few days it went back again. I found that these errors were appearing in journalctl --follow
output at the same time when I was hearing the audio crackling:
pipewire[2674]: pw.node: (alsa_output.usb-GeneralPlus_USB_Audio_Device-00.iec958-stereo-46) graph xrun not-triggered (0 suppressed)
pipewire[2674]: pw.node: (alsa_output.usb-GeneralPlus_USB_Audio_Device-00.iec958-stereo-46) xrun state:0x7fde55d9e008 pending:1/2 s:582961763255 a:582961786198 f:582961798311 waiting:22943 process:12113 status:triggered
pipewire[2674]: pw.node: (PulseAudio Volume Control-108) xrun state:0x7fde55d14008 pending:0/1 s:582967093084 a:582961771501 f:582961780818 waiting:18446744073704230033 process:9317 status:triggered
pipewire[2674]: pw.node: (alsa_input.usb-046d_HD_Pro_Webcam_C920-02.analog-stereo-45) graph xrun not-triggered (0 suppressed)
pipewire[2674]: pw.node: (alsa_input.usb-046d_HD_Pro_Webcam_C920-02.analog-stereo-45) xrun state:0x7fde5612c008 pending:1/2 s:582961966829 a:582961985655 f:582961986566 waiting:18826 process:911 status:triggered
pipewire[2674]: pw.node: (PulseAudio Volume Control-107) xrun state:0x7fde55d15008 pending:0/1 s:582967293953 a:582961975676 f:582961981447 waiting:18446744073704233339 process:5771 status:triggered
pipewire[2674]: pw.node: (alsa_input.pci-0000_0a_00.6.analog-stereo-71) graph xrun not-triggered (0 suppressed)
pipewire[2674]: pw.node: (alsa_input.pci-0000_0a_00.6.analog-stereo-71) xrun state:0x7fde55d99008 pending:1/2 s:582962635760 a:582962655147 f:582962656089 waiting:19387 process:942 status:triggered
I decided to debug it with Claude, and it said that PipeWire is failing to process audio data in time (buffer under-runs or over-runs). It could be related to the multiple devices connected (and it makes sense, as the crackling stared to appear again after connecting a web cam + reboot).
Claude suggested to update the quantum
parameters:
"default.clock.rate" = 48000;
"default.clock.quantum" = 1024;
"default.clock.min-quantum" = 1024;
"default.clock.max-quantum" = 8192;
Before updating the PipeWire’s parameters in my NixOS configuration, I decided to change them temporarily with these commands:
pw-metadata -n settings 0 clock.force-rate 48000
pw-metadata -n settings 0 clock.force-quantum 2048
I went with 2048
as I was still hearing rare crackling with 1024
(everything seems to be good with 2048
).
I haven’t update my NixOS config yet, but I assume this is going to fix my issue permanently:
services.pipewire = {
enable = true;
extraConfig.pipewire = {
"context.properties" = {
"default.clock.rate" = 48000;
"default.clock.quantum" = 2048;
"default.clock.min-quantum" = 2048;
"default.clock.max-quantum" = 8192;
};
};
};
From what I read, increasing quantum (which is a audio data chunk processed by computer) can impact audio latency, but I haven’t noticed anything though