From e3f30c58b09640e3bc7f4aa133e82ee7a0cb0db9 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 14 Jul 2022 15:16:01 +0200 Subject: WIP --- src/c_mpdview.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 +#include #include #include @@ -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); -- cgit v1.2.3