11-07-2023, 04:13 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
I tried to create the service, how are your settings. I see this as status:
Code:
Last login: Tue Nov 7 17:05:14 2023 from 192.168.0.204
pi@moode:~ $ systemctl status looper.service
● looper.service - Loop xun script
Loaded: loaded (/lib/systemd/system/looper.service; enabled; vendor preset>
Active: inactive (dead) since Tue 2023-11-07 17:10:09 CET; 1min 15s ago
Main PID: 595 (code=exited, status=0/SUCCESS)
CPU: 32ms
Nov 07 17:10:09 moode systemd[1]: Started Loop xun script.
Nov 07 17:10:09 moode bash[599]: MPD error: Connection refused
Nov 07 17:10:09 moode systemd[1]: looper.service: Succeeded.