From 9b0a3097f923b18e66748b8196810543f97cff93 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 16 Mar 2009 00:07:12 +0100 Subject: [PATCH] resend now playing notification after successful submit --- src/callback.cpp | 11 +++++------ src/song.cpp | 5 ++++- src/song.h | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/callback.cpp b/src/callback.cpp index 3c65451..bf18228 100644 --- a/src/callback.cpp +++ b/src/callback.cpp @@ -41,7 +41,6 @@ void ScrobbyStatusChanged(MPD::Connection *Mpd, MPD::StatusChanges changed, void { static MPD::State old_state = MPD::psUnknown; static MPD::State current_state = MPD::psUnknown; - static bool NowPlayingNotify = 0; if (changed.State) { @@ -71,14 +70,14 @@ void ScrobbyStatusChanged(MPD::Connection *Mpd, MPD::StatusChanges changed, void if (current_state == MPD::psPlay || current_state == MPD::psPause) { s.SetData(Mpd->CurrentSong()); - NowPlayingNotify = s.Data && !s.isStream(); + MPD::Song::NowPlayingNotify = s.Data && !s.isStream(); } } - if (!NowPlayingNotify || !s.Data) + if (!MPD::Song::NowPlayingNotify || !s.Data) return; - NowPlayingNotify = 0; + MPD::Song::NowPlayingNotify = 0; if (!s.Data->artist || !s.Data->title) { @@ -94,7 +93,7 @@ void ScrobbyStatusChanged(MPD::Connection *Mpd, MPD::StatusChanges changed, void if (!myHandshake.OK()) { myHandshake.Unlock(); - NowPlayingNotify = 1; + MPD::Song::NowPlayingNotify = 1; return; } @@ -174,7 +173,7 @@ void ScrobbyStatusChanged(MPD::Connection *Mpd, MPD::StatusChanges changed, void myHandshake.Clear(); myHandshake.Unlock(); Log(llVerbose, "Handshake reset"); - NowPlayingNotify = 1; + MPD::Song::NowPlayingNotify = 1; } } } diff --git a/src/song.cpp b/src/song.cpp index 8cdccb5..79a40c2 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -31,9 +31,11 @@ using std::string; extern Handshake myHandshake; +extern MPD::Song s; -std::deque MPD::Song::SubmitQueue; +bool MPD::Song::NowPlayingNotify = 0; +std::deque MPD::Song::SubmitQueue; std::queue MPD::Song::Queue; pthread_mutex_t MPD::Song::itsQueueMutex = PTHREAD_MUTEX_INITIALIZER; @@ -232,6 +234,7 @@ bool MPD::Song::SendQueue() SubmitQueue.clear(); std::ofstream f(Config.file_cache.c_str(), std::ios::trunc); f.close(); + NowPlayingNotify = s.Data && !s.isStream(); return true; } else diff --git a/src/song.h b/src/song.h index a20dd60..ffb5ab8 100644 --- a/src/song.h +++ b/src/song.h @@ -50,6 +50,8 @@ namespace MPD static bool SendQueue(); + static bool NowPlayingNotify; + static std::queue Queue; static std::deque SubmitQueue; -- 2.11.4.GIT