summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2019-03-06 18:32:38 +0000
committerTim-Philipp Müller <tim@centricular.com>2019-03-08 01:18:39 +0000
commit6dad8b7c787c1d57e944cec681dfccf22b37fc90 (patch)
tree0caf4ced25094cbf3b4dab1c82f5f63871b776ce
parent2ab238a4d06e8e20f739d770a8ad5973d00eff0a (diff)
closedcaption: fix leak in line21 decoder
Destroy old decoder instance when shutting down the element, and also in case the input format changes. Fix harness/pipeline leak in unit test.
-rw-r--r--ext/closedcaption/gstline21dec.c17
-rw-r--r--tests/check/elements/line21.c1
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/closedcaption/gstline21dec.c b/ext/closedcaption/gstline21dec.c
index b3c93cbaf..a7f91d893 100644
--- a/ext/closedcaption/gstline21dec.c
+++ b/ext/closedcaption/gstline21dec.c
@@ -53,6 +53,7 @@ G_DEFINE_TYPE (GstLine21Decoder, gst_line_21_decoder, GST_TYPE_VIDEO_FILTER);
#define parent_class gst_line_21_decoder_parent_class
static void gst_line_21_decoder_finalize (GObject * self);
+static gboolean gst_line_21_decoder_stop (GstBaseTransform * btrans);
static gboolean gst_line_21_decoder_set_info (GstVideoFilter * filter,
GstCaps * incaps, GstVideoInfo * in_info,
GstCaps * outcaps, GstVideoInfo * out_info);
@@ -85,6 +86,7 @@ gst_line_21_decoder_class_init (GstLine21DecoderClass * klass)
gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
+ transform_class->stop = gst_line_21_decoder_stop;
transform_class->prepare_output_buffer =
gst_line_21_decoder_prepare_output_buffer;
@@ -202,7 +204,10 @@ gst_line_21_decoder_set_info (GstVideoFilter * filter,
self->info = gst_video_info_copy (in_info);
/* initialize the decoder */
- vbi_raw_decoder_init (&self->zvbi_decoder);
+ if (self->zvbi_decoder.pattern != NULL)
+ vbi_raw_decoder_reset (&self->zvbi_decoder);
+ else
+ vbi_raw_decoder_init (&self->zvbi_decoder);
/*
* Set up blank / black / white levels fit for NTSC, no actual relation
* with the height of the video
@@ -415,6 +420,16 @@ gst_line_21_decoder_transform_ip (GstVideoFilter * filter,
return GST_FLOW_OK;
}
+static gboolean
+gst_line_21_decoder_stop (GstBaseTransform * btrans)
+{
+ GstLine21Decoder *self = (GstLine21Decoder *) btrans;
+
+ vbi_raw_decoder_destroy (&self->zvbi_decoder);
+
+ return TRUE;
+}
+
static void
gst_line_21_decoder_finalize (GObject * object)
{
diff --git a/tests/check/elements/line21.c b/tests/check/elements/line21.c
index 029ff238f..02547ec5a 100644
--- a/tests/check/elements/line21.c
+++ b/tests/check/elements/line21.c
@@ -83,6 +83,7 @@ GST_START_TEST (basic)
fail_unless (out_cc_meta->data[i] == full_data[i]);
gst_buffer_unref (outbuf);
+ gst_harness_teardown (h);
}
GST_END_TEST;