diff --git a/src/mpdclient.cpp b/src/mpdclient.cpp index bbb47ae..d4bbd99 100644 --- a/src/mpdclient.cpp +++ b/src/mpdclient.cpp @@ -27,14 +27,14 @@ void CMpdClient::Process() { if (!OpenSocket()) { - m_currentsong.clear(); + ClearCurrentSong(); continue; } } if (!GetCurrentSong()) { - m_currentsong.clear(); + ClearCurrentSong(); m_socket.Close(); } @@ -120,6 +120,16 @@ bool CMpdClient::GetCurrentSong() return false; } +void CMpdClient::ClearCurrentSong() +{ + CLock lock(m_condition); + if (!m_currentsong.empty()) + { + m_currentsong.clear(); + m_songchanged = true; + } +} + bool CMpdClient::CurrentSong(std::string& song) { CLock lock(m_condition); diff --git a/src/mpdclient.h b/src/mpdclient.h index 9481fb1..46062ee 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -20,6 +20,7 @@ class CMpdClient : public CThread private: bool OpenSocket(); bool GetCurrentSong(); + void ClearCurrentSong(); int m_port; std::string m_address;