Posts: 9
Threads: 2
Joined: Nov 2023
Reputation:
1
(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
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.
Posts: 13,439
Threads: 305
Joined: Mar 2018
Reputation:
545
(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
Does the WebUI hang or crash when this happens?
Posts: 1,870
Threads: 43
Joined: Mar 2020
Reputation:
85
(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
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
Posts: 1,870
Threads: 43
Joined: Mar 2020
Reputation:
85
(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
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
Posts: 9
Threads: 2
Joined: Nov 2023
Reputation:
1
@ 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.
Posts: 13,439
Threads: 305
Joined: Mar 2018
Reputation:
545
(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.
Posts: 11
Threads: 2
Joined: Nov 2022
Reputation:
1
(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
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
Posts: 9
Threads: 2
Joined: Nov 2023
Reputation:
1
11-11-2023, 09:15 AM
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.
Posts: 1,870
Threads: 43
Joined: Mar 2020
Reputation:
85
(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
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 , I'll try it out at the weekend.
----------------
Robert
Posts: 9
Threads: 3
Joined: Oct 2022
Reputation:
0
Same here. Stops and cuts ramdomly
|