Skip to content
Snippets Groups Projects
Commit 1fc85d85 authored by Marton Balint's avatar Marton Balint
Browse files

avdevice/decklink: factorize cleanup function to common code


Reviewed-by: default avatarDeti Fliegl <deti@fliegl.de>
Signed-off-by: default avatarMarton Balint <cus@passwd.hu>
parent 340cea9f
No related branches found
No related tags found
No related merge requests found
...@@ -239,3 +239,16 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct ...@@ -239,3 +239,16 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
return 0; return 0;
} }
void ff_decklink_cleanup(AVFormatContext *avctx)
{
struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
struct decklink_ctx *ctx = (struct decklink_ctx *) cctx->ctx;
if (ctx->dli)
ctx->dli->Release();
if (ctx->dlo)
ctx->dlo->Release();
if (ctx->dl)
ctx->dl->Release();
}
...@@ -105,5 +105,6 @@ int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb ...@@ -105,5 +105,6 @@ int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb
int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num); int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
int ff_decklink_list_devices(AVFormatContext *avctx); int ff_decklink_list_devices(AVFormatContext *avctx);
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT); int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
void ff_decklink_cleanup(AVFormatContext *avctx);
#endif /* AVDEVICE_DECKLINK_COMMON_H */ #endif /* AVDEVICE_DECKLINK_COMMON_H */
...@@ -419,11 +419,7 @@ av_cold int ff_decklink_read_close(AVFormatContext *avctx) ...@@ -419,11 +419,7 @@ av_cold int ff_decklink_read_close(AVFormatContext *avctx)
ctx->dli->DisableAudioInput(); ctx->dli->DisableAudioInput();
} }
if (ctx->dli) ff_decklink_cleanup(avctx);
ctx->dli->Release();
if (ctx->dl)
ctx->dl->Release();
avpacket_queue_end(&ctx->queue); avpacket_queue_end(&ctx->queue);
av_freep(&cctx->ctx); av_freep(&cctx->ctx);
...@@ -620,10 +616,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ...@@ -620,10 +616,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
return 0; return 0;
error: error:
ff_decklink_cleanup(avctx);
ctx->dli->Release();
ctx->dl->Release();
return AVERROR(EIO); return AVERROR(EIO);
} }
......
...@@ -193,10 +193,7 @@ av_cold int ff_decklink_write_trailer(AVFormatContext *avctx) ...@@ -193,10 +193,7 @@ av_cold int ff_decklink_write_trailer(AVFormatContext *avctx)
ctx->dlo->DisableAudioOutput(); ctx->dlo->DisableAudioOutput();
} }
if (ctx->dlo) ff_decklink_cleanup(avctx);
ctx->dlo->Release();
if (ctx->dl)
ctx->dl->Release();
if (ctx->output_callback) if (ctx->output_callback)
delete ctx->output_callback; delete ctx->output_callback;
...@@ -400,10 +397,7 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx) ...@@ -400,10 +397,7 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
return 0; return 0;
error: error:
ff_decklink_cleanup(avctx);
ctx->dlo->Release();
ctx->dl->Release();
return AVERROR(EIO); return AVERROR(EIO);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment