[FFmpeg-devel] Patch for device list error in decklink_common.cpp

Ramiro Polla ramiro.polla at gmail.com
Tue Dec 2 22:19:34 CET 2014


On 02.12.2014 20:30, Jon bae wrote:
> Here is the other patch for decklink_common.cpp. It fix the error:
>
>     COM initialization failed
>     [decklink @ 02e5b520] Could not create DeckLink iterator
>     dummy: Immediate exit request

> From 203eba2fad14dd6d84552d6c22899792e80b53bb Mon Sep 17 00:00:00 2001
> From: Jonathan Baecker <jonbae77 at gmail.com>
> Date: Tue, 2 Dec 2014 20:12:38 +0100
> Subject: [PATCH 2/2] device list error in decklink_common
>
> Signed-off-by: Jonathan Baecker <jonbae77 at gmail.com>
> ---
>  libavdevice/decklink_common.cpp | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
> index 8eff910..8f7e32a 100644
> --- a/libavdevice/decklink_common.cpp
> +++ b/libavdevice/decklink_common.cpp
> @@ -42,16 +42,20 @@ IDeckLinkIterator *CreateDeckLinkIteratorInstance(void)
>  {
>      IDeckLinkIterator *iter;
>
> -    if (CoInitialize(NULL) != S_OK) {
> -        av_log(NULL, 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;
> -    }
> +    HRESULT result;
> +    /* Initialize COM on this thread */
> +    result = CoInitialize(NULL);
> +    if (FAILED(result)) {
> +        av_log(NULL, AV_LOG_ERROR, "COM initialization failed.\n");
> +        return NULL;
> +    }
> +
> +    /* Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system */
> +    result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&iter);
> +    if (FAILED(result)) {
> +        av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n");
> +        return NULL;
> +    }
>
>      return iter;
>  }
> --
> 2.2.0

This code is Copyright (c) Blackmagic Design. Try just changing the 
check for CoInitialize(NULL) from "!= S_OK" to "< 0".


More information about the ffmpeg-devel mailing list