pipewire / pw-play (pw-cat) cuts off end of audio output when it is the only/last audio played
Hello,
issue: pipewire / pw-play (pw-cat) cuts off end of audio output when it is the only/last audio played.
Versions tested:
pipewire
/ pw-cat
/ libpipewire
0.3.65
and 0.3.74
(wireplumber
0.4.13
and 0.4.14
)
Examples using speech-dispatcher sound icons:
-
percussion-10.wav
("tok") is a very short sound, only ~ 30ms -
percussion-12.wav
("tok"-"tik") is a little longer ~ 130ms
This does not play any sound on my systems (older Intel/AMD laptops and desktops):
pw-play /usr/share/sounds/*/percussion-10.wav
…unless another process is also outputting audio at the same time, then it works.
This only plays the first part of the sound ("tok" without "tik") on my systems:
pw-play /usr/share/sounds/*/percussion-12.wav
Note: if another process is also outputing audio at the same time, even if paused, then it works ok.
It appears it might be dropping the very last buffer? and if last buffer is larger than last sound…
pw-top # outputs for each command on i7 laptop Intel Series 8 chipset (snd_hda_intel):
S ID QUANT RATE WAIT BUSY W/Q B/Q ERR FORMAT NAME
pw-play /usr/share/sounds/sound-icons/percussion-10.wav # NO sound (def. latency=100ms)
R 50 2048 48000 61.1us 89.3us 0.00 0.00 8 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 80 1600 16000 27.8us 19.9us 0.00 0.00 8 S16LE 1 16000 + pw-play
pw-play --latency=20ms /usr/share/sounds/sound-icons/percussion-10.wav # OK sound
R 50 512 48000 83.6us 44.1us 0.01 0.00 8 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 77 320 16000 25.8us 25.4us 0.00 0.00 8 S16LE 1 16000 + pw-play
paplay /usr/share/sounds/sound-icons/percussion-10.wav # OK sound
R 50 2048 48000 192.9us 100.3us 0.00 0.00 8 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 80 8192 16000 40.5us 134.0us 0.00 0.00 8 S16LE 1 16000 + paplay
aplay /usr/share/sounds/sound-icons/percussion-10.wav # OK sound
R 50 2048 48000 167.5us 94.1us 0.00 0.00 8 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 85 2000 16000 27.2us 122.1us 0.00 0.00 8 S16LE 1 16000 + ALSA Playback
pw-play --latency=512ms /usr/share/sounds/sound-icons/percussion-10.wav # NO sound
R 50 2048 48000 72.6us 83.3us 0.00 0.00 8 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 82 8192 16000 26.5us 30.9us 0.00 0.00 8 S16LE 1 16000 + pw-play
Since clock.power-of-two-quantum = true
…
42ms = 2016/48000 rounds down to 1024/48000 = 21⅓ms
pw-play --latency=42ms /usr/share/sounds/sound-icons/percussion-10.wav # OK sound
R 50 1024 48000 87.1us 58.8us 0.00 0.00 1 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 61 672 16000 46.0us 25.5us 0.00 0.00 1 S16LE 1 16000 + pw-play
43ms = 2064/48000 rounds down to 2048/48000 = 42⅔ms
pw-play --latency=43ms /usr/share/sounds/sound-icons/percussion-10.wav # NO sound
R 50 2048 48000 68.1us 91.3us 0.00 0.00 1 S32LE 2 48000 alsa_output.pci-0000_00_1b.0.analog-stereo
R 61 688 16000 28.1us 23.6us 0.00 0.00 1 S16LE 1 16000 + pw-play
It appears to not be a specific problem with pw-cat, but a pipewire issue since mpv using pipewire also exhibits the same issue, but not with pulse:
mpv /usr/share/sounds/sound-icons/percussion-10.wav # OK sound, def. pipewire-buffer=20ms (rounds down 512/48000 = 10⅔ms)
mpv --pipewire-buffer=100 /usr/share/sounds/sound-icons/percussion-10.wav # NO sound, (rounds down 2048/48000 = 48000 = 42⅔ms)
mpv --ao=pulse --pulse-buffer=100 /usr/share/sounds/sound-icons/percussion-10.wav # OK sound
Thank you.