[FFmpeg-cvslog] avdevice/decklink: factorize cleanup function to common code
Marton Balint
git at videolan.org
Sun Jun 26 19:20:07 CEST 2016
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Jun 18 15:49:01 2016 +0200| [1fc85d8511fb059450e36f2493b273635d507aa3] | committer: Marton Balint
avdevice/decklink: factorize cleanup function to common code
Reviewed-by: Deti Fliegl <deti at fliegl.de>
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fc85d8511fb059450e36f2493b273635d507aa3
---
libavdevice/decklink_common.cpp | 13 +++++++++++++
libavdevice/decklink_common.h | 1 +
libavdevice/decklink_dec.cpp | 11 ++---------
libavdevice/decklink_enc.cpp | 10 ++--------
4 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index ac7964c..43599b6 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -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();
+}
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index dff4fc1..1a9feeb 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -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 */
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 3b5d4be..8b57e0c 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -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);
}
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 6c5450f..4d00a53 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -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);
}
More information about the ffmpeg-cvslog
mailing list