From 5a5228a25a1badc99f74f1c123c70996cf9829b0 Mon Sep 17 00:00:00 2001 From: Kishore Arepalli Date: Thu, 17 Oct 2013 15:16:00 +0200 Subject: [PATCH] ges: Fix several memory leaks https://bugzilla.gnome.org/show_bug.cgi?id=710390 --- ges/ges-audio-source.c | 1 + ges/ges-image-source.c | 7 +++---- ges/ges-pipeline.c | 1 + ges/ges-smart-adder.c | 5 ++++- ges/ges-smart-video-mixer.c | 6 ++++-- ges/ges-source.c | 3 +++ ges/ges-title-source.c | 6 ++++-- ges/ges-track.c | 7 +++++++ ges/ges-video-track.c | 2 ++ 9 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ges/ges-audio-source.c b/ges/ges-audio-source.c index bf69baa7ce..68a73fb663 100644 --- a/ges/ges-audio-source.c +++ b/ges/ges-audio-source.c @@ -88,6 +88,7 @@ ges_audio_source_create_element (GESTrackElement * trksrc) _sync_element_to_layer_property_float (trksrc, volume, GES_META_VOLUME, "volume"); ges_track_element_add_children_props (trksrc, volume, NULL, NULL, props); + gst_object_unref (volume); return topbin; } diff --git a/ges/ges-image-source.c b/ges/ges-image-source.c index 7d8cb4a566..7f045528e7 100644 --- a/ges/ges-image-source.c +++ b/ges/ges-image-source.c @@ -98,12 +98,11 @@ pad_added_cb (GstElement * timeline, GstPad * pad, GstElement * scale) GST_DEBUG ("got sink pad, trying to link"); ret = gst_pad_link (pad, sinkpad); - if GST_PAD_LINK_SUCCESSFUL - (ret) { + gst_object_unref (sinkpad); + if (GST_PAD_LINK_SUCCESSFUL (ret)) { GST_DEBUG ("linked ok, returning"); - gst_object_unref (sinkpad); return; - } + } } GST_DEBUG ("pad failed to link properly"); diff --git a/ges/ges-pipeline.c b/ges/ges-pipeline.c index 7405d73591..f163f8c9cf 100644 --- a/ges/ges-pipeline.c +++ b/ges/ges-pipeline.c @@ -733,6 +733,7 @@ pad_removed_cb (GstElement * timeline, GstPad * pad, GESPipeline * self) gst_object_unref (peer); gst_element_release_request_pad (self->priv->encodebin, chain->encodebinpad); + gst_object_unref (chain->encodebinpad); } /* Unlink playsink */ diff --git a/ges/ges-smart-adder.c b/ges/ges-smart-adder.c index a1b2c24aee..0e479524fa 100644 --- a/ges/ges-smart-adder.c +++ b/ges/ges-smart-adder.c @@ -63,8 +63,10 @@ destroy_pad (PadInfos * infos) gst_bin_remove (GST_BIN (infos->self), infos->bin); } - if (infos->adder_pad) + if (infos->adder_pad) { gst_element_release_request_pad (infos->self->adder, infos->adder_pad); + gst_object_unref (infos->adder_pad); + } g_slice_free (PadInfos, infos); } @@ -191,6 +193,7 @@ ges_smart_adder_init (GESSmartAdder * self) pad = gst_element_get_static_pad (self->adder, "src"); self->srcpad = gst_ghost_pad_new ("src", pad); gst_pad_set_active (self->srcpad, TRUE); + gst_object_unref (pad); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); diff --git a/ges/ges-smart-video-mixer.c b/ges/ges-smart-video-mixer.c index a318843e2f..d38ff6fa8f 100644 --- a/ges/ges-smart-video-mixer.c +++ b/ges/ges-smart-video-mixer.c @@ -59,8 +59,10 @@ destroy_pad (PadInfos * infos) gst_bin_remove (GST_BIN (infos->self), infos->bin); } - if (infos->mixer_pad) + if (infos->mixer_pad) { gst_element_release_request_pad (infos->self->mixer, infos->mixer_pad); + gst_object_unref (infos->mixer_pad); + } g_slice_free (PadInfos, infos); } @@ -216,7 +218,7 @@ ges_smart_mixer_init (GESSmartMixer * self) pad = gst_element_get_static_pad (self->mixer, "src"); self->srcpad = gst_ghost_pad_new ("src", pad); gst_pad_set_active (self->srcpad, TRUE); - + gst_object_unref (pad); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); self->pads_infos = g_hash_table_new_full (g_direct_hash, g_direct_equal, diff --git a/ges/ges-source.c b/ges/ges-source.c index 52627ddf50..b00f9bea23 100644 --- a/ges/ges-source.c +++ b/ges/ges-source.c @@ -116,6 +116,9 @@ ges_source_create_topbin (const gchar * bin_name, GstElement * sub_element, ...) G_CALLBACK (_ghost_pad_added_cb), bin); } + if (sub_srcpad) + gst_object_unref (sub_srcpad); + return bin; } diff --git a/ges/ges-title-source.c b/ges/ges-title-source.c index ef0def57b3..f481fbabc9 100644 --- a/ges/ges-title-source.c +++ b/ges/ges-title-source.c @@ -144,7 +144,7 @@ ges_title_source_create_source (GESTrackElement * object) GESTitleSource *self = GES_TITLE_SOURCE (object); GESTitleSourcePrivate *priv = self->priv; GstElement *topbin, *background, *text; - GstPad *src; + GstPad *src, *pad; topbin = gst_bin_new ("titlesrc-bin"); background = gst_element_factory_make ("videotestsrc", "titlesrc-bg"); @@ -172,7 +172,9 @@ ges_title_source_create_source (GESTrackElement * object) gst_element_link_pads_full (background, "src", text, "video_sink", GST_PAD_LINK_CHECK_NOTHING); - src = gst_ghost_pad_new ("src", gst_element_get_static_pad (text, "src")); + pad = gst_element_get_static_pad (text, "src"); + src = gst_ghost_pad_new ("src", pad); + gst_object_unref (pad); gst_element_add_pad (topbin, src); gst_object_ref (text); diff --git a/ges/ges-track.c b/ges/ges-track.c index e9fd3f4633..89be9a9c9d 100644 --- a/ges/ges-track.c +++ b/ges/ges-track.c @@ -265,10 +265,12 @@ pad_added_cb (GstElement * element, GstPad * pad, GESTrack * track) GST_DEBUG ("track:%p, pad %s:%s", track, GST_DEBUG_PAD_NAME (pad)); gst_pad_link (pad, capsfilter_sink); + gst_object_unref (capsfilter_sink); capsfilter_src = gst_element_get_static_pad (priv->capsfilter, "src"); /* ghost the pad */ priv->srcpad = gst_ghost_pad_new ("src", capsfilter_src); + gst_object_unref (capsfilter_src); gst_pad_set_active (priv->srcpad, TRUE); gst_element_add_pad (GST_ELEMENT (track), priv->srcpad); @@ -423,6 +425,9 @@ ges_track_dispose (GObject * object) g_sequence_free (priv->trackelements_by_start); g_list_free_full (priv->gaps, (GDestroyNotify) free_gap); + if (priv->mixing_operation) + gst_object_unref (priv->mixing_operation); + if (priv->composition) { gst_bin_remove (GST_BIN (object), priv->composition); priv->composition = NULL; @@ -758,6 +763,8 @@ ges_track_set_mixing (GESTrack * track, gboolean mixing) } if (mixing) { + // increase ref count to hold the object + gst_object_ref (track->priv->mixing_operation); if (!gst_bin_add (GST_BIN (track->priv->composition), track->priv->mixing_operation)) { GST_WARNING_OBJECT (track, "Could not add the mixer to our composition"); diff --git a/ges/ges-video-track.c b/ges/ges-video-track.c index dc08b6de8f..22d0859b02 100644 --- a/ges/ges-video-track.c +++ b/ges/ges-video-track.c @@ -90,6 +90,8 @@ create_element_for_raw_video_gap (GESTrack * track) _sync_capsfilter_with_track (track, capsfilter); + gst_object_unref (capsfilter); + return bin; }