I'm experiencing an issue that when ALSA gives an XRUN underrun, the pulseaudio virtual sinks for the output that i've set start changing. Description below:
I've created three virtual sinks using the following commands (from Virtual0 to Virtual2)
pacmd load-module module-null-sink sink_name=Virtual0
pacmd update-sink-proplist Virtual0 device.description=Virtual0
pacmd update-source-proplist Virtual0.monitor device.description=Virtual0
I'm then running some DSP commands which output into three aplay commands (aplay -v -r 48000 -f S16_LE). Then in pavucontrol I set each of those to a seperate virtual sink (Virtual0 - Virtual2), which I then use to pipe to another DSP program.
The problem is that whenever ALSA underruns due to high CPU usage, the source entry in pavucontrol will briefly dissappear, then come back a second or two later with the virtual sink changed to the last one that i've set in the pavucontrol GUI (usually Virtual2). So after a few underruns on each alsa instance all sources end up outputting to the Virtual2 sink.
I don't mind ALSA underruning every now and then (underruns only occur rarely when the CPU fully maxes out - this is a Raspberry Pi), but I just want the sources to restore to the same sink.
I think the problem is that each aplay source has the same name. So when one briefly disappears due to an underrun it goes to the last set sink for that name, which happens to be the last one set in the GUI.
Is there anything I can do to stop the source entry briefly dissappearing on an underrun? Or change the aplay source name to something unique?
Just a note: Interestingly, i've also tried outputting with mplayer, and this never glitches the source in pavucontrol, but unforuntately mplayer introduces an unacceptable latency on the audio (even with caching disabled), so it can't be used. aplay and play (from sox) both have the issue.