summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/c_mpdview.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/c_mpdview.c b/src/c_mpdview.c
index 77d1eec..320f8e2 100644
--- a/src/c_mpdview.c
+++ b/src/c_mpdview.c
@@ -45,6 +45,8 @@
* This is the entrypoint of the program.
*/
+#include <mpd/song.h>
+#include <mpd/status.h>
#include <sys/param.h>
#include <sys/syslimits.h>
@@ -143,6 +145,10 @@ c_get_mpd_status(struct mpdview_s* v)
static u8_t
c_get_mpd_song(struct mpdview_s* v)
{
+ if (v->song != NULL) {
+ mpd_song_free(v->song);
+ v->song = NULL;
+ }
v->song = mpd_run_current_song(v->conn);
if (v->song == NULL) {
dprintf(
@@ -220,11 +226,11 @@ main
c_destroy_mpdview(&view);
return (EXIT_FAILURE);
}
+ signal(SIGINT, c_signal);
if (c_get_mpd_status(view) == RET_ERR) {
c_destroy_mpdview(&view);
return (EXIT_FAILURE);
}
- signal(SIGINT, c_signal);
if (view->state == MPD_STATE_PLAY || view->state == MPD_STATE_PAUSE) {
if (c_get_mpd_song(view) == RET_ERR) {
c_destroy_mpdview(&view);
@@ -239,6 +245,10 @@ main
doexit == FALSE &&
mpd_run_idle_mask(view->conn, MPD_IDLE_PLAYER) != 0
) {
+ if (c_get_mpd_status(view) == RET_ERR) {
+ c_destroy_mpdview(&view);
+ return (EXIT_FAILURE);
+ }
if (view->state == MPD_STATE_PLAY || view->state == MPD_STATE_PAUSE) {
if (c_get_mpd_song(view) == RET_ERR) {
c_destroy_mpdview(&view);