tDistinguish between no song playing versus mpd error - spoon - dwm status util… | |
git clone git://src.adamsgaard.dk/spoon | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit a0dad9bb5687f35a14c415828a24d84f1ffc1fbe | |
parent 2fc1f4927f97a4a86c887d67b6e9124d26afee7d | |
Author: sin <[email protected]> | |
Date: Mon, 26 Sep 2016 16:48:33 +0100 | |
Distinguish between no song playing versus mpd error | |
We were hitting this when killing mpd. Because conn was non-NULL | |
we would never attempt to reconnect. | |
Diffstat: | |
M spoon.c | 7 ++++++- | |
1 file changed, 6 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/spoon.c b/spoon.c | |
t@@ -61,8 +61,13 @@ mpdread(char *buf, size_t len) | |
mpd_send_current_song(conn); | |
song = mpd_recv_song(conn); | |
/* if no song is playing, reuse connection next time */ | |
- if (song == NULL) | |
+ if (song == NULL) { | |
+ if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) { | |
+ ret = -1; | |
+ goto out; | |
+ } | |
return -1; | |
+ } | |
artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0); | |
title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0); | |
if (artist != NULL && title != NULL) { |