Thank you for your donation!


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


Thread Closed 
Problem: [PROBLEM] 9.x: MPD crashing ad-hoc / stops playing
#61
Hi @the_bertrum , @Tim Curtis

So... I disabled the stream monitor in moOde and I'm running your script since a couple of hours. 

We're in the evening, so much more congestion on the internet. Your script kicks in on a regular basis, resulting very rare in a hick-up, but never stopping the steam.

This is... absolutely faboulus! @Tim Curtis is there a way to integrate this in moOde?

Tx,
Kurt

Code:
moode@moode:~ $ ls -l
total 20
-rwxr-xr-x 1 root  root  2063 Oct 18 13:53 mpdmon.php
-rwxr-xr-x 1 root  root   808 May  7 22:20 piano.sh
-rwxrwxrwx 1 moode moode   52 Oct 24 20:17 start-XRUN-script.sh
-rwxr--r-- 1 moode moode   43 Sep 17 19:50 temp.sh
-rwxrwxrwx 1 moode moode  453 Oct 24 20:14 XRUN_restart.sh
moode@moode:~ $ ./start-XRUN-script.sh
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Yotam Silberstein - Capricho de Espanha - 06:50
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Seven Years In High Resolution - SuperStereo Network - 00:04
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Jack Jezzro - Secretly - 04:05
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Dave Brubeck - Mr. Fats - 07:55
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Wolfgang Haffner - Remembrance - 04:56
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Art Tatum - My One And Only Love - 06:14
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Dizzy Gillespie - Frelimo - 08:14
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Seven Years In High Resolution - SuperStereo Network - 00:05
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Wes Montgomery - Bumpin' - 06:47
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: SuperStereo Network - Advertising Space (9) - 00:23
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
xrun matched
volume:100%   repeat: off   random: off   single: off   consume: off
SuperStereo 7  *Jazz*: Jimmy Smith, Wes Montgomery - Down By The Riverside - 10:03
[playing] #5/30   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
#62
If other users report problems with the built-in Stream monitor I can look into it again but until that happens your best bet is to just use the bash script since it appears to work for your particular stream issues.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
#63
@Tim Curtis , I'll do that, but I'm not the only one suffering from this as there's already a thread about this from someone else where this script is coming from: https://moodeaudio.org/forum/showthread....6#pid49406

@the_bertrum, I start the script in rc.local, right after the start of moOde. Works perfect! Tx! As this moment, I'm not at home. I'll let it playing and I'll see what it gives later today, playing the "difficult" Super Stereo HD channel. But the tests already done, sound promising. X fingers...
#64
I'm glad the script is working for you.  Really all it does differently to the monitor is to run "mpc stop" followed by "mpc start", rather than a full restart of the MPD process.  So, I'm experimenting now with this in my mpdmon.php:

Code:
//                                      $msg = 'mpdmon: MPD restarted';
//                                      sysCmd('systemctl restart mpd');
                                       $msg = 'mpdmon: MPD stopped';
                                       sysCmd('mpc stop');
                                       if ($resumePlay == 'Yes') {
                                               $msg .= ', play resumed';
                                               sysCmd('mpc play');
                                       }
I've simply replaced the restart with a stop.

I don't get xruns often these days, but I expect this will recover just as well.  I'll let you know.
----------------
Robert
#65
Hi @the_bertrum, @Tim Curtis

Coming home, and after +8h, the system is still playing my HD Super Stereo 7 channel. This never happened before! As expected, xruns happen very frequently, but due the script, the system nicely recovers. So, it looks like the script does a better recovery job than the stream monitor (switched off now).

I just made the change in /var/www/daemon/mpdmon.php you proposed above, switched on the stream monitor and disabled the script.
Let you know the outcome!
#66
Hi @the_bertrum ,

I just tested the proposed fix in mpdmon.php, but this doesnt work. Music stops playing due to xruns, and the mpd log keeps getting filled with xrun messages. Moodeutl says nothing and the monitor doesn't kick in. This is the same behavior as with the patch @Tim Curtis proposed. 
Although, not sure if - due to the preceding conditions in the code - your code gets actually hit? I doubt it. Tim may know.

So, for now, I went back to your script and switched off the stream monitor. This works.

It would be great to see this logic integrated in the stream monitor, as it requires manual work in case of a fresh install. Unfortunately I'm not a php, but Java, C++ guy.

@Tim Curtis can you please (re)consider, as this is not an isolated case, and it's improving moOde?

Code:
Oct 25 12:41 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:41 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
Oct 25 12:42 : alsa_output: Decoder is too slow; playing silence to avoid xrun
#67
(10-25-2024, 10:20 AM)kurt1970 Wrote: Hi @the_bertrum, @Tim Curtis

Coming home, and after +8h, the system is still playing my HD Super Stereo 7 channel. This never happened before! As expected, xruns happen very frequently, but due the script, the system nicely recovers. So, it looks like the script does a better recovery job than the stream monitor (switched off now).

I just made the change in /var/www/daemon/mpdmon.php you proposed above, switched on the stream monitor and disabled the script.
Let you know the outcome!

Just checking that you did add the station to those that are monitored as well as turning the monitor on?
----------------
Robert
#68
All my stations (40+, I don't use the default moOde stations) are marked as being monitored, as I used to have drop-outs on all of them from time to time. Fact that almost all of them are flac hd stations may have to do something with that.

But your script is great! I've a SSH terminal running a tail -f on the /var/log/mpd/log, and I see your script kicks in from time to time, mostly with no hearable interruption. Also, resource consumption of your script is negligible.

Actually, I woke up at 4h30. Now it's 19h06, and the music keeps playing! Never had that experience! Not on moOde, and for sure not on Naim gear! Tx!

I combined both of your scripts in 1:

Code:
moode@moode:~ $ cat XRUN_restart.sh
#!/bin/bash
#XRUN_restart.sh - look for and attempt to recover from under-runs and timeouts in MPD.

while sleep 1;
do
       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
done
#69
I forgot it did timeout as well, I used to get them on occasion too. I remember I needed a modification in the case where CamillaDSP was engaged also because the xrun caused other errors in the log from CamillaDSP that swamped the xrun message, I'll see if I can find the version with that in (just in case).
----------------
Robert
#70
I don't use CamillaDSP, but indeed, I see that in your script you explicitly check on timeout as well.
No, I'm only suffering from those xruns.


Forum Jump: