summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVineeth TM <vineeth.tm@samsung.com>2015-10-05 13:10:56 +0900
committerSebastian Dröge <sebastian@centricular.com>2015-10-07 19:02:09 +0100
commit92dc815d0418ffd431be9fb589eb9a31e4b8fea1 (patch)
treedadd4539030c9e92c08758d7d5813eccc4a20447
parent83644e559d1657122d6050dd2532479b88b0a9f0 (diff)
downloadgstreamer-plugins-good-92dc815d0418ffd431be9fb589eb9a31e4b8fea1.tar.gz
cutter: Fix buffer leak
Buffer is added to the internal cache, and pushed only when accumulated buffer duration crosses 200 ms. So when the chain ends, the buffer accumulated is not freed. Freeing the cache when the state changes from PAUSED to READY. https://bugzilla.gnome.org/show_bug.cgi?id=754212
-rw-r--r--gst/cutter/gstcutter.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gst/cutter/gstcutter.c b/gst/cutter/gstcutter.c
index d643de1f2..6d41ef739 100644
--- a/gst/cutter/gstcutter.c
+++ b/gst/cutter/gstcutter.c
@@ -97,6 +97,9 @@ enum
#define gst_cutter_parent_class parent_class
G_DEFINE_TYPE (GstCutter, gst_cutter, GST_TYPE_ELEMENT);
+static GstStateChangeReturn
+gst_cutter_change_state (GstElement * element, GstStateChange transition);
+
static void gst_cutter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_cutter_get_property (GObject * object, guint prop_id,
@@ -152,6 +155,7 @@ gst_cutter_class_init (GstCutterClass * klass)
"Filter/Editor/Audio",
"Audio Cutter to split audio into non-silent bits",
"Thomas Vander Stichele <thomas at apestaart dot org>");
+ element_class->change_state = gst_cutter_change_state;
}
static void
@@ -236,6 +240,25 @@ gst_cutter_setcaps (GstCutter * filter, GstCaps * caps)
return gst_pad_set_caps (filter->srcpad, caps);
}
+static GstStateChangeReturn
+gst_cutter_change_state (GstElement * element, GstStateChange transition)
+{
+ GstStateChangeReturn ret;
+ GstCutter *filter = GST_CUTTER (element);
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ g_list_free_full (filter->pre_buffer, (GDestroyNotify) gst_buffer_unref);
+ filter->pre_buffer = NULL;
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
static gboolean
gst_cutter_event (GstPad * pad, GstObject * parent, GstEvent * event)
{