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
5353
5454 #include "decklink_common.h"
5555
56−#ifdef _WIN32
57−IDeckLinkIterator *CreateDeckLinkIteratorInstance(void)
56+static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx)
5857 {
5958 IDeckLinkIterator *iter;
6059
60+#ifdef _WIN32
6161 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");
6363 return NULL;
6464 }
6565
6666 if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL,
6767 IID_IDeckLinkIterator, (void**) &iter) != S_OK) {
68− av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n");
69− return NULL;
68+ iter = NULL;
7069 }
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");
7176
7277 return iter;
7378 }
74−#endif
7579
7680 #ifdef _WIN32
7781 static char *dup_wchar_to_utf8(wchar_t *w)
@@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx, · 207 unmodified lines
285289 int show_inputs, int show_outputs)
286290 {
287291 IDeckLink *dl = NULL;
288− IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();
292+ IDeckLinkIterator *iter = decklink_create_iterator(avctx);
289293 int ret = 0;
290294
291− if (!iter) {
292− av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
295+ if (!iter)
293296 return AVERROR(EIO);
294− }
295297
296298 while (ret == 0 && iter->Next(&dl) == S_OK) {
297299 IDeckLinkOutput *output_config;
@@ -442,11 +444,9 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) · 144 unmodified lines
442444 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
443445 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
444446 IDeckLink *dl = NULL;
445− IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();
446− if (!iter) {
447− av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
447+ IDeckLinkIterator *iter = decklink_create_iterator(avctx);
448+ if (!iter)
448449 return AVERROR_EXTERNAL;
449− }
450450
451451 while (iter->Next(&dl) == S_OK) {
452452 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