Browse Source

avdevice/decklink: factorize cleanup function to common code

Reviewed-by: Deti Fliegl <deti@fliegl.de>
Signed-off-by: Marton Balint <cus@passwd.hu>
tags/n3.2
Marton Balint 9 years ago
parent
commit
1fc85d8511
4 changed files with 18 additions and 17 deletions
  1. +13
    -0
      libavdevice/decklink_common.cpp
  2. +1
    -0
      libavdevice/decklink_common.h
  3. +2
    -9
      libavdevice/decklink_dec.cpp
  4. +2
    -8
      libavdevice/decklink_enc.cpp

+ 13
- 0
libavdevice/decklink_common.cpp View File

@@ -239,3 +239,16 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct

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();
}

+ 1
- 0
libavdevice/decklink_common.h View File

@@ -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_list_devices(AVFormatContext *avctx);
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
void ff_decklink_cleanup(AVFormatContext *avctx);

#endif /* AVDEVICE_DECKLINK_COMMON_H */

+ 2
- 9
libavdevice/decklink_dec.cpp View File

@@ -419,11 +419,7 @@ av_cold int ff_decklink_read_close(AVFormatContext *avctx)
ctx->dli->DisableAudioInput();
}

if (ctx->dli)
ctx->dli->Release();
if (ctx->dl)
ctx->dl->Release();

ff_decklink_cleanup(avctx);
avpacket_queue_end(&ctx->queue);

av_freep(&cctx->ctx);
@@ -620,10 +616,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
return 0;

error:

ctx->dli->Release();
ctx->dl->Release();

ff_decklink_cleanup(avctx);
return AVERROR(EIO);
}



+ 2
- 8
libavdevice/decklink_enc.cpp View File

@@ -193,10 +193,7 @@ av_cold int ff_decklink_write_trailer(AVFormatContext *avctx)
ctx->dlo->DisableAudioOutput();
}

if (ctx->dlo)
ctx->dlo->Release();
if (ctx->dl)
ctx->dl->Release();
ff_decklink_cleanup(avctx);

if (ctx->output_callback)
delete ctx->output_callback;
@@ -400,10 +397,7 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
return 0;

error:

ctx->dlo->Release();
ctx->dl->Release();

ff_decklink_cleanup(avctx);
return AVERROR(EIO);
}



Loading…
Cancel
Save