gst/: Leak fixes, the fold functions need to unref the passed object and _get_parent_*() returns ref to parent.

Original commit message from CVS:
* gst/elements/gsttee.c: (gst_tee_init), (gst_tee_do_push):
* gst/gstutils.c: (intersect_caps_func), (gst_pad_proxy_getcaps),
(link_fold_func), (gst_pad_proxy_setcaps):
Leak fixes, the fold functions need to unref the passed object and
_get_parent_*() returns ref to parent.
This commit is contained in:
Wim Taymans 2005-09-27 15:37:40 +00:00
parent 7d1cb339da
commit 590a0cfb57
4 changed files with 44 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2005-09-27 Wim Taymans <wim@fluendo.com>
* gst/elements/gsttee.c: (gst_tee_init), (gst_tee_do_push):
* gst/gstutils.c: (intersect_caps_func), (gst_pad_proxy_getcaps),
(link_fold_func), (gst_pad_proxy_setcaps):
Leak fixes, the fold functions need to unref the passed object and
_get_parent_*() returns ref to parent.
2005-09-27 Tim-Philipp Müller <tim at centricular dot net>
* check/gst/gstbuffer.c: (test_make_writable):

View file

@ -142,11 +142,11 @@ gst_tee_init (GstTee * tee, GstTeeClass * g_class)
tee->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
"sink");
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
gst_pad_set_setcaps_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
gst_pad_set_getcaps_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
tee->last_message = NULL;
}
@ -276,6 +276,8 @@ gst_tee_do_push (GstPad * pad, GValue * ret, PushData * data)
res = gst_pad_push (pad, gst_buffer_ref (data->buffer));
g_value_set_enum (ret, res);
gst_object_unref (pad);
return (res == GST_FLOW_OK);
}

View file

@ -2212,6 +2212,7 @@ intersect_caps_func (GstPad * pad, GValue * ret, GstPad * orig)
gst_caps_unref (existing);
gst_caps_unref (peercaps);
}
gst_object_unref (pad);
return TRUE;
}
@ -2254,11 +2255,10 @@ gst_pad_proxy_getcaps (GstPad * pad)
&ret, pad);
gst_iterator_free (iter);
if (res != GST_ITERATOR_DONE) {
g_warning ("Pad list changed during capsnego for element %s",
GST_ELEMENT_NAME (element));
return NULL;
}
if (res != GST_ITERATOR_DONE)
goto pads_changed;
gst_object_unref (element);
caps = g_value_get_pointer (&ret);
g_value_unset (&ret);
@ -2267,6 +2267,15 @@ gst_pad_proxy_getcaps (GstPad * pad)
gst_caps_unref (caps);
return intersected;
/* ERRORS */
pads_changed:
{
g_warning ("Pad list changed during capsnego for element %s",
GST_ELEMENT_NAME (element));
gst_object_unref (element);
return NULL;
}
}
typedef struct
@ -2284,6 +2293,7 @@ link_fold_func (GstPad * pad, GValue * ret, LinkData * data)
success = gst_pad_set_caps (pad, data->caps);
g_value_set_boolean (ret, success);
}
gst_object_unref (pad);
return success;
}
@ -2314,6 +2324,8 @@ gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps)
GST_DEBUG ("proxying pad link for %s:%s", GST_DEBUG_PAD_NAME (pad));
element = gst_pad_get_parent_element (pad);
if (element == NULL)
return FALSE;
iter = gst_element_iterate_pads (element);
@ -2326,14 +2338,22 @@ gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps)
&ret, &data);
gst_iterator_free (iter);
if (res != GST_ITERATOR_DONE) {
g_warning ("Pad list changed during proxy_pad_link for element %s",
GST_ELEMENT_NAME (element));
return FALSE;
}
if (res != GST_ITERATOR_DONE)
goto pads_changed;
gst_object_unref (element);
/* ok not to unset the gvalue */
return g_value_get_boolean (&ret);
/* ERRORS */
pads_changed:
{
g_warning ("Pad list changed during proxy_pad_link for element %s",
GST_ELEMENT_NAME (element));
gst_object_unref (element);
return FALSE;
}
}
/**

View file

@ -142,11 +142,11 @@ gst_tee_init (GstTee * tee, GstTeeClass * g_class)
tee->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
"sink");
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
gst_pad_set_setcaps_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
gst_pad_set_getcaps_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
tee->last_message = NULL;
}
@ -276,6 +276,8 @@ gst_tee_do_push (GstPad * pad, GValue * ret, PushData * data)
res = gst_pad_push (pad, gst_buffer_ref (data->buffer));
g_value_set_enum (ret, res);
gst_object_unref (pad);
return (res == GST_FLOW_OK);
}