avdevice/decklink: always free decklink resources on error
Reviewed-by: Deti Fliegl <deti@fliegl.de> Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
38d75fe906
commit
e22760aafd
@ -486,21 +486,21 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
|
|||||||
if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
|
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",
|
av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
|
||||||
avctx->filename);
|
avctx->filename);
|
||||||
ctx->dl->Release();
|
ret = AVERROR(EIO);
|
||||||
return AVERROR(EIO);
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List supported formats. */
|
/* List supported formats. */
|
||||||
if (ctx->list_formats) {
|
if (ctx->list_formats) {
|
||||||
ff_decklink_list_formats(avctx, DIRECTION_IN);
|
ff_decklink_list_formats(avctx, DIRECTION_IN);
|
||||||
ctx->dli->Release();
|
ret = AVERROR_EXIT;
|
||||||
ctx->dl->Release();
|
goto error;
|
||||||
return AVERROR_EXIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode_num > 0) {
|
if (mode_num > 0) {
|
||||||
if (ff_decklink_set_format(avctx, DIRECTION_IN, 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);
|
av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);
|
||||||
|
ret = AVERROR(EIO);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,6 +509,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
|
|||||||
st = avformat_new_stream(avctx, NULL);
|
st = avformat_new_stream(avctx, NULL);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
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);
|
st = avformat_new_stream(avctx, NULL);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
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);
|
st = avformat_new_stream(avctx, NULL);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||||
@ -564,6 +567,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
|
|||||||
|
|
||||||
if (result != S_OK) {
|
if (result != S_OK) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
|
||||||
|
ret = AVERROR(EIO);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,6 +577,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
|
|||||||
|
|
||||||
if (result != S_OK) {
|
if (result != S_OK) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
|
||||||
|
ret = AVERROR(EIO);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,6 +585,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
|
|||||||
|
|
||||||
if (decklink_start_input (avctx) != S_OK) {
|
if (decklink_start_input (avctx) != S_OK) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
|
||||||
|
ret = AVERROR(EIO);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +593,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
ff_decklink_cleanup(avctx);
|
ff_decklink_cleanup(avctx);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
||||||
|
@ -337,19 +337,19 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
|
|||||||
if (ctx->dl->QueryInterface(IID_IDeckLinkOutput, (void **) &ctx->dlo) != S_OK) {
|
if (ctx->dl->QueryInterface(IID_IDeckLinkOutput, (void **) &ctx->dlo) != S_OK) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
|
av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
|
||||||
avctx->filename);
|
avctx->filename);
|
||||||
ctx->dl->Release();
|
ret = AVERROR(EIO);
|
||||||
return AVERROR(EIO);
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List supported formats. */
|
/* List supported formats. */
|
||||||
if (ctx->list_formats) {
|
if (ctx->list_formats) {
|
||||||
ff_decklink_list_formats(avctx);
|
ff_decklink_list_formats(avctx);
|
||||||
ctx->dlo->Release();
|
ret = AVERROR_EXIT;
|
||||||
ctx->dl->Release();
|
goto error;
|
||||||
return AVERROR_EXIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup streams. */
|
/* Setup streams. */
|
||||||
|
ret = AVERROR(EIO);
|
||||||
for (n = 0; n < avctx->nb_streams; n++) {
|
for (n = 0; n < avctx->nb_streams; n++) {
|
||||||
AVStream *st = avctx->streams[n];
|
AVStream *st = avctx->streams[n];
|
||||||
AVCodecContext *c = st->codec;
|
AVCodecContext *c = st->codec;
|
||||||
@ -369,7 +369,7 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
ff_decklink_cleanup(avctx);
|
ff_decklink_cleanup(avctx);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_decklink_write_packet(AVFormatContext *avctx, AVPacket *pkt)
|
int ff_decklink_write_packet(AVFormatContext *avctx, AVPacket *pkt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user