Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: Stops playing
#8
(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.

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
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
while sleep 1; do /home/<your username here>/XRUN_restart.sh; done
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 time Smile
----------------
Robert
Reply


Messages In This Thread
Stops playing - by funnyf - 11-06-2023, 12:19 PM
RE: Stops playing - by Tim Curtis - 11-06-2023, 12:34 PM
RE: Stops playing - by funnyf - 11-06-2023, 12:39 PM
RE: Stops playing - by Tim Curtis - 11-06-2023, 06:16 PM
RE: Stops playing - by funnyf - 11-06-2023, 07:02 PM
RE: Stops playing - by the_bertrum - 11-07-2023, 08:08 AM
RE: Stops playing - by funnyf - 11-07-2023, 12:15 PM
RE: Stops playing - by the_bertrum - 11-07-2023, 01:25 PM
RE: Stops playing - by funnyf - 11-07-2023, 04:13 PM
RE: Stops playing - by the_bertrum - 11-07-2023, 05:00 PM
RE: Stops playing - by Tim Curtis - 11-07-2023, 04:26 PM
RE: Stops playing - by the_bertrum - 11-07-2023, 04:52 PM
RE: Stops playing - by funnyf - 11-07-2023, 02:30 PM
RE: Stops playing - by marek.marakesh - 11-11-2023, 01:28 AM
RE: Stops playing - by the_bertrum - 11-13-2023, 11:41 AM
RE: Stops playing - by the_bertrum - 11-07-2023, 03:58 PM
RE: Stops playing - by funnyf - 11-07-2023, 06:21 PM
RE: Stops playing - by Tim Curtis - 11-07-2023, 07:58 PM
RE: Stops playing - by funnyf - 11-11-2023, 09:15 AM
RE: Stops playing - by grandfunk69 - 11-15-2023, 01:15 PM
RE: Stops playing - by Tim Curtis - 11-15-2023, 01:17 PM
RE: Stops playing - by grandfunk69 - 11-16-2023, 12:33 PM
RE: Stops playing - by Tim Curtis - 11-16-2023, 02:22 PM
RE: Stops playing - by Tim Curtis - 11-15-2023, 09:10 PM
RE: Stops playing - by Nutul - 11-15-2023, 09:52 PM
RE: Stops playing - by Tim Curtis - 11-15-2023, 10:46 PM
RE: Stops playing - by Nutul - 11-15-2023, 11:11 PM
RE: Stops playing - by TheOldPresbyope - 11-15-2023, 11:11 PM
RE: Stops playing - by Tim Curtis - 11-15-2023, 11:18 PM
RE: Stops playing - by Tim Curtis - 11-16-2023, 05:47 PM

Forum Jump: