ext/: Big shout-out to MikeS for fixing this giant memory leak.
authorJan Schmidt <thaytan@mad.scientist.com>
Fri, 26 Aug 2005 10:50:56 +0000 (10:50 +0000)
committerJan Schmidt <thaytan@mad.scientist.com>
Fri, 26 Aug 2005 10:50:56 +0000 (10:50 +0000)
Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_dispose):
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(vorbisdec_finalize), (vorbis_handle_type_packet):
Big shout-out to MikeS for fixing this giant memory leak.
Huzzah!

ChangeLog
common
ext/ogg/gstoggdemux.c
ext/vorbis/vorbisdec.c

index c4a70a9..9b42d0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-08-26  Jan Schmidt  <thaytan@mad.scientist.com>
+
+       * ext/ogg/gstoggdemux.c: (gst_ogg_pad_dispose):
+       * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
+       (vorbisdec_finalize), (vorbis_handle_type_packet):
+         Big shout-out to MikeS for fixing this giant memory leak.
+         Huzzah!
+
 2005-08-25  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_dispose),
diff --git a/common b/common
index aa2a757..7c93670 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit aa2a757c587d91069a230d8e656481c3c364ccc6
+Subproject commit 7c93670c50de2b6e9d8edd31737c636192fbd831
index 273c47e..40cf3d7 100644 (file)
@@ -275,6 +275,9 @@ gst_ogg_pad_dispose (GObject * object)
 {
   GstOggPad *pad = GST_OGG_PAD (object);
 
+  if (pad->element)
+    gst_element_set_state (pad->element, GST_STATE_NULL);
+
   gst_object_replace ((GstObject **) (&pad->elem_pad), NULL);
   gst_object_replace ((GstObject **) (&pad->element), NULL);
   gst_object_replace ((GstObject **) (&pad->elem_out), NULL);
index 0944386..75f9d0a 100644 (file)
@@ -72,6 +72,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
 
 GST_BOILERPLATE (GstVorbisDec, gst_vorbis_dec, GstElement, GST_TYPE_ELEMENT);
 
+static void vorbisdec_finalize (GObject * object);
 static gboolean vorbis_dec_sink_event (GstPad * pad, GstEvent * event);
 static GstFlowReturn vorbis_dec_chain (GstPad * pad, GstBuffer * buffer);
 static GstElementStateReturn vorbis_dec_change_state (GstElement * element);
@@ -103,8 +104,11 @@ gst_vorbis_dec_base_init (gpointer g_class)
 static void
 gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
 {
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
 
+  gobject_class->finalize = vorbisdec_finalize;
+
   gstelement_class->change_state = vorbis_dec_change_state;
 }
 
@@ -175,6 +179,20 @@ gst_vorbis_dec_init (GstVorbisDec * dec)
   dec->queued = NULL;
 }
 
+static void
+vorbisdec_finalize (GObject * object)
+{
+  /* Release any possibly allocated libvorbis data. 
+   * _clear functions can safely be called multiple times
+   */
+  GstVorbisDec *vd = GST_VORBIS_DEC (object);
+
+  vorbis_block_clear (&vd->vb);
+  vorbis_dsp_clear (&vd->vd);
+  vorbis_comment_clear (&vd->vc);
+  vorbis_info_clear (&vd->vi);
+}
+
 static gboolean
 vorbis_dec_convert (GstPad * pad,
     GstFormat src_format, gint64 src_value,
@@ -598,6 +616,8 @@ vorbis_handle_comment_packet (GstVorbisDec * vd, ogg_packet * packet)
 static GstFlowReturn
 vorbis_handle_type_packet (GstVorbisDec * vd)
 {
+  g_assert (vd->initialized == FALSE);
+
   vorbis_synthesis_init (&vd->vd, &vd->vi);
   vorbis_block_init (&vd->vd, &vd->vb);
   vd->initialized = TRUE;