Thank you for your donation!


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


Solved: currentsong.txt is updated too often
#1
Hello all,
I have just found that on 8.3.8 the file 
Code:
/var/local/www/currentsong.txt

is updated also when the player is in pause or stop mode. Dunno when this change was introduced exactly, I was not checking the file in the prev version, but now I started working again on a personal project to drive some peripherals based on the status of moode and I realised that the file is updated every 3 seconds, roughly. I think it is related to the fact that the current bitrate has been added to that file, nice addition, but that should happen only while playing and the file should not be updated when the player is paused or stopped, that's quite useless and can wear out microSD faster.

I will try to take a look at the code and see if I can pass a patch here, but in the meantime I would like to hear from developers
Location: Malaga, Spain | RPi4 / HifiBerry DAC+ / Teac A-H300
Reply
#2
Here is the patch

in file /var/www/daemon/worker.php, line 1732

replace

PHP Code:
if ($current['title'] != $fileMeta['title'] || $current['album'] != $fileMeta['album'] || $_SESSION['volknob'] != $fileMeta['volume'] || $_SESSION['volmute'] != $fileMeta['mute'] || $current['state'] != $fileMeta['state'] || $fileMeta['outrate'] != $hwParamsFormat $hwParamsCalcrate) { 



with


PHP Code:
if ($current['title'] != $fileMeta['title'] || $current['album'] != $fileMeta['album'] || $_SESSION['volknob'] != $fileMeta['volume'] || $_SESSION['volmute'] != $fileMeta['mute'] || $current['state'] != $fileMeta['state'] || $fileMeta['outrate'] != $current['output'] . $hwParamsCalcrate || $fileMeta['bitrate'] != $current['bitrate']) { 

This way the comparison is exactly identical and we keep in account the bitrate too.

With this the currentsong.txt file is updated ONLY when there are changes and if the status is paused or stopped, there is no update
Location: Malaga, Spain | RPi4 / HifiBerry DAC+ / Teac A-H300
Reply
#3
I went a bit further and I created https://github.com/moode-player/moode/pull/655
Location: Malaga, Spain | RPi4 / HifiBerry DAC+ / Teac A-H300
Reply
#4
(02-19-2024, 11:50 AM)AkelGe Wrote: I went a bit further and I created https://github.com/moode-player/moode/pull/655

Nice :-) I'll look at it later this morning.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
(02-19-2024, 11:27 AM)AkelGe Wrote: Here is the patch

in file /var/www/daemon/worker.php, line 1732

replace

PHP Code:
if ($current['title'] != $fileMeta['title'] || $current['album'] != $fileMeta['album'] || $_SESSION['volknob'] != $fileMeta['volume'] || $_SESSION['volmute'] != $fileMeta['mute'] || $current['state'] != $fileMeta['state'] || $fileMeta['outrate'] != $hwParamsFormat $hwParamsCalcrate) { 



with


PHP Code:
if ($current['title'] != $fileMeta['title'] || $current['album'] != $fileMeta['album'] || $_SESSION['volknob'] != $fileMeta['volume'] || $_SESSION['volmute'] != $fileMeta['mute'] || $current['state'] != $fileMeta['state'] || $fileMeta['outrate'] != $current['output'] . $hwParamsCalcrate || $fileMeta['bitrate'] != $current['bitrate']) { 

This way the comparison is exactly identical and we keep in account the bitrate too.

With this the currentsong.txt file is updated ONLY when there are changes and if the status is paused or stopped, there is no update

Although it works (and I have no idea why, TTYTT) it looks to me not the best way (logically) to fix it.

I would check for $current['state'] being 'playing' (or whatever it is while moOde is actually playing (that is, neither PAUSED nor STOPPED).
It's weird, as there is already a check for the ['status'] having to be different for the update to take place, but maybe once stopped the other fields are not getting changed, so to speak, the $current data is set to empty strings, but for some reason the $fileMeta is not, resulting in the fields always being different at the end of the playing queue...
Just wandering in the wild here, not looking at the code; maybe will later today.
Reply
#6
Actually, looking at the code right now:

the $['outrate'] field is checked against being different from $hwParamsFormat . $hwParamsCalcrate, but then is being assigned ONLY $hwParamsCalcrate, hence it is always different; so just assign the same $hwParamsFormat . $hwParamsCalcrate to it few lines below.
Reply
#7
In looking that code section there appear to be a number of issues. I'll make a commit tomorrow.

@AkelGe and @Nutul, Let me know how it works.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#8
As I was bored I manually edited the suggested pull into new 8.3.8 install and started getting random lost mpd output device issues.

Using a RME usb dac.

I reverted back, no issues hence.
Reply
#9
(02-19-2024, 11:08 PM)Tim Curtis Wrote: In looking that code section there appear to be a number of issues. I'll make a commit tomorrow.

@AkelGe and @Nutul, Let me know how it works.

Here is the commit
https://github.com/moode-player/moode/co...82f06fe5b1

You might also want to look at the other two from today.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#10
(02-21-2024, 11:49 PM)Tim Curtis Wrote:
(02-19-2024, 11:08 PM)Tim Curtis Wrote: In looking that code section there appear to be a number of issues. I'll make a commit tomorrow.

@AkelGe and @Nutul, Let me know how it works.

Here is the commit
https://github.com/moode-player/moode/co...82f06fe5b1

You might also want to look at the other two from today.

I would really love to test it, do you have suggestions on a quick way to test it? I am on the official code, I am not working on a git clone.
Location: Malaga, Spain | RPi4 / HifiBerry DAC+ / Teac A-H300
Reply


Forum Jump: