Skip to content
Snippets Groups Projects
Commit 768c0774 authored by Marton Balint's avatar Marton Balint
Browse files

avdevice/decklink_commmon: enhance error messages when iterator creation fails


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: default avatarMarton Balint <cus@passwd.hu>
parent 30270561
No related branches found
No related tags found
No related merge requests found
...@@ -53,25 +53,29 @@ extern "C" { ...@@ -53,25 +53,29 @@ extern "C" {
#include "decklink_common.h" #include "decklink_common.h"
#ifdef _WIN32 static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx)
IDeckLinkIterator *CreateDeckLinkIteratorInstance(void)
{ {
IDeckLinkIterator *iter; IDeckLinkIterator *iter;
#ifdef _WIN32
if (CoInitialize(NULL) < 0) { 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; return NULL;
} }
if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL,
IID_IDeckLinkIterator, (void**) &iter) != S_OK) { IID_IDeckLinkIterator, (void**) &iter) != S_OK) {
av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n"); iter = NULL;
return 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; return iter;
} }
#endif
#ifdef _WIN32 #ifdef _WIN32
static char *dup_wchar_to_utf8(wchar_t *w) static char *dup_wchar_to_utf8(wchar_t *w)
...@@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx, ...@@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx,
int show_inputs, int show_outputs) int show_inputs, int show_outputs)
{ {
IDeckLink *dl = NULL; IDeckLink *dl = NULL;
IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); IDeckLinkIterator *iter = decklink_create_iterator(avctx);
int ret = 0; int ret = 0;
if (!iter) { if (!iter)
av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
return AVERROR(EIO); return AVERROR(EIO);
}
while (ret == 0 && iter->Next(&dl) == S_OK) { while (ret == 0 && iter->Next(&dl) == S_OK) {
IDeckLinkOutput *output_config; IDeckLinkOutput *output_config;
...@@ -442,11 +444,9 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) ...@@ -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_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
IDeckLink *dl = NULL; IDeckLink *dl = NULL;
IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); IDeckLinkIterator *iter = decklink_create_iterator(avctx);
if (!iter) { if (!iter)
av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
return AVERROR_EXTERNAL; return AVERROR_EXTERNAL;
}
while (iter->Next(&dl) == S_OK) { while (iter->Next(&dl) == S_OK) {
const char *displayName; const char *displayName;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment