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.
Showing the changes to libavdevice/decklink_common.cpp (1 of 1 file). Show all
Unified · Split
| @@ -53,25 +53,29 @@ extern "C" { · 52 unmodified lines | ||
| 53 | 53 | |
| 54 | 54 | #include "decklink_common.h" |
| 55 | 55 | |
| 56 | −#ifdef _WIN32 | |
| 57 | −IDeckLinkIterator *CreateDeckLinkIteratorInstance(void) | |
| 56 | +static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx) | |
| 58 | 57 | { |
| 59 | 58 | IDeckLinkIterator *iter; |
| 60 | 59 | |
| 60 | +#ifdef _WIN32 | |
| 61 | 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 | 63 | return NULL; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, |
| 67 | 67 | IID_IDeckLinkIterator, (void**) &iter) != S_OK) { |
| 68 | − av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n"); | |
| 69 | − return NULL; | |
| 68 | + iter = 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 | 77 | return iter; |
| 73 | 78 | } |
| 74 | −#endif | |
| 75 | 79 | |
| 76 | 80 | #ifdef _WIN32 |
| 77 | 81 | static char *dup_wchar_to_utf8(wchar_t *w) |
| @@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx, · 207 unmodified lines | ||
| 285 | 289 | int show_inputs, int show_outputs) |
| 286 | 290 | { |
| 287 | 291 | IDeckLink *dl = NULL; |
| 288 | − IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); | |
| 292 | + IDeckLinkIterator *iter = decklink_create_iterator(avctx); | |
| 289 | 293 | int ret = 0; |
| 290 | 294 | |
| 291 | − if (!iter) { | |
| 292 | − av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n"); | |
| 295 | + if (!iter) | |
| 293 | 296 | return AVERROR(EIO); |
| 294 | − } | |
| 295 | 297 | |
| 296 | 298 | while (ret == 0 && iter->Next(&dl) == S_OK) { |
| 297 | 299 | IDeckLinkOutput *output_config; |
| @@ -442,11 +444,9 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) · 144 unmodified lines | ||
| 442 | 444 | struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; |
| 443 | 445 | struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; |
| 444 | 446 | 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) | |
| 448 | 449 | return AVERROR_EXTERNAL; |
| 449 | − } | |
| 450 | 450 | |
| 451 | 451 | while (iter->Next(&dl) == S_OK) { |
| 452 | 452 | const char *displayName; |