From 267b0d17bfec307c19c35f0807b427eccce0969c Mon Sep 17 00:00:00 2001 From: Bob van Loosen Date: Thu, 21 Feb 2013 21:33:23 +0100 Subject: [PATCH] fixed: volume handling --- src/bitvis/bitvis.cpp | 2 +- src/bitvis/mpdclient.cpp | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/bitvis/bitvis.cpp b/src/bitvis/bitvis.cpp index 389c6a4..f340715 100644 --- a/src/bitvis/bitvis.cpp +++ b/src/bitvis/bitvis.cpp @@ -401,7 +401,7 @@ void CBitVis::SendData(int64_t time) nrlines = m_nrlines - m_fontdisplay; } - if (isplaying && GetTimeUs() - m_volumetime < 1000000 && m_displayvolume > 0) + if (isplaying && GetTimeUs() - m_volumetime < 1000000) { for (int y = 0; y < nrlines; y++) { diff --git a/src/bitvis/mpdclient.cpp b/src/bitvis/mpdclient.cpp index 0d951f8..3741135 100644 --- a/src/bitvis/mpdclient.cpp +++ b/src/bitvis/mpdclient.cpp @@ -154,7 +154,7 @@ bool CMpdClient::GetPlayStatus() data.Clear(); bool isplaying = false; - bool muted = false; + int volume = -1; while(1) { if (m_socket.Read(data) != SUCCESS) @@ -184,25 +184,15 @@ bool CMpdClient::GetPlayStatus() } else if (word == "volume:") { - int volume; - if (GetWord(tmpline, word) && StrToInt(word, volume)) - { - if (volume == 0) - volume = true; - - if (volume != m_volume) - { - CLock lock(m_condition); - m_volume = volume; - m_volumechanged = true; - } - } + int parsevolume; + if (GetWord(tmpline, word) && StrToInt(word, parsevolume)) + volume = parsevolume; } } if (line == "OK") { - if (muted) + if (volume == 0) isplaying = false; CLock lock(m_condition); @@ -210,6 +200,13 @@ bool CMpdClient::GetPlayStatus() m_playingchanged = true; m_isplaying = isplaying; + + if (volume != -1 && m_volume != volume) + { + m_volume = volume; + m_volumechanged = true; + } + return true; } }