summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.h25
-rw-r--r--src/player.c11
2 files changed, 32 insertions, 4 deletions
diff --git a/src/config.h b/src/config.h
index e6982db..bc8934a 100644
--- a/src/config.h
+++ b/src/config.h
@@ -12,10 +12,33 @@
* ffmpeg’s micro versions always start at 100, that’s how we can distinguish
* ffmpeg and libav */
#include <libavfilter/version.h>
+#include <libavformat/version.h>
/* does graph_send_command exist (ffmpeg >=2.2) */
-#if LIBAVFILTER_VERSION_MAJOR >= 4 && \
+#if !defined(HAVE_AVFILTER_GRAPH_SEND_COMMAND) && \
+ LIBAVFILTER_VERSION_MAJOR >= 4 && \
LIBAVFILTER_VERSION_MICRO >= 100
#define HAVE_AVFILTER_GRAPH_SEND_COMMAND
#endif
+/* explicit init is optional for ffmpeg>=4.0 */
+#if !defined(HAVE_AVFORMAT_NETWORK_INIT) && \
+ LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 5, 100) && \
+ LIBAVFORMAT_VERSION_MICRO >= 100
+#define HAVE_AVFORMAT_NETWORK_INIT
+#endif
+
+/* dito */
+#if !defined(HAVE_AVFILTER_REGISTER_ALL) && \
+ LIBAVFILTER_VERSION_INT < AV_VERSION_INT(7, 14, 100) && \
+ LIBAVFILTER_VERSION_MICRO >= 100
+#define HAVE_AVFILTER_REGISTER_ALL
+#endif
+
+/* dito */
+#if !defined(HAVE_AV_REGISTER_ALL) && \
+ LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100) && \
+ LIBAVFORMAT_VERSION_MICRO >= 100
+#define HAVE_AV_REGISTER_ALL
+#endif
+
diff --git a/src/player.c b/src/player.c
index ff1f1c9..16f5553 100644
--- a/src/player.c
+++ b/src/player.c
@@ -70,16 +70,19 @@ static void printError (const BarSettings_t * const settings,
}
/* global initialization
- *
- * XXX: in theory we can select the filters/formats we want to support, but
- * this does not work in practise.
*/
void BarPlayerInit (player_t * const p, const BarSettings_t * const settings) {
ao_initialize ();
av_log_set_level (AV_LOG_FATAL);
+#ifdef HAVE_AV_REGISTER_ALL
av_register_all ();
+#endif
+#ifdef HAVE_AVFILTER_REGISTER_ALL
avfilter_register_all ();
+#endif
+#ifdef HAVE_AVFORMAT_NETWORK_INIT
avformat_network_init ();
+#endif
pthread_mutex_init (&p->lock, NULL);
pthread_cond_init (&p->cond, NULL);
@@ -95,7 +98,9 @@ void BarPlayerDestroy (player_t * const p) {
pthread_cond_destroy (&p->aoplayCond);
pthread_mutex_destroy (&p->aoplayLock);
+#ifdef HAVE_AVFORMAT_NETWORK_INIT
avformat_network_deinit ();
+#endif
ao_shutdown ();
}