From de1357a4074d7cab9df163237bcfbce653d417e7 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 4 Mar 2007 13:52:03 +0000 Subject: [PATCH] Fix a bunch of leaks shown by the newly-added states test. Original commit message from CVS: * ext/flac/gstflacenc.c: (gst_flac_enc_finalize): * ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init), (gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize): * ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init), (gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose), (gst_gconf_audio_src_finalize), (do_toggle_element): * ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init), (gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize), (do_toggle_element): * ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init), (gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose), (gst_gconf_video_src_finalize), (do_toggle_element): * ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init), (gst_switch_sink_reset), (gst_switch_sink_set_child): * ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init): * ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init): * ext/shout2/gstshout2.c: (gst_shout2send_class_init), (gst_shout2send_init), (gst_shout2send_finalize): * gst/debug/testplugin.c: (gst_test_class_init), (gst_test_finalize): * gst/flx/gstflxdec.c: (gst_flxdec_class_init), (gst_flxdec_dispose): * gst/multipart/multipartmux.c: (gst_multipart_mux_finalize): * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize): * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init), (gst_rtspsrc_finalize): * gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context): * gst/rtsp/rtspextwms.h: * gst/smpte/gstsmpte.c: (gst_smpte_class_init), (gst_smpte_finalize): * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize): * gst/udp/gstudpsink.c: (gst_udpsink_class_init), (gst_udpsink_finalize): * gst/wavparse/gstwavparse.c: (gst_wavparse_dispose), (gst_wavparse_sink_activate): * sys/oss/gstosssink.c: (gst_oss_sink_finalise): * sys/oss/gstosssrc.c: (gst_oss_src_class_init), (gst_oss_src_finalize): * sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy): * sys/v4l2/gstv4l2object.h: * sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init), (gst_v4l2src_finalize): * sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get): Fix a bunch of leaks shown by the newly-added states test. --- ChangeLog | 48 +++++++++++++++++++++++++++++++++++++++++++ ext/flac/gstflacenc.c | 1 + ext/gconf/gstgconfaudiosink.c | 11 ++++++++-- ext/gconf/gstgconfaudiosrc.c | 14 ++++++++++--- ext/gconf/gstgconfvideosink.c | 13 +++++++++++- ext/gconf/gstgconfvideosrc.c | 25 +++++++++++++++++++--- ext/gconf/gstswitchsink.c | 5 +++-- ext/hal/gsthalaudiosink.c | 2 +- ext/hal/gsthalaudiosrc.c | 2 +- ext/shout2/gstshout2.c | 18 ++++++++++++++++ gst/debug/testplugin.c | 16 +++++++++++++++ gst/flx/gstflxdec.c | 14 +++++++++++++ gst/multipart/multipartmux.c | 6 +++--- gst/rtp/gstrtpmp4gpay.c | 3 +++ gst/rtsp/gstrtspsrc.c | 13 ++++++++++-- gst/rtsp/rtspextwms.c | 6 ++++++ gst/rtsp/rtspextwms.h | 1 + gst/smpte/gstsmpte.c | 12 +++++++++++ gst/udp/gstmultiudpsink.c | 5 +++++ gst/udp/gstudpsink.c | 11 ++++++++++ gst/wavparse/gstwavparse.c | 5 ++++- sys/oss/gstosssink.c | 2 ++ sys/oss/gstosssrc.c | 12 +++++++++++ sys/v4l2/gstv4l2object.c | 15 ++++++-------- sys/v4l2/gstv4l2object.h | 2 +- sys/v4l2/gstv4l2src.c | 9 ++++++++ sys/ximage/gstximagesrc.c | 4 +++- 27 files changed, 245 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index e019360..19b11ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,53 @@ 2007-03-04 Jan Schmidt + * ext/flac/gstflacenc.c: (gst_flac_enc_finalize): + * ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init), + (gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize): + * ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init), + (gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose), + (gst_gconf_audio_src_finalize), (do_toggle_element): + * ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init), + (gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize), + (do_toggle_element): + * ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init), + (gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose), + (gst_gconf_video_src_finalize), (do_toggle_element): + * ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init), + (gst_switch_sink_reset), (gst_switch_sink_set_child): + * ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init): + * ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init): + * ext/shout2/gstshout2.c: (gst_shout2send_class_init), + (gst_shout2send_init), (gst_shout2send_finalize): + * gst/debug/testplugin.c: (gst_test_class_init), + (gst_test_finalize): + * gst/flx/gstflxdec.c: (gst_flxdec_class_init), + (gst_flxdec_dispose): + * gst/multipart/multipartmux.c: (gst_multipart_mux_finalize): + * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize): + * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init), + (gst_rtspsrc_finalize): + * gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context): + * gst/rtsp/rtspextwms.h: + * gst/smpte/gstsmpte.c: (gst_smpte_class_init), + (gst_smpte_finalize): + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize): + * gst/udp/gstudpsink.c: (gst_udpsink_class_init), + (gst_udpsink_finalize): + * gst/wavparse/gstwavparse.c: (gst_wavparse_dispose), + (gst_wavparse_sink_activate): + * sys/oss/gstosssink.c: (gst_oss_sink_finalise): + * sys/oss/gstosssrc.c: (gst_oss_src_class_init), + (gst_oss_src_finalize): + * sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy): + * sys/v4l2/gstv4l2object.h: + * sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init), + (gst_v4l2src_finalize): + * sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get): + + Fix a bunch of leaks shown by the newly-added states test. + +2007-03-04 Jan Schmidt + * ext/dv/gstdvdec.c: (gst_dvdec_init): Use gst_pad_new_from_static_template instead of static_pad_template_get+pad_new. diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c index 90888fb..b257681 100644 --- a/ext/flac/gstflacenc.c +++ b/ext/flac/gstflacenc.c @@ -315,6 +315,7 @@ gst_flac_enc_finalize (GObject * object) { GstFlacEnc *flacenc = GST_FLAC_ENC (object); + gst_tag_list_free (flacenc->tags); FLAC__seekable_stream_encoder_delete (flacenc->encoder); G_OBJECT_CLASS (parent_class)->finalize (object); diff --git a/ext/gconf/gstgconfaudiosink.c b/ext/gconf/gstgconfaudiosink.c index 3ac1b89..0737af6 100644 --- a/ext/gconf/gstgconfaudiosink.c +++ b/ext/gconf/gstgconfaudiosink.c @@ -28,6 +28,7 @@ #include "gstgconfaudiosink.h" static void gst_gconf_audio_sink_dispose (GObject * object); +static void gst_gconf_audio_sink_finalize (GstGConfAudioSink * sink); static void cb_change_child (GConfClient * client, guint connection_id, GConfEntry * entry, gpointer data); static GstStateChangeReturn @@ -91,6 +92,7 @@ gst_gconf_audio_sink_class_init (GstGConfAudioSinkClass * klass) oklass->set_property = gst_gconf_audio_sink_set_property; oklass->get_property = gst_gconf_audio_sink_get_property; oklass->dispose = gst_gconf_audio_sink_dispose; + oklass->finalize = (GObjectFinalizeFunc) gst_gconf_audio_sink_finalize; eklass->change_state = gst_gconf_audio_sink_change_state; g_object_class_install_property (oklass, PROP_PROFILE, @@ -131,10 +133,15 @@ gst_gconf_audio_sink_dispose (GObject * object) sink->client = NULL; } + GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); +} + +static void +gst_gconf_audio_sink_finalize (GstGConfAudioSink * sink) +{ g_free (sink->gconf_str); - sink->gconf_str = NULL; - GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); + GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (sink))); } static gboolean diff --git a/ext/gconf/gstgconfaudiosrc.c b/ext/gconf/gstgconfaudiosrc.c index 0203c2e..b9379c4 100644 --- a/ext/gconf/gstgconfaudiosrc.c +++ b/ext/gconf/gstgconfaudiosrc.c @@ -28,6 +28,7 @@ #include "gstgconfaudiosrc.h" static void gst_gconf_audio_src_dispose (GObject * object); +static void gst_gconf_audio_src_finalize (GstGConfAudioSrc * src); static void cb_toggle_element (GConfClient * client, guint connection_id, GConfEntry * entry, gpointer data); static GstStateChangeReturn @@ -45,7 +46,7 @@ gst_gconf_audio_src_base_init (gpointer klass) "Source/Audio", "Audio source embedding the GConf-settings for audio input", "Ronald Bultje "); - GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); @@ -62,6 +63,7 @@ gst_gconf_audio_src_class_init (GstGConfAudioSrcClass * klass) GstElementClass *eklass = GST_ELEMENT_CLASS (klass); oklass->dispose = gst_gconf_audio_src_dispose; + oklass->finalize = (GObjectFinalizeFunc) gst_gconf_audio_src_finalize; eklass->change_state = gst_gconf_audio_src_change_state; } @@ -122,10 +124,15 @@ gst_gconf_audio_src_dispose (GObject * object) src->client = NULL; } + GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); +} + +static void +gst_gconf_audio_src_finalize (GstGConfAudioSrc * src) +{ g_free (src->gconf_str); - src->gconf_str = NULL; - GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); + GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (src))); } static gboolean @@ -151,6 +158,7 @@ do_toggle_element (GstGConfAudioSrc * src) if (cur >= GST_STATE_READY || next == GST_STATE_PAUSED) { GST_DEBUG_OBJECT (src, "already running, ignoring GConf change"); + g_free (new_gconf_str); return TRUE; } diff --git a/ext/gconf/gstgconfvideosink.c b/ext/gconf/gstgconfvideosink.c index ed37287..e22791d 100644 --- a/ext/gconf/gstgconfvideosink.c +++ b/ext/gconf/gstgconfvideosink.c @@ -27,6 +27,7 @@ #include "gstgconfvideosink.h" static void gst_gconf_video_sink_dispose (GObject * object); +static void gst_gconf_video_sink_finalize (GstGConfVideoSink * sink); static void cb_toggle_element (GConfClient * client, guint connection_id, GConfEntry * entry, gpointer data); static GstStateChangeReturn @@ -44,7 +45,7 @@ gst_gconf_video_sink_base_init (gpointer klass) "Sink/Video", "Video sink embedding the GConf-settings for video output", "Ronald Bultje "); - GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); @@ -61,6 +62,7 @@ gst_gconf_video_sink_class_init (GstGConfVideoSinkClass * klass) GstElementClass *eklass = GST_ELEMENT_CLASS (klass); oklass->dispose = gst_gconf_video_sink_dispose; + oklass->finalize = (GObjectFinalizeFunc) gst_gconf_video_sink_finalize; eklass->change_state = gst_gconf_video_sink_change_state; } @@ -121,6 +123,14 @@ gst_gconf_video_sink_dispose (GObject * object) GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); } +static void +gst_gconf_video_sink_finalize (GstGConfVideoSink * sink) +{ + g_free (sink->gconf_str); + + GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (sink))); +} + static gboolean do_toggle_element (GstGConfVideoSink * sink) { @@ -148,6 +158,7 @@ do_toggle_element (GstGConfVideoSink * sink) if (cur > GST_STATE_READY || next == GST_STATE_PAUSED) { GST_DEBUG_OBJECT (sink, "Auto-sink is already running. Ignoring GConf change"); + g_free (new_gconf_str); return TRUE; } diff --git a/ext/gconf/gstgconfvideosrc.c b/ext/gconf/gstgconfvideosrc.c index 093545e..2735a90 100644 --- a/ext/gconf/gstgconfvideosrc.c +++ b/ext/gconf/gstgconfvideosrc.c @@ -28,6 +28,7 @@ #include "gstgconfvideosrc.h" static void gst_gconf_video_src_dispose (GObject * object); +static void gst_gconf_video_src_finalize (GstGConfVideoSrc * src); static void cb_toggle_element (GConfClient * client, guint connection_id, GConfEntry * entry, gpointer data); static GstStateChangeReturn @@ -45,7 +46,7 @@ gst_gconf_video_src_base_init (gpointer klass) "Source/Video", "Video source embedding the GConf-settings for video input", "Ronald Bultje "); - GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); @@ -62,6 +63,7 @@ gst_gconf_video_src_class_init (GstGConfVideoSrcClass * klass) GstElementClass *eklass = GST_ELEMENT_CLASS (klass); oklass->dispose = gst_gconf_video_src_dispose; + oklass->finalize = (GObjectFinalizeFunc) gst_gconf_video_src_finalize; eklass->change_state = gst_gconf_video_src_change_state; } @@ -117,10 +119,15 @@ gst_gconf_video_src_dispose (GObject * object) src->client = NULL; } + GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); +} + +static void +gst_gconf_video_src_finalize (GstGConfVideoSrc * src) +{ g_free (src->gconf_str); - src->gconf_str = NULL; - GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); + GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (src))); } static gboolean @@ -128,6 +135,7 @@ do_toggle_element (GstGConfVideoSrc * src) { GstPad *targetpad; gchar *new_gconf_str; + GstState cur, next; new_gconf_str = gst_gconf_get_string (GST_GCONF_AUDIOSRC_KEY); if (new_gconf_str != NULL && src->gconf_str != NULL && @@ -138,6 +146,17 @@ do_toggle_element (GstGConfVideoSrc * src) return TRUE; } + GST_OBJECT_LOCK (src); + cur = GST_STATE (src); + next = GST_STATE_PENDING (src); + GST_OBJECT_UNLOCK (src); + + if (cur >= GST_STATE_READY || next == GST_STATE_PAUSED) { + GST_DEBUG_OBJECT (src, "already running, ignoring GConf change"); + g_free (new_gconf_str); + return TRUE; + } + g_free (src->gconf_str); src->gconf_str = new_gconf_str; diff --git a/ext/gconf/gstswitchsink.c b/ext/gconf/gstswitchsink.c index d00336e..9c09170 100644 --- a/ext/gconf/gstswitchsink.c +++ b/ext/gconf/gstswitchsink.c @@ -57,7 +57,7 @@ gst_switch_sink_class_init (GstSwitchSinkClass * klass) { GObjectClass *oklass = G_OBJECT_CLASS (klass); GstElementClass *eklass = GST_ELEMENT_CLASS (klass); - GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); @@ -79,7 +79,7 @@ gst_switch_sink_class_init (GstSwitchSinkClass * klass) static void gst_switch_sink_reset (GstSwitchSink * sink) { - /* fakesink */ + /* this will install fakesink if no other child has been set */ if (sink->kid == NULL) { gst_switch_sink_set_child (sink, NULL); } @@ -189,6 +189,7 @@ gst_switch_sink_set_child (GstSwitchSink * sink, GstElement * new_kid) if (cur == GST_STATE_PAUSED && next == GST_STATE_READY) { return gst_switch_commit_new_kid (sink); } + /* Sometime, it would be lovely to allow sink changes even when * already running, but this involves sending an appropriate new-segment * and possibly prerolling etc */ diff --git a/ext/hal/gsthalaudiosink.c b/ext/hal/gsthalaudiosink.c index 215926b..582e15a 100644 --- a/ext/hal/gsthalaudiosink.c +++ b/ext/hal/gsthalaudiosink.c @@ -79,7 +79,7 @@ gst_hal_audio_sink_base_init (gpointer klass) "Sink/Audio", "Audio sink for sound device access via HAL", "Jürg Billeter "); - GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); diff --git a/ext/hal/gsthalaudiosrc.c b/ext/hal/gsthalaudiosrc.c index b745bef..ebd4470 100644 --- a/ext/hal/gsthalaudiosrc.c +++ b/ext/hal/gsthalaudiosrc.c @@ -81,7 +81,7 @@ gst_hal_audio_src_base_init (gpointer klass) "Source/Audio", "Audio source for sound device access via HAL", "Jürg Billeter "); - GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); diff --git a/ext/shout2/gstshout2.c b/ext/shout2/gstshout2.c index 68f581d..1285ced 100644 --- a/ext/shout2/gstshout2.c +++ b/ext/shout2/gstshout2.c @@ -86,6 +86,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", static void gst_shout2send_class_init (GstShout2sendClass * klass); static void gst_shout2send_base_init (GstShout2sendClass * klass); static void gst_shout2send_init (GstShout2send * shout2send); +static void gst_shout2send_finalize (GstShout2send * shout2send); static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event); static GstFlowReturn gst_shout2send_render (GstBaseSink * sink, @@ -184,6 +185,7 @@ gst_shout2send_class_init (GstShout2sendClass * klass) gobject_class->set_property = gst_shout2send_set_property; gobject_class->get_property = gst_shout2send_get_property; + gobject_class->finalize = (GObjectFinalizeFunc) gst_shout2send_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP, g_param_spec_string ("ip", "ip", "ip", DEFAULT_IP, G_PARAM_READWRITE)); @@ -265,7 +267,23 @@ gst_shout2send_init (GstShout2send * shout2send) shout2send->songmetadata = NULL; shout2send->songartist = NULL; shout2send->songtitle = NULL; +} +static void +gst_shout2send_finalize (GstShout2send * shout2send) +{ + g_free (shout2send->ip); + g_free (shout2send->password); + g_free (shout2send->username); + g_free (shout2send->streamname); + g_free (shout2send->description); + g_free (shout2send->genre); + g_free (shout2send->mount); + g_free (shout2send->url); + + gst_tag_list_free (shout2send->tags); + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send)); } static void diff --git a/gst/debug/testplugin.c b/gst/debug/testplugin.c index 5d1dba5..c521c44 100644 --- a/gst/debug/testplugin.c +++ b/gst/debug/testplugin.c @@ -62,6 +62,8 @@ struct _GstTestClass gchar *param_names[2 * TESTS_COUNT]; }; +static void gst_test_finalize (GstTest * test); + static gboolean gst_test_start (GstBaseSink * trans); static gboolean gst_test_stop (GstBaseSink * trans); static gboolean gst_test_sink_event (GstBaseSink * basesink, GstEvent * event); @@ -107,6 +109,8 @@ gst_test_class_init (GstTestClass * klass) object_class->set_property = GST_DEBUG_FUNCPTR (gst_test_set_property); object_class->get_property = GST_DEBUG_FUNCPTR (gst_test_get_property); + object_class->finalize = (GObjectFinalizeFunc) gst_test_finalize; + for (i = 0; i < TESTS_COUNT; i++) { GParamSpec *spec; @@ -141,6 +145,18 @@ gst_test_init (GstTest * test, GstTestClass * g_class) } static void +gst_test_finalize (GstTest * test) +{ + guint i; + + for (i = 0; i < TESTS_COUNT; i++) { + g_value_unset (&test->values[i]); + } + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) test); +} + +static void tests_unset (GstTest * test) { guint i; diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c index ec7f198..6f9cb7f 100644 --- a/gst/flx/gstflxdec.c +++ b/gst/flx/gstflxdec.c @@ -68,6 +68,7 @@ static GstStaticPadTemplate src_video_factory = GST_STATIC_PAD_TEMPLATE ("src", static void gst_flxdec_class_init (GstFlxDecClass * klass); static void gst_flxdec_base_init (GstFlxDecClass * klass); static void gst_flxdec_init (GstFlxDec * flxdec); +static void gst_flxdec_dispose (GstFlxDec * flxdec); static GstFlowReturn gst_flxdec_chain (GstPad * pad, GstBuffer * buf); @@ -134,6 +135,8 @@ gst_flxdec_class_init (GstFlxDecClass * klass) parent_class = g_type_class_peek_parent (klass); + gobject_class->dispose = (GObjectFinalizeFunc) gst_flxdec_dispose; + GST_DEBUG_CATEGORY_INIT (flxdec_debug, "flxdec", 0, "FLX video decoder"); gstelement_class->change_state = gst_flxdec_change_state; @@ -160,6 +163,17 @@ gst_flxdec_init (GstFlxDec * flxdec) flxdec->adapter = gst_adapter_new (); } +static void +gst_flxdec_dispose (GstFlxDec * flxdec) +{ + if (flxdec->adapter) { + g_object_unref (flxdec->adapter); + flxdec->adapter = NULL; + } + + G_OBJECT_CLASS (parent_class)->dispose ((GObject *) flxdec); +} + static gboolean gst_flxdec_src_query_handler (GstPad * pad, GstQuery * query) { diff --git a/gst/multipart/multipartmux.c b/gst/multipart/multipartmux.c index e87d42a..ba9d1c0 100644 --- a/gst/multipart/multipartmux.c +++ b/gst/multipart/multipartmux.c @@ -240,10 +240,10 @@ gst_multipart_mux_finalize (GObject * object) multipart_mux = GST_MULTIPART_MUX (object); - if (multipart_mux->collect) { + g_free (multipart_mux->boundary); + + if (multipart_mux->collect) gst_object_unref (multipart_mux->collect); - multipart_mux->collect = NULL; - } G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/gst/rtp/gstrtpmp4gpay.c b/gst/rtp/gstrtpmp4gpay.c index 1c0ba5d..3220728 100644 --- a/gst/rtp/gstrtpmp4gpay.c +++ b/gst/rtp/gstrtpmp4gpay.c @@ -184,6 +184,9 @@ gst_rtp_mp4g_pay_finalize (GObject * object) g_free (rtpmp4gpay->params); rtpmp4gpay->params = NULL; + g_free (rtpmp4gpay->profile); + rtpmp4gpay->profile = NULL; + G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 9e9aa1a..cb27035 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -288,10 +288,11 @@ gst_rtspsrc_init (GstRTSPSrc * src, GstRTSPSrcClass * g_class) src->location = g_strdup (DEFAULT_LOCATION); src->url = NULL; - /* install WMS extension by default */ - src->extension = rtsp_ext_wms_get_context (); #ifdef WITH_EXT_REAL src->extension = rtsp_ext_real_get_context (); +#else + /* install WMS extension by default */ + src->extension = rtsp_ext_wms_get_context (); #endif src->extension->src = (gpointer) src; } @@ -311,6 +312,14 @@ gst_rtspsrc_finalize (GObject * object) g_free (rtspsrc->content_base); rtsp_url_free (rtspsrc->url); + if (rtspsrc->extension) { +#ifdef WITH_EXT_REAL + rtsp_ext_real_free_context (rtspsrc->extension); +#else + rtsp_ext_wms_free_context (rtspsrc->extension); +#endif + } + G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/gst/rtsp/rtspextwms.c b/gst/rtsp/rtspextwms.c index 2f1fbda..30e2136 100644 --- a/gst/rtsp/rtspextwms.c +++ b/gst/rtsp/rtspextwms.c @@ -178,3 +178,9 @@ rtsp_ext_wms_get_context (void) return (RTSPExtensionCtx *) res; } + +void +rtsp_ext_wms_free_context (RTSPExtensionCtx * ctx) +{ + g_free (ctx); +} diff --git a/gst/rtsp/rtspextwms.h b/gst/rtsp/rtspextwms.h index 48f1447..3dcd65a 100644 --- a/gst/rtsp/rtspextwms.h +++ b/gst/rtsp/rtspextwms.h @@ -50,6 +50,7 @@ G_BEGIN_DECLS #include "rtspext.h" RTSPExtensionCtx* rtsp_ext_wms_get_context (void); +void rtsp_ext_wms_free_context (RTSPExtensionCtx *ctx); G_END_DECLS diff --git a/gst/smpte/gstsmpte.c b/gst/smpte/gstsmpte.c index 44420ac..5d3101c 100644 --- a/gst/smpte/gstsmpte.c +++ b/gst/smpte/gstsmpte.c @@ -163,6 +163,7 @@ gst_smpte_transition_type_get_type (void) static void gst_smpte_class_init (GstSMPTEClass * klass); static void gst_smpte_base_init (GstSMPTEClass * klass); static void gst_smpte_init (GstSMPTE * smpte); +static void gst_smpte_finalize (GstSMPTE * smpte); static GstFlowReturn gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte); @@ -230,6 +231,7 @@ gst_smpte_class_init (GstSMPTEClass * klass) gobject_class->set_property = gst_smpte_set_property; gobject_class->get_property = gst_smpte_get_property; + gobject_class->finalize = (GObjectFinalizeFunc) gst_smpte_finalize; _gst_mask_init (); @@ -380,6 +382,16 @@ gst_smpte_init (GstSMPTE * smpte) } static void +gst_smpte_finalize (GstSMPTE * smpte) +{ + if (smpte->collect) { + gst_object_unref (smpte->collect); + } + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) smpte); +} + +static void gst_smpte_reset (GstSMPTE * smpte) { smpte->width = -1; diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c index 670162c..bcafd95 100644 --- a/gst/udp/gstmultiudpsink.c +++ b/gst/udp/gstmultiudpsink.c @@ -92,6 +92,8 @@ static void gst_multiudpsink_set_property (GObject * object, guint prop_id, static void gst_multiudpsink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static void free_client (GstUDPClient * client); + static GstElementClass *parent_class = NULL; static guint gst_multiudpsink_signals[LAST_SIGNAL] = { 0 }; @@ -269,6 +271,9 @@ gst_multiudpsink_finalize (GObject * object) sink = GST_MULTIUDPSINK (object); + g_list_foreach (sink->clients, (GFunc) free_client, NULL); + g_list_free (sink->clients); + g_mutex_free (sink->client_lock); WSA_CLEANUP (object); diff --git a/gst/udp/gstudpsink.c b/gst/udp/gstudpsink.c index f647e60..583827d 100644 --- a/gst/udp/gstudpsink.c +++ b/gst/udp/gstudpsink.c @@ -51,6 +51,7 @@ enum static void gst_udpsink_base_init (gpointer g_class); static void gst_udpsink_class_init (GstUDPSink * klass); static void gst_udpsink_init (GstUDPSink * udpsink); +static void gst_udpsink_finalize (GstUDPSink * udpsink); static void gst_udpsink_uri_handler_init (gpointer g_iface, gpointer iface_data); @@ -123,6 +124,8 @@ gst_udpsink_class_init (GstUDPSink * klass) gobject_class->set_property = gst_udpsink_set_property; gobject_class->get_property = gst_udpsink_get_property; + gobject_class->finalize = (GObjectFinalizeFunc) gst_udpsink_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HOST, g_param_spec_string ("host", "host", "The host/IP/Multicast group to send the packets to", @@ -142,6 +145,14 @@ gst_udpsink_init (GstUDPSink * udpsink) udpsink->port); } +static void +gst_udpsink_finalize (GstUDPSink * udpsink) +{ + g_free (udpsink->host); + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) udpsink); +} + static gboolean gst_udpsink_set_uri (GstUDPSink * sink, const gchar * uri) { diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index ade334a..00da901 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -182,7 +182,7 @@ gst_wavparse_dispose (GObject * object) { GstWavParse *wav; - GST_DEBUG ("WAV: Dispose\n"); + GST_DEBUG ("WAV: Dispose"); wav = GST_WAVPARSE (object); if (wav->adapter) { @@ -1957,6 +1957,9 @@ gst_wavparse_sink_activate (GstPad * sinkpad) GstWavParse *wav = GST_WAVPARSE (gst_pad_get_parent (sinkpad)); gboolean res; + if (wav->adapter) + gst_object_unref (wav->adapter); + if (gst_pad_check_pull_range (sinkpad)) { GST_DEBUG ("going to pull mode"); wav->streaming = FALSE; diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c index 1351d1b..9f2a7ea 100644 --- a/sys/oss/gstosssink.c +++ b/sys/oss/gstosssink.c @@ -247,6 +247,8 @@ gst_oss_sink_finalise (GObject * object) GstOssSink *osssink = GST_OSSSINK (object); g_free (osssink->device); + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (object)); } static void diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c index 26eb6c6..34d901a 100644 --- a/sys/oss/gstosssrc.c +++ b/sys/oss/gstosssrc.c @@ -97,6 +97,7 @@ static void gst_oss_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_oss_src_dispose (GObject * object); +static void gst_oss_src_finalize (GstOssSrc * osssrc); static GstCaps *gst_oss_src_getcaps (GstBaseSrc * bsrc); @@ -160,6 +161,8 @@ gst_oss_src_class_init (GstOssSrcClass * klass) gstaudiosrc_class = (GstAudioSrcClass *) klass; gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_oss_src_dispose); + gobject_class->finalize = + (GObjectFinalizeFunc) GST_DEBUG_FUNCPTR (gst_oss_src_finalize); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_oss_src_get_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_oss_src_set_property); @@ -234,6 +237,15 @@ gst_oss_src_init (GstOssSrc * osssrc, GstOssSrcClass * g_class) osssrc->device_name = g_strdup (DEFAULT_DEVICE_NAME); } +static void +gst_oss_src_finalize (GstOssSrc * osssrc) +{ + g_free (osssrc->device); + g_free (osssrc->device_name); + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (osssrc)); +} + static GstCaps * gst_oss_src_getcaps (GstBaseSrc * bsrc) { diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 48497fc..c842e8b 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -278,17 +278,14 @@ gst_v4l2_object_new (GstElement * element, } void -gst_v4l2_object_destroy (GstV4l2Object ** v4l2object) +gst_v4l2_object_destroy (GstV4l2Object * v4l2object) { - if (*v4l2object) { - if ((*v4l2object)->videodev) { - g_free ((*v4l2object)->videodev); - (*v4l2object)->videodev = NULL; - } + g_return_if_fail (v4l2object != NULL); - g_free (*v4l2object); - *v4l2object = NULL; - } + if (v4l2object->videodev) + g_free (v4l2object->videodev); + + g_free (v4l2object); } gboolean diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index 906cff9..f309bc7 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -117,7 +117,7 @@ GstV4l2Object * gst_v4l2_object_new (GstElement * element, GstV4l2GetInOutFunction get_in_out_func, GstV4l2SetInOutFunction set_in_out_func, GstV4l2UpdateFpsFunction update_fps_func); -void gst_v4l2_object_destroy (GstV4l2Object ** v4l2object); +void gst_v4l2_object_destroy (GstV4l2Object * v4l2object); /* properties */ void gst_v4l2_object_install_properties_helper (GObjectClass *gobject_class); diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 4aeb6f1..cddad93 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -223,6 +223,7 @@ GST_BOILERPLATE_FULL (GstV4l2Src, gst_v4l2src, GstPushSrc, GST_TYPE_PUSH_SRC, gst_v4l2src_init_interfaces); static void gst_v4l2src_dispose (GObject * object); +static void gst_v4l2src_finalize (GstV4l2Src * v4l2src); /* basesrc methods */ static gboolean gst_v4l2src_start (GstBaseSrc * src); @@ -270,6 +271,7 @@ gst_v4l2src_class_init (GstV4l2SrcClass * klass) pushsrc_class = GST_PUSH_SRC_CLASS (klass); gobject_class->dispose = gst_v4l2src_dispose; + gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2src_finalize; gobject_class->set_property = gst_v4l2src_set_property; gobject_class->get_property = gst_v4l2src_get_property; @@ -325,6 +327,13 @@ gst_v4l2src_dispose (GObject * object) G_OBJECT_CLASS (parent_class)->dispose (object); } +static void +gst_v4l2src_finalize (GstV4l2Src * v4l2src) +{ + gst_v4l2_object_destroy (v4l2src->v4l2object); + + G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (v4l2src)); +} static void gst_v4l2src_set_property (GObject * object, diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c index ba4d52f..d695837 100644 --- a/sys/ximage/gstximagesrc.c +++ b/sys/ximage/gstximagesrc.c @@ -339,7 +339,6 @@ static GstXImageSrcBuffer * gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc) { GstXImageSrcBuffer *ximage = NULL; - GstCaps *caps = NULL; g_mutex_lock (ximagesrc->pool_lock); while (ximagesrc->buffer_pool != NULL) { @@ -357,6 +356,7 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc) if (ximage == NULL) { GstXContext *xcontext; + GstCaps *caps = NULL; GST_DEBUG_OBJECT (ximagesrc, "creating image (%dx%d)", ximagesrc->width, ximagesrc->height); @@ -391,6 +391,8 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc) gst_buffer_set_caps (GST_BUFFER (ximage), caps); g_mutex_unlock (ximagesrc->x_lock); + + gst_caps_unref (caps); } g_return_val_if_fail (GST_IS_XIMAGE_SRC (ximagesrc), NULL); -- 2.7.4