Description
Describe the bug
Audio playback is intermittently interrupted by stuttering and crackling noises when a data stream is transferred through a pipe using standard Linux utilities. The issue is especially noticeable when performing data-heavy operations such as piping /dev/zero
through pv
to /dev/null
, and appears to be related to resource contention or scheduling.
Additional Information:
- The issue was first noticed during debugging of a custom application that processes data from a pipe.
- It was later confirmed to occur using only standard tools (cat, pv, mpg123).
- The CPU load remains relatively low when the issue occurs (25-40%).
- Appears to be either a scheduler latency issue, audio buffer underrun, or an I/O-related bottleneck affecting audio playback.
Steps to reproduce the behaviour
- Open a terminal and start audio playback (e.g., internet radio):
mpg123 -f 6554 https://strm112.1.fm/onelive_mobile_mp3
- In another terminal, run:
cat /dev/zero | pv -r > /dev/null
- Optionally, open Chromium and navigate to a simple web page, for example https://www.google.com to increase likelihood of issue manifesting. You can also try moving the mouse cursor over the browser page, which appears to increase the likelihood of the audio glitch occurring.
Expected Behavior:
Audio should continue playing smoothly without interruptions, regardless of background data transfers or other light system activity.
Actual Behavior:
- Audio crackles intermittently or stutters heavily.
- In some cases, the audio becomes distorted and jittery immediately; in others, only mild crackling is noticed after several seconds.
- Severity varies based on system state and seems to be influenced by non-deterministic factors.
Note: The issue does not always manifest immediately and may require restarting the cat /dev/zero | pv -r > /dev/null
command multiple times under different conditions. I have not identified a clear pattern or trigger, but once the audio disruption begins, it tends to persist consistently until the command cat /dev/zero | pv -r > /dev/null
is restarted. Interestingly, restarting the same command - under seemingly identical system conditions (no change in background processes or overall system load), can result in normal, uninterrupted audio playback.
I also observed that when the audio stuttering and crackling occurs, the cat /dev/zero | pv -r > /dev/null
command reports significantly reduced throughput. Under normal conditions, it shows a data rate of around 1.1 - 1.2 GiB/s, but during audio issues, the reported speed drops to 600-700 MiB/s with noticeable and very unstable fluctuations.
What’s particularly puzzling is that the issue may or may not occur under seemingly identical conditions. It appears to depend on some non-deterministic factors at the moment the command is executed.
Device (s)
Raspberry Pi 4 Mod. B
System
Raspberry Pi reference 2023-09-22
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 40f37458ae7cadea1aec913ae10b5e7008ebce0a, stage4
vcgencmd version
Apr 30 2025 13:33:39
Copyright (c) 2012 Broadcom
version 5560078dcc8591a00f57b9068d13e5544aeef3aa (clean) (release) (start)
uname -a
Linux zx80 6.12.25+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux
Logs
No relevant error messages appear in the dmesg log when the issue occurs.
Additional context
Similar audio interruptions and crackling can also be observed when opening moderately large schematic files in KiCad.