Description
I am having unreliable audio on a system that has Pulseaudio 5.0 installed.
It seems that when Pulseaudio is installed, and an application has finished playing audio, Pulseaudio doesn't close the audio device straight away, but waits 5 seconds.
If another application shows up that wants to play audio within that time, it re-uses the same connection.
However it seems that does not work properly on the Pi.
If I do:
aplay /usr/share/sounds/alsa/Front_Center.wav ; sleep 4 ; aplay /usr/share/sounds/alsa/Front_Center.wav
The file plays correctly the first time, but the second time there is no sound, and the program never finishes executing.
It just prints "Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono", and sits there.
Problem doesn't happen when sleeping at least 5 seconds.
No idea how to debug this, and if the problem is in the ALSA module or in Pulseaudio.
But here is the output of bcm2835_snd with debugging enabled in case that is useful to anyone: https://paste.ee/r/soht7
Was able to reproduce the issue with both my own custom Linux distribution, and with Arch Linux (installed Pulse with: "pacman -Sy pulseaudio pulseaudio-alsa alsa-utils ; pulseaudio --start")
Doesn't seem to happen with very old versions of Pulse, like 2.0 which you get when you install it through Raspbian.