From d057e7a142a327c653f3f0379014567028448b5d Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Jul 2016 20:56:59 +0200 Subject: player: fatal error if linked and compiled FFmpeg versions mismatch We don't support this anymore. This tries to exit in a controlled way after command line options are applied in order to honor logging options and, in case of libmpv, not to kill the host. Not sure if it would be better to just vomit text to stderr and call abort(). --- README.md | 3 +++ common/av_log.c | 11 ++--------- common/av_log.h | 5 ++++- player/main.c | 12 ++++++++++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5d43c682df..0cac74341c 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,9 @@ The reason for not supporting this is because it creates far too much complexity with little to no benefit, coupled with absurd and unusable FFmpeg API artifacts. +Newer mpv versiosn will refuse to start if runtime and compile time FFmpeg +library versions mismatch. + ## Release cycle Every other month, an arbitrary git snapshot is made, and is assigned diff --git a/common/av_log.c b/common/av_log.c index 804972889f..64ce26d853 100644 --- a/common/av_log.c +++ b/common/av_log.c @@ -189,7 +189,7 @@ struct lib { unsigned runv; }; -void print_libav_versions(struct mp_log *log, int v) +bool print_libav_versions(struct mp_log *log, int v) { const struct lib libs[] = { {"libavutil", LIBAVUTIL_VERSION_INT, avutil_version()}, @@ -222,14 +222,7 @@ void print_libav_versions(struct mp_log *log, int v) mp_msg(log, v, "%s version: %s\n", LIB_PREFIX, av_version_info()); #endif - if (mismatch) { - // Using mismatched libraries can be legitimate, but even then it's - // a bad idea. We don't acknowledge its usefulness and stability. - mp_warn(log, "Warning: mpv was compiled against a different version of " - "%s than the shared\nlibrary it is linked against. This is " - "most likely a broken build\nand misbehavior and crashes are " - "to be expected.\n", LIB_PREFIX); - } + return !mismatch; } #undef V diff --git a/common/av_log.h b/common/av_log.h index 17326b609f..18f7fc9d82 100644 --- a/common/av_log.h +++ b/common/av_log.h @@ -1,8 +1,11 @@ #ifndef MP_AV_LOG_H #define MP_AV_LOG_H + +#include + struct mpv_global; struct mp_log; void init_libav(struct mpv_global *global); void uninit_libav(struct mpv_global *global); -void print_libav_versions(struct mp_log *log, int v); +bool print_libav_versions(struct mp_log *log, int v); #endif diff --git a/player/main.c b/player/main.c index 21c273338c..7c06b5fed0 100644 --- a/player/main.c +++ b/player/main.c @@ -418,6 +418,18 @@ int mp_initialize(struct MPContext *mpctx, char **options) if (handle_help_options(mpctx)) return -2; + if (!print_libav_versions(mp_null_log, 0)) { + // Using mismatched libraries can be legitimate, but even then it's + // a bad idea. We don't acknowledge its usefulness and stability. + print_libav_versions(mpctx->log, MSGL_FATAL); + MP_FATAL(mpctx, "\nmpv was compiled against a different version of " + "FFmpeg/Libav than the shared\nlibrary it is linked against. " + "This is most likely a broken build and could\nresult in " + "misbehavior and crashes.\n\nmpv does not support this" + "configuration and will not run - rebuild mpv instead.\n"); + return -1; + } + if (opts->dump_stats && opts->dump_stats[0]) { if (mp_msg_open_stats_file(mpctx->global, opts->dump_stats) < 0) MP_ERR(mpctx, "Failed to open stats file '%s'\n", opts->dump_stats); -- cgit v1.2.3