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
486 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {486 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
487 av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",487 av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
488 avctx->filename);488 avctx->filename);
489 ctx->dl->Release();489 ret = AVERROR(EIO);
490 return AVERROR(EIO);490 goto error;
491 }491 }
492 492
493 /* List supported formats. */493 /* List supported formats. */
494 if (ctx->list_formats) {494 if (ctx->list_formats) {
495 ff_decklink_list_formats(avctx, DIRECTION_IN);495 ff_decklink_list_formats(avctx, DIRECTION_IN);
496 ctx->dli->Release();496 ret = AVERROR_EXIT;
497 ctx->dl->Release();497 goto error;
498 return AVERROR_EXIT;
499 }498 }
500 499
501 if (mode_num > 0) {500 if (mode_num > 0) {
502 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {501 if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
503 av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);502 av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);
503 ret = AVERROR(EIO);
504 goto error;504 goto error;
505 }505 }
506 }506 }
@@ -509,6 +509,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 2 unmodified lines
509 st = avformat_new_stream(avctx, NULL);509 st = avformat_new_stream(avctx, NULL);
510 if (!st) {510 if (!st) {
511 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");511 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
512 ret = AVERROR(ENOMEM);
512 goto error;513 goto error;
513 }514 }
514 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;515 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -521,6 +522,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 6 unmodified lines
521 st = avformat_new_stream(avctx, NULL);522 st = avformat_new_stream(avctx, NULL);
522 if (!st) {523 if (!st) {
523 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");524 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
525 ret = AVERROR(ENOMEM);
524 goto error;526 goto error;
525 }527 }
526 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;528 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -549,6 +551,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 22 unmodified lines
549 st = avformat_new_stream(avctx, NULL);551 st = avformat_new_stream(avctx, NULL);
550 if (!st) {552 if (!st) {
551 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");553 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
554 ret = AVERROR(ENOMEM);
552 goto error;555 goto error;
553 }556 }
554 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;557 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
@@ -564,6 +567,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 9 unmodified lines
564 567
565 if (result != S_OK) {568 if (result != S_OK) {
566 av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");569 av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
570 ret = AVERROR(EIO);
567 goto error;571 goto error;
568 }572 }
569 573
@@ -573,6 +577,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 3 unmodified lines
573 577
574 if (result != S_OK) {578 if (result != S_OK) {
575 av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");579 av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
580 ret = AVERROR(EIO);
576 goto error;581 goto error;
577 }582 }
578 583
@@ -580,6 +585,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 1 unmodified line
580 585
581 if (decklink_start_input (avctx) != S_OK) {586 if (decklink_start_input (avctx) != S_OK) {
582 av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");587 av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
588 ret = AVERROR(EIO);
583 goto error;589 goto error;
584 }590 }
585 591
@@ -587,7 +593,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 1 unmodified line
587 593
588error:594error:
589 ff_decklink_cleanup(avctx);595 ff_decklink_cleanup(avctx);
590 return AVERROR(EIO);596 return ret;
591}597}
592 598
593int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)599int 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