From 7179ea04e32e6c8c16ace5d9fdd8c972c19d125e Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Sun, 29 Dec 2019 08:20:25 -0600 Subject: [PATCH] address av_lockmgr_register deprecation --- ffmpeg/wrapper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ffmpeg/wrapper.c b/ffmpeg/wrapper.c index bd18eac..3484f19 100644 --- a/ffmpeg/wrapper.c +++ b/ffmpeg/wrapper.c @@ -54,6 +54,20 @@ const int moonfire_ffmpeg_av_codec_id_h264 = AV_CODEC_ID_H264; const int moonfire_ffmpeg_averror_eof = AVERROR_EOF; +// Prior to libavcodec 58.9.100, multithreaded callers were expected to supply +// a lock callback. That release deprecated this API. It also introduced a +// FF_API_LOCKMGR #define to track its removal: +// +// * older builds (in which the lock callback is needed) don't define it. +// * middle builds (in which the callback is deprecated) define it as 1. +// value of 1. +// * future builds (in which the callback removed) will define +// it as 0. +// +// so (counterintuitively) use the lock manager when FF_API_LOCKMGR is +// undefined. + +#ifndef FF_API_LOCKMGR static int lock_callback(void **mutex, enum AVLockOp op) { switch (op) { case AV_LOCK_CREATE: @@ -82,11 +96,14 @@ static int lock_callback(void **mutex, enum AVLockOp op) { } return 0; } +#endif void moonfire_ffmpeg_init(void) { +#ifndef FF_API_LOCKMGR if (av_lockmgr_register(&lock_callback) < 0) { abort(); } +#endif } struct moonfire_ffmpeg_streams {