From 13221e941bcda86bc251c1ce0f90ba7b2f8501a5 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 3 Jul 2022 03:51:52 +0200 Subject: WIP --- src/c_mpdview.c | 25 +++++++++++++++++-------- src/c_mpdview.h | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/c_mpdview.c b/src/c_mpdview.c index 91a8b4e..4b0eece 100644 --- a/src/c_mpdview.c +++ b/src/c_mpdview.c @@ -45,16 +45,19 @@ * This is the entrypoint of the program. */ -#include -#include -#include #include #include +#include #include -#include +#include #include #include +#include +#include +#include +#include +#include #include "c_mpdview.h" @@ -67,7 +70,8 @@ main struct mpd_connection* conn; struct mpd_status* status; struct mpd_song* song; - char* uri; + char buff[BUFF_SIZE]; + /* char* uri; */ enum mpd_state state; (void)argc; @@ -94,11 +98,16 @@ main if (state == MPD_STATE_PLAY || state == MPD_STATE_PAUSE) { mpd_response_next(conn); song = mpd_recv_song(conn); - uri = (char*)mpd_song_get_uri(song); - dprintf(STDOUT_FILENO, "Song: %s\n", uri); + mpd_response_finish(conn); + bzero(buff, BUFF_SIZE); + if (mpd_run_albumart(conn, mpd_song_get_uri(song), 0, buff, BUFF_SIZE) > -1) { + write(STDOUT_FILENO, buff, BUFF_SIZE); + } + else { + dprintf(STDOUT_FILENO, "Exit\n"); + } mpd_song_free(song); song = NULL; - mpd_response_finish(conn); } if (conn != NULL) { mpd_connection_free(conn); diff --git a/src/c_mpdview.h b/src/c_mpdview.h index ad9338f..21f96b1 100644 --- a/src/c_mpdview.h +++ b/src/c_mpdview.h @@ -39,13 +39,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * mpdview: src/c_mpdview.h - * Mon, 27 Jun 2022 21:20:40 +0200 + * Sun, 03 Jul 2022 03:31:56 +0200 * Joe */ #ifndef __C_MPDVIEW_H__ #define __C_MPDVIEW_H__ +#define BUFF_SIZE 8192 #define PROGNAME "mpdview" typedef char bool_t; -- cgit v1.2.3