From patchwork Sat Apr 14 22:43:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 8450 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp2190931jad; Sat, 14 Apr 2018 15:43:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx48vwlRh4DBDvo5On7xywUy2yBaGLeorqOK4F8Mq3hU76xNAzxpQGPuLBT5PIgWYXOPmpwIZ X-Received: by 10.223.158.201 with SMTP id b9mr6536196wrf.215.1523745826209; Sat, 14 Apr 2018 15:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523745826; cv=none; d=google.com; s=arc-20160816; b=mOLhhNTF5zSOe9vIW3kB8XI4A/m2Wt4IPQz5eBbiTbdQ78iwJP6CyyjMk5Iof+Clxd UkPKIPI4zv/Ou7bkpCQnjVpNyBW522yVu0a+yRKjbRqixX1E4+auo1zWJTD9S6YJeo/z aG2iKwngAt+QFQVgoX9aZH/5SJbsSLs4Rh4qzJhweVNE5Ul9nNHz/cymCbjHUBuxSLqJ MlD5tgUWCR72Rs9ztfw8iD1eS5fvZPJN8/anC7DqvJQIhMmCU1K4TiT8/gnw4Ewd9p4i 4wqLcN64nJ0jKkjWGuihKan6ibrZPFqR5sZvHnA0vyQQ9IUw4gJqllatHjrsfj6HzRC0 eLsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=d1e0ZF/od21WcTyc7DchR+6dWLNrf3GIeadtqJVTV1U=; b=dr6y04q4wPDzXN0zL3KRn7cNaO8vPVZvoSWhSTOwWEYn9Ca6hie/YrkxgZMyGqV/OL gsan6zacAZPsix1ZMc5/htZE8a6rwHXLca/BZ8I8L5rO8xQsJPWcxV3Yo1BhPZscBjOq YtL9eNnX2MAL3HbPnoButAIwXNFou8vze7O6TCiJuwgybgC35dPrFCUTcvAo5445SaUP z/9QaPpHnFsR5BdK44TYVpKFr1WGUrRY8H18jD1wcDSiXrsgcmuAij5ZEiTAnosmJi6M erukwia/DRMXZt3387NML+f1b3Lb6CG4e57/FF1BT8QSjWT48hh/XCDcIHFwupS3TAbg mJTA== 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 a2si3683374wmg.178.2018.04.14.15.43.45; Sat, 14 Apr 2018 15:43:46 -0700 (PDT) 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 4B07768837F; Sun, 15 Apr 2018 01:43:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 45D4F6882DB for ; Sun, 15 Apr 2018 01:43:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 77843E0E2B; Sun, 15 Apr 2018 00:43:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CfEOzdxwxJ42; Sun, 15 Apr 2018 00:43:35 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 35D76E0838; Sun, 15 Apr 2018 00:43:35 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 15 Apr 2018 00:43:29 +0200 Message-Id: <20180414224329.18292-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 Subject: [FFmpeg-devel] [PATCH] avdevice/decklink_commmon: enhance error messages when iterator creation fails 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 Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Show a more useful error message which specifies the required driver version for the build, and use the correct context in the error message for WIN32. Signed-off-by: Marton Balint --- libavdevice/decklink_common.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index b889033cf8..d8cced7c74 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -53,25 +53,29 @@ extern "C" { #include "decklink_common.h" -#ifdef _WIN32 -IDeckLinkIterator *CreateDeckLinkIteratorInstance(void) +static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx) { IDeckLinkIterator *iter; +#ifdef _WIN32 if (CoInitialize(NULL) < 0) { - av_log(NULL, AV_LOG_ERROR, "COM initialization failed.\n"); + av_log(avctx, AV_LOG_ERROR, "COM initialization failed.\n"); return NULL; } if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**) &iter) != S_OK) { - av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n"); - return NULL; + iter = NULL; } +#else + iter = CreateDeckLinkIteratorInstance(); +#endif + if (!iter) + av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator. " + "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); return iter; } -#endif #ifdef _WIN32 static char *dup_wchar_to_utf8(wchar_t *w) @@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx, int show_inputs, int show_outputs) { IDeckLink *dl = NULL; - IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); + IDeckLinkIterator *iter = decklink_create_iterator(avctx); int ret = 0; - if (!iter) { - av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n"); + if (!iter) return AVERROR(EIO); - } while (ret == 0 && iter->Next(&dl) == S_OK) { IDeckLinkOutput *output_config; @@ -442,11 +444,9 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; IDeckLink *dl = NULL; - IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); - if (!iter) { - av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n"); + IDeckLinkIterator *iter = decklink_create_iterator(avctx); + if (!iter) return AVERROR_EXTERNAL; - } while (iter->Next(&dl) == S_OK) { const char *displayName;