History

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.

Marton Balint committed 8 years ago

Commit 768c0771 parent 30270561 file · +14 −14Browse files

Showing the changes to libavdevice/decklink_common.cpp (1 of 1 file). Show all

Unified · Split

libavdevice/decklink_common.cpp+14−14
@@ -53,25 +53,29 @@ extern "C" { · 52 unmodified lines
53 53
54#include "decklink_common.h"54#include "decklink_common.h"
55 55
56#ifdef _WIN3256static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx)
57IDeckLinkIterator *CreateDeckLinkIteratorInstance(void)
58{57{
59 IDeckLinkIterator *iter;58 IDeckLinkIterator *iter;
60 59
60#ifdef _WIN32
61 if (CoInitialize(NULL) < 0) {61 if (CoInitialize(NULL) < 0) {
62 av_log(NULL, AV_LOG_ERROR, "COM initialization failed.\n");62 av_log(avctx, AV_LOG_ERROR, "COM initialization failed.\n");
63 return NULL;63 return NULL;
64 }64 }
65 65
66 if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL,66 if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL,
67 IID_IDeckLinkIterator, (void**) &iter) != S_OK) {67 IID_IDeckLinkIterator, (void**) &iter) != S_OK) {
68 av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n");68 iter = NULL;
69 return NULL;
70 }69 }
70#else
71 iter = CreateDeckLinkIteratorInstance();
72#endif
73 if (!iter)
74 av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator. "
75 "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n");
71 76
72 return iter;77 return iter;
73}78}
74#endif
75 79
76#ifdef _WIN3280#ifdef _WIN32
77static char *dup_wchar_to_utf8(wchar_t *w)81static char *dup_wchar_to_utf8(wchar_t *w)
@@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx, · 207 unmodified lines
285 int show_inputs, int show_outputs)289 int show_inputs, int show_outputs)
286{290{
287 IDeckLink *dl = NULL;291 IDeckLink *dl = NULL;
288 IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();292 IDeckLinkIterator *iter = decklink_create_iterator(avctx);
289 int ret = 0;293 int ret = 0;
290 294
291 if (!iter) {295 if (!iter)
292 av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
293 return AVERROR(EIO);296 return AVERROR(EIO);
294 }
295 297
296 while (ret == 0 && iter->Next(&dl) == S_OK) {298 while (ret == 0 && iter->Next(&dl) == S_OK) {
297 IDeckLinkOutput *output_config;299 IDeckLinkOutput *output_config;
@@ -442,11 +444,9 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) · 144 unmodified lines
442 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;444 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
443 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;445 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
444 IDeckLink *dl = NULL;446 IDeckLink *dl = NULL;
445 IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();447 IDeckLinkIterator *iter = decklink_create_iterator(avctx);
446 if (!iter) {448 if (!iter)
447 av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
448 return AVERROR_EXTERNAL;449 return AVERROR_EXTERNAL;
449 }
450 450
451 while (iter->Next(&dl) == S_OK) {451 while (iter->Next(&dl) == S_OK) {
452 const char *displayName;452 const char *displayName;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t