11-07-2023, 04:26 PM
(11-07-2023, 01:25 PM)the_bertrum Wrote:(11-07-2023, 12:15 PM)funnyf Wrote: I can this error in the mpd log:
Nov 07 08:31 : alsa_output: Decoder is too slow; playing silence to avoid xrun
OK, that's exactly the condition I get from time to time. I have been unable to locate a cause myself, and you are the first person on the Forum to have the same issue that I'm aware of. I suspect in my case that my home network/ISP is to blame, in particular the "smart" router that I got from the ISP that "optimises" connections to ensure speed (or something). I suspect the optimising interrupts the stream enough to throw ASLA or MPD off kilter and restarting the stream sorts it out again.
Since it doesn't seem to be an issue with moOde (most other users don't see it), nor a problem with the stream (likewise no other users have bother) I have a rather inelegant fix of a script that checks the log and restarts the stream when it sees the error.
That's the script, and putting aside the lesson I was taught 30 years ago about avoiding infinite loops in code, I use this to fire it every second:Code:#!/bin/bash
#XRUN_restart.sh - look for and attempt to recover from under-runs and timeouts in MPD.
LASTLOG=$( tail -n 1 /var/log/mpd/log )
STATUS=$(mpc status)
if [[ $STATUS = *"playing"* && $LASTLOG = *"xrun"* ]];
then
echo "xrun matched"
mpc stop
mpc play
else
LASTLOG=$( tail -n 2 /var/log/mpd/log )
if [[ $STATUS != *"playing"* && $LASTLOG = *"timed out"* ]];
then
echo "timeout matched"
mpc play
fi
fi
I then create a service to start the looper script on boot and the restart script will usually recover within a second or so. Not perfect, but it saves having to press play all the timeCode:#!/bin/bash
while sleep 1; do /home/<your username here>/XRUN_restart.sh; done
Does the WebUI hang or crash when this happens?