summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2013-04-10 16:17:10 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2013-04-10 16:17:10 +0200
commit54a1822db2bfa77f24d48c6456fc24aa0af215a7 (patch)
tree5365d3666fa30f55d2eac18a6f6cef2d03092dfa
parent425836630e2791ce612db290a8a68d4ec6b01c63 (diff)
fix problem with status update (#3740)
-rw-r--r--src/playlist.cpp8
-rw-r--r--src/playlist.h4
-rw-r--r--src/status.cpp10
3 files changed, 10 insertions, 12 deletions
diff --git a/src/playlist.cpp b/src/playlist.cpp
index 1f758f2e..3abbf9e1 100644
--- a/src/playlist.cpp
+++ b/src/playlist.cpp
@@ -43,7 +43,6 @@ Playlist *myPlaylist;
bool Playlist::ReloadTotalLength = 0;
bool Playlist::ReloadRemaining = false;
-unsigned Playlist::Version = 0;
namespace {//
@@ -52,7 +51,8 @@ bool playlistEntryMatcher(const boost::regex &rx, const MPD::Song &s);
}
-Playlist::Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0)
+Playlist::Playlist()
+: itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0), m_old_playlist_version(0)
{
w = NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::Border::None);
w.cyclicScrolling(Config.use_cyclic_scrolling);
@@ -335,9 +335,9 @@ void Playlist::setStatus(MPD::Status status)
m_status = status;
}
-unsigned int Playlist::version() const
+unsigned Playlist::oldVersion() const
{
- return m_status.empty() ? 0 : m_status.playlistVersion();
+ return m_old_playlist_version;
}
int Playlist::currentSongPosition() const
diff --git a/src/playlist.h b/src/playlist.h
index 55c7a2c5..0563bef2 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -79,7 +79,7 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable,
void SetSelectedItemsPriority(int prio);
void setStatus(MPD::Status status);
- unsigned version() const;
+ unsigned oldVersion() const;
int currentSongPosition() const;
unsigned currentSongLength() const;
@@ -87,7 +87,6 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable,
void registerHash(size_t hash);
void unregisterHash(size_t hash);
- static unsigned Version;
static bool ReloadTotalLength;
static bool ReloadRemaining;
@@ -107,6 +106,7 @@ private:
time_t itsTimer;
MPD::Status m_status;
+ unsigned m_old_playlist_version;
};
extern Playlist *myPlaylist;
diff --git a/src/status.cpp b/src/status.cpp
index 7df6d8c1..0d02b1fc 100644
--- a/src/status.cpp
+++ b/src/status.cpp
@@ -167,6 +167,9 @@ void Status::update(int event)
{
MPD::Status old_status = m_status;
m_status = Mpd.getStatus();
+ m_player_state = m_status.playerState();
+ m_volume = m_status.volume();
+ myPlaylist->setStatus(m_status);
if (event & MPD_IDLE_DATABASE)
Changes::database();
@@ -269,7 +272,7 @@ void Status::Changes::playlist()
myPlaylist->main().resizeList(playlist_length);
}
- Mpd.GetPlaylistChanges(myPlaylist->version(), [](MPD::Song &&s) {
+ Mpd.GetPlaylistChanges(myPlaylist->oldVersion(), [](MPD::Song &&s) {
size_t pos = s.getPosition();
if (pos < myPlaylist->main().size())
{
@@ -282,8 +285,6 @@ void Status::Changes::playlist()
myPlaylist->main().addItem(s);
myPlaylist->registerHash(s.getHash());
});
-
- myPlaylist->setStatus(m_status);
});
if (State::player() != MPD::psStop)
@@ -330,8 +331,6 @@ void Status::Changes::database()
void Status::Changes::playerState()
{
- m_player_state = m_status.playerState();
-
switch (State::player())
{
case MPD::psPlay:
@@ -622,7 +621,6 @@ void Status::Changes::flags()
void Status::Changes::mixer()
{
- m_volume = m_status.volume();
if (!Config.display_volume_level || (!Config.header_visibility && !Config.new_design))
return;