History

avdevice/decklink: factorize device finder function

Marton Balint committed 10 years ago

Commit 38d75fe1 parent 4ce0a774 files · +38 −50Browse files

Showing the changes to libavdevice/decklink_dec.cpp (1 of 4 files). Show all

Unified · Split

libavdevice/decklink_dec.cpp+4−25
@@ -431,13 +431,12 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 430 unmodified lines
431431 {
432432 struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
433433 struct decklink_ctx *ctx;
434− IDeckLinkIterator *iter;
435− IDeckLink *dl = NULL;
436434 AVStream *st;
437435 HRESULT result;
438436 char fname[1024];
439437 char *tmp;
440438 int mode_num = 0;
439+ int ret;
441440
442441 ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx));
443442 if (!ctx)
@@ -466,12 +465,6 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 22 unmodified lines
466465 return AVERROR(EINVAL);
467466 }
468467
469− iter = CreateDeckLinkIteratorInstance();
470− if (!iter) {
471− av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
472− return AVERROR(EIO);
473− }
474−
475468 /* List available devices. */
476469 if (ctx->list_devices) {
477470 ff_decklink_list_devices(avctx);
@@ -485,23 +478,9 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 7 unmodified lines
485478 *tmp = 0;
486479 }
487480
488− /* Open device. */
489− while (iter->Next(&dl) == S_OK) {
490− const char *displayName;
491− ff_decklink_get_display_name(dl, &displayName);
492− if (!strcmp(fname, displayName)) {
493− av_free((void *) displayName);
494− ctx->dl = dl;
495− break;
496− }
497− av_free((void *) displayName);
498− dl->Release();
499− }
500− iter->Release();
501− if (!ctx->dl) {
502− av_log(avctx, AV_LOG_ERROR, "Could not open '%s'\n", fname);
503− return AVERROR(EIO);
504− }
481+ ret = ff_decklink_init_device(avctx, fname);
482+ if (ret < 0)
483+ return ret;
505484
506485 /* Get input device. */
507486 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {

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