From patchwork Thu Jan 11 08:11:30 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: 7258 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp322321jaa; Thu, 11 Jan 2018 00:12:15 -0800 (PST) X-Google-Smtp-Source: ACJfBot8dmw1Lc43lCWggSPoxoKmpNT/2EmCgQ7TpKjE7ovy0e0x/NAOhhzU20X27HtaQgNQJiiu X-Received: by 10.223.141.235 with SMTP id o98mr12094326wrb.39.1515658335239; Thu, 11 Jan 2018 00:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515658335; cv=none; d=google.com; s=arc-20160816; b=NqHCi3GQnM77vgnqG1HgKkwMl0gVaKxr8gZ9ZNU1F97xETFxa3b5FfOYKSsbpXIp9N bIBI86TMtPhmdoAgOE5VM3ybQSWH5vCWfGBx8JqZ1QwZH+Kcv6LFFGpTxxCj0Nn4R6rp zkB5DtU4lWfOcQvNS90+7/IAzZLga3nVDKthtq8ZpIc9K5XUswSH2UcT6whNSYgwwSkZ pbCpvy6i7tTGH2gpxbJB693x9AyVDYvfnv+IwWvg9ID4OYfdx89kqmwodlt/HdnL2Ns8 mAP6rWDNRAFS73v4eHM3z+fJNwaGEDCHWVWuQ2pQhGeBJb+AHYFlOvRc4rZlIn5xsHkY ZZcQ== 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=jgRrm8wOz/njvlkQ1+idfb0p8XxoGwOuo9Ey3LXZg1qutpFsNXBdBp0k5XfFyH1utM zV1DXB4nxLy4XfAfonb6v2KbJSJQ+blxzHm6DFIMjDxNueTbh/n8sWVljMLqW2d268dx uA7Z6Ic5MUbx1zF6aByPo8TiS1qPKi8x4oSwgPy3dkqEcfWB6dXdz1ETx97XVn/pkTcA rdAsYI11maoACLKBXCYogU/F4jc1CswyW4W0pbjY7lKPSe2wUY8fd2/0qHkhHd1+bVmF tYaGEoD9+xfDOVBZ1pnI8+9axTZDwzI/yyX6otMiEjzh5jAGUqaPplRvR7CYnE+2xdIm 5s2w== 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 v78si5806066wrc.476.2018.01.11.00.12.14; Thu, 11 Jan 2018 00:12:15 -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 EE664689F33; Thu, 11 Jan 2018 10:12:03 +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 4D781689AB3 for ; Thu, 11 Jan 2018 10:11:58 +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 1eZXxY-0008RJ-G9; Thu, 11 Jan 2018 09:11:36 +0100 From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Jan 2018 09:11:30 +0100 Message-Id: <1515658292-4719-2-git-send-email-osmanx@problemloesungsmaschine.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515658292-4719-1-git-send-email-osmanx@problemloesungsmaschine.de> References: <1515233228-16796-1-git-send-email-osmanx@problemloesungsmaschine.de> <1515658292-4719-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 v3 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);