/var/local/www/currentsong.txt is empty sometimes - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: Feature requests (https://moodeaudio.org/forum/forumdisplay.php?fid=8) +--- Thread: /var/local/www/currentsong.txt is empty sometimes (/showthread.php?tid=3797) |
/var/local/www/currentsong.txt is empty sometimes - adrii - 05-11-2021 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 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 RE: /var/local/www/currentsong.txt is empty sometimes - Tim Curtis - 05-11-2021 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. RE: /var/local/www/currentsong.txt is empty sometimes - adrii - 05-11-2021 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. RE: /var/local/www/currentsong.txt is empty sometimes - Tim Curtis - 05-11-2021 Good ideas. I'll run some tests. |