From 360535171d457506deaad4210251939c08674a76 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 3 Jul 2015 17:35:18 +0200 Subject: make libav (and retrieving cover from media file) optional --- Makefile | 5 ++++- mpd-notification.c | 13 ++++++++++++- mpd-notification.h | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dd08b43..4d3260e 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,10 @@ RM := rm CFLAGS += -std=c11 -O2 -Wall -Werror CFLAGS += $(shell pkg-config --cflags --libs libmpdclient) CFLAGS += $(shell pkg-config --cflags --libs libnotify) -CFLAGS += $(shell pkg-config --cflags --libs libavcodec libavformat) +LIBAV_CFLAGS := $(shell pkg-config --cflags --libs libavcodec libavformat 2>/dev/null) +ifneq ($(LIBAV_CFLAGS),) +CFLAGS += -DHAVE_LIBAV $(LIBAV_CFLAGS) +endif # this is just a fallback in case you do not use git but downloaded # a release tarball... VERSION := 0.6.0 diff --git a/mpd-notification.c b/mpd-notification.c index 764df95..e79bc68 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -56,6 +56,7 @@ void received_signal(int signal) { } } +#ifdef HAVE_LIBAV /*** retrieve_album_art ***/ char * retrieve_album_art(const char *path) { int i, ret = 0; @@ -105,14 +106,18 @@ fail: return NULL; } } +#endif /*** get_icon ***/ char * get_icon(const char * music_dir, const char * uri) { - char * icon = NULL, * uri_path = NULL, * uri_dirname = NULL; + char * icon = NULL, * uri_dirname = NULL; DIR * dir; struct dirent * entry; regex_t regex; +#ifdef HAVE_LIBAV + char * uri_path = NULL; + /* try album artwork first */ uri_path = malloc(strlen(music_dir) + strlen(uri) + 2); sprintf(uri_path, "%s/%s", music_dir, uri); @@ -120,6 +125,7 @@ char * get_icon(const char * music_dir, const char * uri) { if (icon != NULL) goto found; +#endif uri_dirname = strdup(uri); @@ -153,9 +159,12 @@ char * get_icon(const char * music_dir, const char * uri) { regfree(®ex); closedir(dir); +#ifdef HAVE_LIBAV found: if (uri_path) free(uri_path); +#endif + if (uri_dirname) free(uri_dirname); @@ -243,8 +252,10 @@ int main(int argc, char ** argv) { } } +#ifdef HAVE_LIBAV /* libav */ av_register_all(); +#endif conn = mpd_connection_new(mpd_host, mpd_port, mpd_timeout); diff --git a/mpd-notification.h b/mpd-notification.h index c991fd1..159aef1 100644 --- a/mpd-notification.h +++ b/mpd-notification.h @@ -14,8 +14,10 @@ #include +#ifdef HAVE_LIBAV #include #include +#endif #include #include -- cgit v1.2.3-54-g00ecf