]> git.sesse.net Git - ffmpeg/commitdiff
avdevice/decklink: factorize cleanup function to common code
authorMarton Balint <cus@passwd.hu>
Sat, 18 Jun 2016 13:49:01 +0000 (15:49 +0200)
committerMarton Balint <cus@passwd.hu>
Sun, 26 Jun 2016 17:17:37 +0000 (19:17 +0200)
Reviewed-by: Deti Fliegl <deti@fliegl.de>
Signed-off-by: Marton Balint <cus@passwd.hu>
libavdevice/decklink_common.cpp
libavdevice/decklink_common.h
libavdevice/decklink_dec.cpp
libavdevice/decklink_enc.cpp

index ac7964cd171eba58baa44e8b6b30d04d0c3b22ae..43599b6b2b6eeb1fa4af87523aa9ef2fb9d5f867 100644 (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();
+}
index dff4fc1cec669199fd1c2d9539b6991f54b90ac3..1a9feeba436358864a65cd1d6f90d4b141def8be 100644 (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 */
index 3b5d4be56a66c0f28ad873bc22d4cbb3ba72c290..8b57e0cd085ed5235b3234b4e06d2bcf78b05780 100644 (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);
 }
 
index 6c5450f4ec5f36d1b397737b5dde9063d5ec6acc..4d00a537ec14aacab420939abcf8ea9a8443a376 100644 (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);
 }