summaryrefslogtreecommitdiff
path: root/libavdevice/decklink_dec.cpp
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2016-06-18 17:40:06 +0200
committerMarton Balint <cus@passwd.hu>2016-06-26 19:17:52 +0200
commite22760aafd3048bcb006191d55432561b50070ea (patch)
tree11015329d55a59841719948af04238b04d05b8e5 /libavdevice/decklink_dec.cpp
parent38d75fe90696fb80a5a78840443bc9bb421fe924 (diff)
avdevice/decklink: always free decklink resources on error
Reviewed-by: Deti Fliegl <deti@fliegl.de> Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/decklink_dec.cpp')
-rw-r--r--libavdevice/decklink_dec.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 0d789425fd..371be20ef9 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -486,21 +486,21 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
avctx->filename);
- ctx->dl->Release();
- return AVERROR(EIO);
+ ret = AVERROR(EIO);
+ goto error;
}
/* List supported formats. */
if (ctx->list_formats) {
ff_decklink_list_formats(avctx, DIRECTION_IN);
- ctx->dli->Release();
- ctx->dl->Release();
- return AVERROR_EXIT;
+ ret = AVERROR_EXIT;
+ goto error;
}
if (mode_num > 0) {
if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);
+ ret = AVERROR(EIO);
goto error;
}
}
@@ -509,6 +509,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
st = avformat_new_stream(avctx, NULL);
if (!st) {
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
+ ret = AVERROR(ENOMEM);
goto error;
}
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -521,6 +522,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
st = avformat_new_stream(avctx, NULL);
if (!st) {
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
+ ret = AVERROR(ENOMEM);
goto error;
}
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -549,6 +551,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
st = avformat_new_stream(avctx, NULL);
if (!st) {
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
+ ret = AVERROR(ENOMEM);
goto error;
}
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
@@ -564,6 +567,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
if (result != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
+ ret = AVERROR(EIO);
goto error;
}
@@ -573,6 +577,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
if (result != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
+ ret = AVERROR(EIO);
goto error;
}
@@ -580,6 +585,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
if (decklink_start_input (avctx) != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
+ ret = AVERROR(EIO);
goto error;
}
@@ -587,7 +593,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
error:
ff_decklink_cleanup(avctx);
- return AVERROR(EIO);
+ return ret;
}
int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)