summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarri Mähönen <harri.mahonen@gmail.com>2010-11-17 10:14:59 +0200
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-11-18 00:11:41 +0000
commit7c5e39664e68700d8895c1873c2a070d1bde3ff8 (patch)
tree1c24bc7670d6a1504e6bae5235d9b2699d88696d
parent8f039997f097ac5baa6a59350b2d41942a13232e (diff)
*decodebin*: don't leak pad templates set on ghostpads
https://bugzilla.gnome.org/show_bug.cgi?id=635067
-rw-r--r--gst/playback/gstdecodebin.c8
-rw-r--r--gst/playback/gstdecodebin2.c13
-rw-r--r--gst/playback/gsturidecodebin.c6
3 files changed, 20 insertions, 7 deletions
diff --git a/gst/playback/gstdecodebin.c b/gst/playback/gstdecodebin.c
index afb8d60ab..13c8ebdd2 100644
--- a/gst/playback/gstdecodebin.c
+++ b/gst/playback/gstdecodebin.c
@@ -392,6 +392,7 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
g_warning ("can't find typefind element, decodebin will not work");
} else {
GstPad *pad, *gpad;
+ GstPadTemplate *pad_tmpl;
/* add the typefind element */
if (!gst_bin_add (GST_BIN (decode_bin), decode_bin->typefind)) {
@@ -403,12 +404,15 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
/* get the sinkpad */
pad = gst_element_get_static_pad (decode_bin->typefind, "sink");
+ /* get the pad template */
+ pad_tmpl = gst_static_pad_template_get (&decoder_bin_sink_template);
+
/* ghost the sink pad to ourself */
- gpad = gst_ghost_pad_new_from_template ("sink", pad,
- gst_static_pad_template_get (&decoder_bin_sink_template));
+ gpad = gst_ghost_pad_new_from_template ("sink", pad, pad_tmpl);
gst_pad_set_active (gpad, TRUE);
gst_element_add_pad (GST_ELEMENT (decode_bin), gpad);
+ gst_object_unref (pad_tmpl);
gst_object_unref (pad);
/* connect a signal to find out when the typefind element found
diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c
index 3efeb3116..0255fd294 100644
--- a/gst/playback/gstdecodebin2.c
+++ b/gst/playback/gstdecodebin2.c
@@ -919,6 +919,7 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
} else {
GstPad *pad;
GstPad *gpad;
+ GstPadTemplate *pad_tmpl;
/* add the typefind element */
if (!gst_bin_add (GST_BIN (decode_bin), decode_bin->typefind)) {
@@ -930,12 +931,15 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
/* get the sinkpad */
pad = gst_element_get_static_pad (decode_bin->typefind, "sink");
+ /* get the pad template */
+ pad_tmpl = gst_static_pad_template_get (&decoder_bin_sink_template);
+
/* ghost the sink pad to ourself */
- gpad = gst_ghost_pad_new_from_template ("sink", pad,
- gst_static_pad_template_get (&decoder_bin_sink_template));
+ gpad = gst_ghost_pad_new_from_template ("sink", pad, pad_tmpl);
gst_pad_set_active (gpad, TRUE);
gst_element_add_pad (GST_ELEMENT (decode_bin), gpad);
+ gst_object_unref (pad_tmpl);
gst_object_unref (pad);
/* connect a signal to find out when the typefind element found
@@ -3406,16 +3410,19 @@ static GstDecodePad *
gst_decode_pad_new (GstDecodeBin * dbin, GstPad * pad, GstDecodeChain * chain)
{
GstDecodePad *dpad;
+ GstPadTemplate *pad_tmpl;
GST_DEBUG_OBJECT (dbin, "making new decodepad");
+ pad_tmpl = gst_static_pad_template_get (&decoder_bin_src_template);
dpad =
g_object_new (GST_TYPE_DECODE_PAD, "direction", GST_PAD_DIRECTION (pad),
- "template", gst_static_pad_template_get (&decoder_bin_src_template),
+ "template", pad_tmpl,
NULL);
gst_ghost_pad_construct (GST_GHOST_PAD_CAST (dpad));
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (dpad), pad);
dpad->chain = chain;
dpad->dbin = dbin;
+ gst_object_unref (pad_tmpl);
return dpad;
}
diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c
index a76c95011..da583fcc2 100644
--- a/gst/playback/gsturidecodebin.c
+++ b/gst/playback/gsturidecodebin.c
@@ -832,6 +832,7 @@ new_decoded_pad_cb (GstElement * element, GstPad * pad, gboolean last,
GstURIDecodeBin * decoder)
{
GstPad *newpad;
+ GstPadTemplate *pad_tmpl;
gchar *padname;
GST_DEBUG_OBJECT (element, "new decoded pad, name: <%s>. Last: %d",
@@ -842,8 +843,9 @@ new_decoded_pad_cb (GstElement * element, GstPad * pad, gboolean last,
decoder->numpads++;
GST_URI_DECODE_BIN_UNLOCK (decoder);
- newpad = gst_ghost_pad_new_from_template (padname, pad,
- gst_static_pad_template_get (&srctemplate));
+ pad_tmpl = gst_static_pad_template_get (&srctemplate);
+ newpad = gst_ghost_pad_new_from_template (padname, pad, pad_tmpl);
+ gst_object_unref (pad_tmpl);
g_free (padname);
/* store ref to the ghostpad so we can remove it */