Thank you for your donation!


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


/var/local/www/currentsong.txt is empty sometimes
#1
When a song file is paused the currentsong.txt file may be empty while the state is being changed. Here is an example of printing it repeatedly while pausing the stereo test track



Code:
pi@moode:~ $ cat /var/local/www/currentsong.txt 
file=SDCARD/Stereo Test/LRMonoPhase4.flac
artist=Koz
album=Stereo Test
title=LR Channel And Phase
coverurl=/coverart.php/SDCARD%2FStereo%20Test%2FLRMonoPhase4.flac
track=1
date=1997
composer=
encoded=16/48 FLAC
bitrate=435 kbps
outrate=16 bit, 44.1 kHz, Stereo, 1.411 Mbps
volume=13
mute=0
state=play
pi@moode:~ $ cat /var/local/www/currentsong.txt 
pi@moode:~ $ cat /var/local/www/currentsong.txt 
pi@moode:~ $ cat /var/local/www/currentsong.txt 
file=SDCARD/Stereo Test/LRMonoPhase4.flac
artist=Koz
album=Stereo Test
title=LR Channel And Phase
coverurl=/coverart.php/SDCARD%2FStereo%20Test%2FLRMonoPhase4.flac
track=1
date=1997
composer=
encoded=16/48 FLAC
bitrate=131 kbps
outrate=0 bps
volume=13
mute=0
state=pause

The file is also sometimes empty for a short while after Moode startup is complete, but before anything is played, so it is difficult to interpret what an empy file means.

Adrian
Reply
#2
A program thats checking the file could see it as empty if it reads it between the time its opened/truncated and then written/closed. This time interval would be really short though, in the sub milliseconds range because there are just a few lines of code doing the file open/write/close. Have a look at function updExtMetaFile() in worker.php. Just assume its last state if you see it as empty.

The file being empty at startup is a bug. It's being created afresh without first checking to see if it already exists. I've added to the TODO list to fix for upcoming 7.3.0 release.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
Hi Tim

I was using up arrow to repeat the command, and the file was empty three times, so it was probably empty for around a second. Because the file is opened for writing before the data is collected, maybe some of the data collection/processing is taking longer than expected (maybe interupted by another process) and the file then has zero length for longer than expected (I am on a Pi Zero with not much CPU headroom).

Regarding the implementation, it might avoid access issues if the file was written to another name and then renamed to currentsong.txt afterwards. (The zero-length window could be reduced by opening the file for writing after the data is collected, but the rename should avoid the empty file altogether.)

Adrian.
Reply
#4
Good ideas. I'll run some tests.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: