aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2015-07-03 17:35:18 +0200
committerGravatar Christian Hesse <mail@eworm.de>2015-07-03 17:35:18 +0200
commit360535171d457506deaad4210251939c08674a76 (patch)
treef35f356ee3e6000d59b0c9c687a32222fb1dc6db
parent02a7441b621db03161061dbfd5a93f1a1adc7e75 (diff)
downloadmpd-notification-360535171d457506deaad4210251939c08674a76.tar.gz
mpd-notification-360535171d457506deaad4210251939c08674a76.tar.zst
make libav (and retrieving cover from media file) optional
-rw-r--r--Makefile5
-rw-r--r--mpd-notification.c13
-rw-r--r--mpd-notification.h2
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(&regex);
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 <libnotify/notify.h>
+#ifdef HAVE_LIBAV
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
+#endif
#include <stdio.h>
#include <unistd.h>