From patchwork Sat Jan 6 10:07:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B6rn_Heusipp?= X-Patchwork-Id: 7157 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp386195jaa; Sat, 6 Jan 2018 02:07:43 -0800 (PST) X-Google-Smtp-Source: ACJfBotbjk5nynBJSp6cC5UJtqFFT1hiEkFx/Hu1NDOBRsjiglVdKlkVBpdHtHsBuxNcHDrqUA8k X-Received: by 10.223.136.131 with SMTP id f3mr3752327wrf.246.1515233263646; Sat, 06 Jan 2018 02:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515233263; cv=none; d=google.com; s=arc-20160816; b=Uw+jNvskd6YPAxN5J1kRsSHTKRlGDa5OUQhVdurcSOOxqTrpG+LWWllxlu6z2YfYGL CQhydOmQBR5BzUagCTiDq8fCE/77iJ7yF6pTbwAkxI8lnk99qbpFoD1kwHHwYFzlWb2l +kNA6dL9rueSzEMWXi+ctYMbKhaEcj3TSVNuzkQ6cFSlwukW7SQ7ermYzOflejOnsxhl 0HvlRnJXc1Wc5fcTcyI45lXGnl/lKebMsG1ovYhR5sAEQ3DiumAgJWmzFZ78a2ubVR6+ dvIdqiLckaowtA5zomQ+Pk97NEcnuPM0j17x/J2hwio2sp5xSWTXTF/hAA8I2rGvaI13 Yo1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=+xZTx2mlPTp0EpKLfhbNDkTyy8PoaP2voc7H2Gc1hb0=; b=doVI5YLydzz4WjRk9vofN47FdbBmyGb7fZ2wRsE2kA0ZILnjWsfdHs56ycHNDG1k4m h96Ij7FizP8C04Psr7Vhzn+8MzSyGEVslb3v0ABi87mxjoRt0fbbNwXk6GY4l3xtJMtD Lu2DRsseK66Wtuae+zvxfAZa2AOEd6la1Z8ZLG0M7pWsM9PNxxTWmD634ydm1GLIPC55 woR7TzFm0x+/6Ad9hqqNKLxOZG+5/jiQ7OiHdywC1DmxJX+CwYF/cwzHq/XATnDoN6JT JXqir6LLUCHQ+IkiUI5tHeKsRbmXBvgeARnfPCmjQeM601ACAXl09ibHh+JoCrbrhe6p OVwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m1si4868415wmm.143.2018.01.06.02.07.43; Sat, 06 Jan 2018 02:07:43 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5649689C73; Sat, 6 Jan 2018 12:07:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from datengang.de (datengang.de [138.201.179.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B5A76805BD for ; Sat, 6 Jan 2018 12:07:31 +0200 (EET) Received: from p5b3e6755.dip0.t-ipconnect.de ([91.62.103.85] helo=idefix.fritz.box) by datengang.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.89) (envelope-from ) id 1eXlNe-00081P-Ja; Sat, 06 Jan 2018 11:07:10 +0100 From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Jan 2018 11:07:06 +0100 Message-Id: <1515233228-16796-2-git-send-email-osmanx@problemloesungsmaschine.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515233228-16796-1-git-send-email-osmanx@problemloesungsmaschine.de> References: <1515233228-16796-1-git-send-email-osmanx@problemloesungsmaschine.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 91.62.103.85 X-SA-Exim-Mail-From: osmanx@problemloesungsmaschine.de X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on datengang.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=8.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on datengang.de) Subject: [FFmpeg-devel] [PATCH 2/4] avformat/libopenmpt: Update to libopenmpt 0.3 API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" libopenmpt 0.3 deprecates openmpt_module_create_from_memory() and provides a replacement function openmpt_module_create_from_memory2(). Detecting libopenmpt 0.3 can be done at build time via the API version macros provided by libopenmpt. libopenmpt 0.2 did not provide all required macros, however libopenmpt documents the required #define shims that can be safely added for libopenmpt 0.2. Using openmpt_module_create_from_memory2() instead of openmpt_module_create_from_memory() avoids the deprecation warning when building ffmpeg with libopenmpt 0.3. openmpt_module_create_from_memory2() provides more fine-grained error reporting and in particular allows distinguishing out-of-memory from input file parsing errors. Return appropriate ffmpeg errors accordingly. libopenmpt 0.3 is ABI and API compatible with applications built against libopenmpt 0.2. Building ffmpeg with libopenmpt 0.2 is still supported. Signed-off-by: Jörn Heusipp --- libavformat/libopenmpt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c index 2e22290..30c3d6e 100644 --- a/libavformat/libopenmpt.c +++ b/libavformat/libopenmpt.c @@ -21,6 +21,14 @@ #include #include +#include +/* Shims to support libopenmpt < 0.3.0 (as documented by libopenmpt) */ +#if !defined(OPENMPT_API_VERSION_MAKE) +#define OPENMPT_API_VERSION_MAKE(major, minor, patch) (((major)<<24)|((minor)<<16)|((patch)<<0)) +#endif +#if !defined(OPENMPT_API_VERSION_AT_LEAST) +#define OPENMPT_API_VERSION_AT_LEAST(major, minor, patch) (OPENMPT_API_VERSION >= OPENMPT_API_VERSION_MAKE((major), (minor), (patch))) +#endif #include "libavutil/avstring.h" #include "libavutil/opt.h" @@ -74,6 +82,9 @@ static int read_header_openmpt(AVFormatContext *s) OpenMPTContext *openmpt = s->priv_data; int64_t size; char *buf; +#if OPENMPT_API_VERSION_AT_LEAST(0,3,0) + int error; +#endif int ret; size = avio_size(s->pb); @@ -89,10 +100,24 @@ static int read_header_openmpt(AVFormatContext *s) return size; } +#if OPENMPT_API_VERSION_AT_LEAST(0,3,0) + error = OPENMPT_ERROR_OK; + openmpt->module = openmpt_module_create_from_memory2(buf, size, openmpt_logfunc, s, NULL, NULL, &error, NULL, NULL); + av_freep(&buf); + if (!openmpt->module) { + if (error == OPENMPT_ERROR_OUT_OF_MEMORY) + return AVERROR(ENOMEM); + else if (error >= OPENMPT_ERROR_GENERAL) + return AVERROR_INVALIDDATA; + else + return AVERROR_UNKNOWN; + } +#else openmpt->module = openmpt_module_create_from_memory(buf, size, openmpt_logfunc, s, NULL); av_freep(&buf); if (!openmpt->module) return AVERROR_INVALIDDATA; +#endif openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);