Thank you for your donation!


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


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

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

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.
Reply
#12
(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.

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

Does the WebUI hang or crash when this happens?
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#13
(11-07-2023, 04:26 PM)Tim Curtis Wrote:
(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.

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

Does the WebUI hang or crash when this happens?

Nope, everything carries on as if the stream is still playing, just no sound.  Which is what I'd expect given the message is "playing silence to avoid...".  A stop and start sorts it out.
----------------
Robert
Reply
#14
(11-07-2023, 04:13 PM)funnyf Wrote:
(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.

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

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.

My service looks like this:

Code:
cat /etc/systemd/system/looper.service
[Unit]
Description=Looper to run the XRUN detection
After=network-online.target

[Service]
Type=simple
ExecStart=/home/<your user here>/looper.sh

[Install]
WantedBy=multi-user.target


The service file is owned by root and is executable, while the looper script and XRUN script are both owned by the moOde user and are also executable.
----------------
Robert
Reply
#15
@the_bertrum Thanks, I think it's running now. At the startup I see a few times
Nov 07 19:13:03 moode looper.sh[1145]: MPD error: Connection refused
but that stops when it's completely started.

@Tim Curtis I will check the logs when I have the case that the web ui hangs, today it did not occur yet. But it should have it rather soon.
Reply
#16
(11-07-2023, 06:21 PM)funnyf Wrote: @the_bertrum  Thanks, I think it's running now. At the startup I see a few times
Nov 07 19:13:03 moode looper.sh[1145]: MPD error: Connection refused
but that stops when it's completely started.

@Tim Curtis  I will check the logs when I have the case that the web ui hangs, today it did not occur yet. But it should have it rather soon.

For me to spend time troubleshooting this I'll need to be able to reproduce the issue on my end because WebUI hanging or broken is extremely rare.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#17
(11-07-2023, 02:30 PM)funnyf Wrote: thank you, I've added the script and service.

Now I cannot wait for the music to stop to check the logs Smile

I had the same problem for other streams and posted solution I use here: https://moodeaudio.org/forum/showthread....6#pid49506

If you download zip attached you have all files needed and readme how to implement.
----
Cheers!

Marek.Marakesh

Internet HiFi Radio streams enthusiast:
- RPi 3B+ with HiFiBerry Digi2-Pro
- RPi 3B+ with HiFiBerry Amp2

Reply
#18
Thumbs Up 
Thanks for the feedback. I am using the script from @the_bertrum .
I do not have to restart mo0de or the stream anymore.
I appreciate the help.
Reply
#19
(11-11-2023, 01:28 AM)marek.marakesh Wrote:
(11-07-2023, 02:30 PM)funnyf Wrote: thank you, I've added the script and service.

Now I cannot wait for the music to stop to check the logs Smile

I had the same problem for other streams and posted solution I use here: https://moodeaudio.org/forum/showthread....6#pid49506

If you download zip attached you have all files needed and readme how to implement.

I think your solution might be more elegant than mine Smile, I'll try it out at the weekend.
----------------
Robert
Reply
#20
Same here. Stops and cuts ramdomly
Reply


Forum Jump: