mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
Fix all leaks due to the bug in gst_pad_template_new() by which it does not steal the refcount of the given caps as s...
Original commit message from CVS: * gst/gstutils.c: (gst_element_get_compatible_pad): * tests/check/gst/gstghostpad.c: (GST_START_TEST): * tests/check/gst/gstpad.c: (name_is_valid), (GST_START_TEST): Fix all leaks due to the bug in gst_pad_template_new() by which it does not steal the refcount of the given caps as stated. REVERT THIS COMMIT ONCE FIXED ! REVERT THIS COMMIT ONCE FIXED ! REVERT THIS COMMIT ONCE FIXED ! REVERT THIS COMMIT ONCE FIXED ! REVERT THIS COMMIT ONCE FIXED ! REVERT THIS COMMIT ONCE FIXED !
This commit is contained in:
parent
e6da27eb3b
commit
dd80b2030c
4 changed files with 72 additions and 11 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2008-08-30 Edward Hervey <edward.hervey@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/gstutils.c: (gst_element_get_compatible_pad):
|
||||||
|
* tests/check/gst/gstghostpad.c: (GST_START_TEST):
|
||||||
|
* tests/check/gst/gstpad.c: (name_is_valid), (GST_START_TEST):
|
||||||
|
Fix all leaks due to the bug in gst_pad_template_new() by which it does
|
||||||
|
not steal the refcount of the given caps as stated.
|
||||||
|
|
||||||
|
REVERT THIS COMMIT ONCE FIXED !
|
||||||
|
REVERT THIS COMMIT ONCE FIXED !
|
||||||
|
REVERT THIS COMMIT ONCE FIXED !
|
||||||
|
REVERT THIS COMMIT ONCE FIXED !
|
||||||
|
REVERT THIS COMMIT ONCE FIXED !
|
||||||
|
REVERT THIS COMMIT ONCE FIXED !
|
||||||
|
|
||||||
2008-08-29 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-08-29 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* gst/gstiterator.c:
|
* gst/gstiterator.c:
|
||||||
|
|
|
@ -969,6 +969,12 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
|
||||||
|
|
||||||
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
|
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
|
||||||
GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
|
GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
|
||||||
|
|
||||||
|
/* FIXME : Because of a bug in gst_pad_template_new() by which is does not
|
||||||
|
* properly steal the refcount of the given caps, we have to unref these caps
|
||||||
|
* REVERT THIS WHEN FIXED !*/
|
||||||
|
gst_caps_unref (templcaps);
|
||||||
|
|
||||||
foundpad = gst_element_request_compatible_pad (element, templ);
|
foundpad = gst_element_request_compatible_pad (element, templ);
|
||||||
gst_object_unref (templ);
|
gst_object_unref (templ);
|
||||||
|
|
||||||
|
|
|
@ -558,18 +558,27 @@ GST_START_TEST (test_ghost_pads_new_from_template)
|
||||||
GstPadTemplate *padtempl, *ghosttempl;
|
GstPadTemplate *padtempl, *ghosttempl;
|
||||||
|
|
||||||
GstCaps *padcaps, *ghostcaps, *newcaps;
|
GstCaps *padcaps, *ghostcaps, *newcaps;
|
||||||
|
GstCaps *copypadcaps;
|
||||||
|
|
||||||
padcaps = gst_caps_from_string ("some/caps");
|
padcaps = gst_caps_from_string ("some/caps");
|
||||||
fail_unless (padcaps != NULL);
|
fail_unless (padcaps != NULL);
|
||||||
ghostcaps = gst_caps_from_string ("some/caps;some/other-caps");
|
ghostcaps = gst_caps_from_string ("some/caps;some/other-caps");
|
||||||
fail_unless (ghostcaps != NULL);
|
fail_unless (ghostcaps != NULL);
|
||||||
|
|
||||||
|
copypadcaps = gst_caps_copy (padcaps);
|
||||||
padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK,
|
padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS, gst_caps_copy (padcaps));
|
GST_PAD_ALWAYS, copypadcaps);
|
||||||
fail_unless (padtempl != NULL);
|
fail_unless (padtempl != NULL);
|
||||||
ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK,
|
ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS, ghostcaps);
|
GST_PAD_ALWAYS, ghostcaps);
|
||||||
|
|
||||||
|
/* FIXME : We should not have to unref those caps, but due to
|
||||||
|
* a bug in gst_pad_template_new() not stealing the refcount of
|
||||||
|
* the given caps we have to. */
|
||||||
|
gst_caps_unref (ghostcaps);
|
||||||
|
gst_caps_unref (copypadcaps);
|
||||||
|
|
||||||
|
|
||||||
sinkpad = gst_pad_new_from_template (padtempl, "sinkpad");
|
sinkpad = gst_pad_new_from_template (padtempl, "sinkpad");
|
||||||
fail_unless (sinkpad != NULL);
|
fail_unless (sinkpad != NULL);
|
||||||
|
|
||||||
|
@ -602,17 +611,27 @@ GST_START_TEST (test_ghost_pads_new_no_target_from_template)
|
||||||
GstPadTemplate *padtempl, *ghosttempl;
|
GstPadTemplate *padtempl, *ghosttempl;
|
||||||
|
|
||||||
GstCaps *padcaps, *ghostcaps, *newcaps;
|
GstCaps *padcaps, *ghostcaps, *newcaps;
|
||||||
|
GstCaps *copypadcaps, *copyghostcaps;
|
||||||
|
|
||||||
padcaps = gst_caps_from_string ("some/caps");
|
padcaps = gst_caps_from_string ("some/caps");
|
||||||
fail_unless (padcaps != NULL);
|
fail_unless (padcaps != NULL);
|
||||||
ghostcaps = gst_caps_from_string ("some/caps;some/other-caps");
|
ghostcaps = gst_caps_from_string ("some/caps;some/other-caps");
|
||||||
fail_unless (ghostcaps != NULL);
|
fail_unless (ghostcaps != NULL);
|
||||||
|
|
||||||
|
copypadcaps = gst_caps_copy (padcaps);
|
||||||
|
copyghostcaps = gst_caps_copy (ghostcaps);
|
||||||
|
|
||||||
padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK,
|
padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS, gst_caps_copy (padcaps));
|
GST_PAD_ALWAYS, copypadcaps);
|
||||||
fail_unless (padtempl != NULL);
|
fail_unless (padtempl != NULL);
|
||||||
ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK,
|
ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS, gst_caps_copy (ghostcaps));
|
GST_PAD_ALWAYS, copyghostcaps);
|
||||||
|
|
||||||
|
/* FIXME : We should not have to unref those caps, but due to
|
||||||
|
* a bug in gst_pad_template_new() not stealing the refcount of
|
||||||
|
* the given caps we have to. */
|
||||||
|
gst_caps_unref (copyghostcaps);
|
||||||
|
gst_caps_unref (copypadcaps);
|
||||||
|
|
||||||
sinkpad = gst_pad_new_from_template (padtempl, "sinkpad");
|
sinkpad = gst_pad_new_from_template (padtempl, "sinkpad");
|
||||||
fail_unless (sinkpad != NULL);
|
fail_unless (sinkpad != NULL);
|
||||||
|
|
|
@ -203,10 +203,15 @@ static gboolean
|
||||||
name_is_valid (const gchar * name, GstPadPresence presence)
|
name_is_valid (const gchar * name, GstPadPresence presence)
|
||||||
{
|
{
|
||||||
GstPadTemplate *new;
|
GstPadTemplate *new;
|
||||||
|
GstCaps *any = GST_CAPS_ANY;
|
||||||
|
|
||||||
new = gst_pad_template_new (name, GST_PAD_SRC, presence, GST_CAPS_ANY);
|
new = gst_pad_template_new (name, GST_PAD_SRC, presence, any);
|
||||||
if (new) {
|
if (new) {
|
||||||
gst_object_unref (GST_OBJECT (new));
|
gst_object_unref (GST_OBJECT (new));
|
||||||
|
/* FIXME : We should not have to unref those caps, but due to
|
||||||
|
* a bug in gst_pad_template_new() not stealing the refcount of
|
||||||
|
* the given caps we have to. */
|
||||||
|
gst_caps_unref (any);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -463,16 +468,26 @@ GST_START_TEST (test_push_negotiation)
|
||||||
{
|
{
|
||||||
GstPad *src, *sink;
|
GstPad *src, *sink;
|
||||||
GstPadLinkReturn plr;
|
GstPadLinkReturn plr;
|
||||||
GstPadTemplate *src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
GstCaps *srccaps =
|
||||||
GST_PAD_ALWAYS,
|
gst_caps_from_string ("audio/x-raw-int,width={16,32},depth={16,32}");
|
||||||
gst_caps_from_string ("audio/x-raw-int,width={16,32},depth={16,32}"));
|
GstCaps *sinkcaps =
|
||||||
GstPadTemplate *sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
gst_caps_from_string ("audio/x-raw-int,width=32,depth={16,32}");
|
||||||
GST_PAD_ALWAYS,
|
GstPadTemplate *src_template;
|
||||||
gst_caps_from_string ("audio/x-raw-int,width=32,depth={16,32}"));
|
GstPadTemplate *sink_template;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
|
|
||||||
/* setup */
|
/* setup */
|
||||||
|
src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
||||||
|
GST_PAD_ALWAYS, srccaps);
|
||||||
|
sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
||||||
|
GST_PAD_ALWAYS, sinkcaps);
|
||||||
|
/* FIXME : We should not have to unref those caps, but due to
|
||||||
|
* a bug in gst_pad_template_new() not stealing the refcount of
|
||||||
|
* the given caps we have to. */
|
||||||
|
gst_caps_unref (srccaps);
|
||||||
|
gst_caps_unref (sinkcaps);
|
||||||
|
|
||||||
sink = gst_pad_new_from_template (sink_template, "sink");
|
sink = gst_pad_new_from_template (sink_template, "sink");
|
||||||
fail_if (sink == NULL);
|
fail_if (sink == NULL);
|
||||||
gst_pad_set_chain_function (sink, gst_check_chain_func);
|
gst_pad_set_chain_function (sink, gst_check_chain_func);
|
||||||
|
@ -588,17 +603,23 @@ GST_START_TEST (test_get_caps_must_be_copy)
|
||||||
caps = gst_caps_new_any ();
|
caps = gst_caps_new_any ();
|
||||||
templ =
|
templ =
|
||||||
gst_pad_template_new ("test_templ", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
gst_pad_template_new ("test_templ", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
||||||
|
/* FIXME : This is not correct behaviour, but due to a bug with
|
||||||
|
* gst_pad_template_new() not stealing the refcount of the given caps,
|
||||||
|
* we need to unref it */
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
pad = gst_pad_new_from_template (templ, NULL);
|
pad = gst_pad_new_from_template (templ, NULL);
|
||||||
fail_unless (GST_PAD_CAPS (pad) == NULL, "caps present on pad");
|
fail_unless (GST_PAD_CAPS (pad) == NULL, "caps present on pad");
|
||||||
|
/* This is a writable copy ! */
|
||||||
caps = gst_pad_get_caps (pad);
|
caps = gst_pad_get_caps (pad);
|
||||||
|
|
||||||
/* we must own the caps */
|
/* we must own the caps */
|
||||||
ASSERT_OBJECT_REFCOUNT (caps, "caps", 1);
|
ASSERT_OBJECT_REFCOUNT (caps, "caps", 1);
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
gst_object_unref (templ);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
gst_object_unref (templ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue