fixed: reset scroll offset when song changed

This commit is contained in:
Bob van Loosen 2012-12-19 23:29:41 +01:00
parent e91398d77b
commit 1c819b3b41
3 changed files with 19 additions and 5 deletions

View file

@ -334,7 +334,11 @@ void CBitVis::SendData(int64_t time)
//add an empty line //add an empty line
data.SetData(text, m_nrcolumns / 4, true); data.SetData(text, m_nrcolumns / 4, true);
SetText(text, m_mpdclient->CurrentSong().c_str()); string currentsong;
if (m_mpdclient->CurrentSong(currentsong))
m_scrolloffset = m_nrcolumns;
SetText(text, currentsong.c_str());
data.SetData(text, sizeof(text), true); data.SetData(text, sizeof(text), true);
uint8_t end[10]; uint8_t end[10];

View file

@ -105,7 +105,13 @@ bool CMpdClient::GetCurrentSong()
if (!artist.empty() && !title.empty()) if (!artist.empty() && !title.empty())
{ {
m_currentsong = artist + " - " + title; string song = artist + " - " + title;
CLock lock(m_condition);
if (song != m_currentsong)
{
m_currentsong = song;
m_songchanged = true;
}
return true; return true;
} }
} }
@ -114,9 +120,12 @@ bool CMpdClient::GetCurrentSong()
return false; return false;
} }
std::string CMpdClient::CurrentSong() bool CMpdClient::CurrentSong(std::string& song)
{ {
CLock lock(m_condition); CLock lock(m_condition);
return m_currentsong; song = m_currentsong;
bool songchanged = m_songchanged;
m_songchanged = false;
return songchanged;
} }

View file

@ -15,7 +15,7 @@ class CMpdClient : public CThread
~CMpdClient(); ~CMpdClient();
virtual void Process(); virtual void Process();
std::string CurrentSong(); bool CurrentSong(std::string& song);
private: private:
bool OpenSocket(); bool OpenSocket();
@ -26,6 +26,7 @@ class CMpdClient : public CThread
CTcpClientSocket m_socket; CTcpClientSocket m_socket;
CCondition m_condition; CCondition m_condition;
std::string m_currentsong; std::string m_currentsong;
bool m_songchanged;
}; };