From 8234535ffb0789ec95a7bafd4582f0ae93fd286c Mon Sep 17 00:00:00 2001 From: Bob van Loosen Date: Sun, 23 Dec 2012 19:41:40 +0100 Subject: [PATCH] fixed: don't disconnect if mpd doesn't send artist or title info --- src/mpdclient.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mpdclient.cpp b/src/mpdclient.cpp index 03e816d..ccf7a49 100644 --- a/src/mpdclient.cpp +++ b/src/mpdclient.cpp @@ -93,19 +93,25 @@ bool CMpdClient::GetCurrentSong() if (datastream.fail()) break; + string tmpline = line; string word; - if (GetWord(line, word)) + if (GetWord(tmpline, word)) { if (word == "Artist:") - artist = line.substr(1); + artist = tmpline.substr(1); else if (word == "Title:") - title = line.substr(1); + title = tmpline.substr(1); } - if (!artist.empty() && !title.empty()) + if (line == "OK") { - string song = artist + " - " + title; - SetCurrentSong(song); + if (artist.empty()) + artist = "Unknown artist"; + + if (title.empty()) + title = "Unknown title"; + + SetCurrentSong(artist + " - " + title); return true; } }