History

avdevice/decklink: always free decklink resources on error

Marton Balint committed 10 years ago

Commit e22760a1 parent 38d75fe2 files · +18 −12Browse files

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

Unified · Split

libavdevice/decklink_dec.cpp+12−6
@@ -486,21 +486,21 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 485 unmodified lines
486486 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
487487 av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
488488 avctx->filename);
489− ctx->dl->Release();
490− return AVERROR(EIO);
489+ ret = AVERROR(EIO);
490+ goto error;
491491 }
492492
493493 /* List supported formats. */
494494 if (ctx->list_formats) {
495495 ff_decklink_list_formats(avctx, DIRECTION_IN);
496− ctx->dli->Release();
497− ctx->dl->Release();
498− return AVERROR_EXIT;
496+ ret = AVERROR_EXIT;
497+ goto error;
499498 }
500499
501500 if (mode_num > 0) {
502501 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
503502 av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);
503+ ret = AVERROR(EIO);
504504 goto error;
505505 }
506506 }
@@ -509,6 +509,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 2 unmodified lines
509509 st = avformat_new_stream(avctx, NULL);
510510 if (!st) {
511511 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
512+ ret = AVERROR(ENOMEM);
512513 goto error;
513514 }
514515 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -521,6 +522,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 6 unmodified lines
521522 st = avformat_new_stream(avctx, NULL);
522523 if (!st) {
523524 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
525+ ret = AVERROR(ENOMEM);
524526 goto error;
525527 }
526528 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -549,6 +551,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 22 unmodified lines
549551 st = avformat_new_stream(avctx, NULL);
550552 if (!st) {
551553 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
554+ ret = AVERROR(ENOMEM);
552555 goto error;
553556 }
554557 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
@@ -564,6 +567,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 9 unmodified lines
564567
565568 if (result != S_OK) {
566569 av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
570+ ret = AVERROR(EIO);
567571 goto error;
568572 }
569573
@@ -573,6 +577,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 3 unmodified lines
573577
574578 if (result != S_OK) {
575579 av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
580+ ret = AVERROR(EIO);
576581 goto error;
577582 }
578583
@@ -580,6 +585,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 1 unmodified line
580585
581586 if (decklink_start_input (avctx) != S_OK) {
582587 av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
588+ ret = AVERROR(EIO);
583589 goto error;
584590 }
585591
@@ -587,7 +593,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 1 unmodified line
587593
588594 error:
589595 ff_decklink_cleanup(avctx);
590− return AVERROR(EIO);
596+ return ret;
591597 }
592598
593599 int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)

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