fix(mpd): Always update mpd data
Only updating when an mpd event occurred would cause issues when mpd was playing and the machine was put to sleep because the elapsed time was calculated by taking the time difference of the last update and now which would give you wrong numbers, if the machine was in standby in between. Since the update function on the module is only called once a second (or when an event happens), we can just update the data every time without a huge performance hit. Fixes #915
This commit is contained in:
parent
bb0f68aef0
commit
645a3142a1
3 changed files with 10 additions and 13 deletions
src/modules
|
@ -162,13 +162,10 @@ namespace modules {
|
|||
|
||||
int idle_flags = 0;
|
||||
if ((idle_flags = m_mpd->noidle()) != 0) {
|
||||
// Update status on every event
|
||||
m_status->update(idle_flags, m_mpd.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_status->match_state(mpdstate::PLAYING)) {
|
||||
m_status->update_timer();
|
||||
}
|
||||
} catch (const mpd_exception& err) {
|
||||
m_log.err("%s: %s", name(), err.what());
|
||||
m_mpd.reset();
|
||||
|
@ -203,6 +200,11 @@ namespace modules {
|
|||
}
|
||||
}
|
||||
|
||||
if (m_status->match_state(mpdstate::PLAYING)) {
|
||||
// Always update the status while playing
|
||||
m_status->update(-1, m_mpd.get());
|
||||
}
|
||||
|
||||
string artist;
|
||||
string album;
|
||||
string title;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue