From: <bi...@ke...> - 2008-08-30 11:56:05
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: bilboed Date: Sat Aug 30 2008 11:56:13 UTC Log message: * 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 ! Modified files: . : ChangeLog gst : gstutils.c tests/check/gst : gstghostpad.c gstpad.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4049&r2=1.4050 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstutils.c.diff?r1=1.185&r2=1.186 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/tests/check/gst/gstghostpad.c.diff?r1=1.29&r2=1.30 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/tests/check/gst/gstpad.c.diff?r1=1.26&r2=1.27 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.4049 retrieving revision 1.4050 diff -u -d -r1.4049 -r1.4050 --- ChangeLog 29 Aug 2008 17:58:23 -0000 1.4049 +++ ChangeLog 30 Aug 2008 11:55:56 -0000 1.4050 @@ -1,3 +1,18 @@ +2008-08-30 Edward Hervey <edw...@co...> + + * 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 ! 2008-08-29 Wim Taymans <wim...@co...> * gst/gstiterator.c: Index: gstutils.c RCS file: /cvs/gstreamer/gstreamer/gst/gstutils.c,v retrieving revision 1.185 retrieving revision 1.186 diff -u -d -r1.185 -r1.186 --- gstutils.c 27 Aug 2008 02:59:59 -0000 1.185 +++ gstutils.c 30 Aug 2008 11:55:58 -0000 1.186 @@ -969,6 +969,12 @@ templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad), 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); gst_object_unref (templ); Index: gstghostpad.c RCS file: /cvs/gstreamer/gstreamer/tests/check/gst/gstghostpad.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- gstghostpad.c 24 Jun 2008 07:49:36 -0000 1.29 +++ gstghostpad.c 30 Aug 2008 11:55:58 -0000 1.30 @@ -558,18 +558,27 @@ GstPadTemplate *padtempl, *ghosttempl; GstCaps *padcaps, *ghostcaps, *newcaps; + GstCaps *copypadcaps; padcaps = gst_caps_from_string ("some/caps"); fail_unless (padcaps != NULL); ghostcaps = gst_caps_from_string ("some/caps;some/other-caps"); fail_unless (ghostcaps != NULL); + copypadcaps = gst_caps_copy (padcaps); padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK, - GST_PAD_ALWAYS, gst_caps_copy (padcaps)); + GST_PAD_ALWAYS, copypadcaps); fail_unless (padtempl != NULL); ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK, 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"); fail_unless (sinkpad != NULL); @@ -602,17 +611,27 @@ + GstCaps *copypadcaps, *copyghostcaps; + copyghostcaps = gst_caps_copy (ghostcaps); - GST_PAD_ALWAYS, gst_caps_copy (ghostcaps)); + GST_PAD_ALWAYS, copyghostcaps); + gst_caps_unref (copyghostcaps); Index: gstpad.c RCS file: /cvs/gstreamer/gstreamer/tests/check/gst/gstpad.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstpad.c 29 Feb 2008 13:59:21 -0000 1.26 +++ gstpad.c 30 Aug 2008 11:55:59 -0000 1.27 @@ -203,10 +203,15 @@ name_is_valid (const gchar * name, GstPadPresence presence) { 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) { 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 FALSE; @@ -463,16 +468,26 @@ GstPad *src, *sink; GstPadLinkReturn plr; - GstPadTemplate *src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - gst_caps_from_string ("audio/x-raw-int,width={16,32},depth={16,32}")); - GstPadTemplate *sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - gst_caps_from_string ("audio/x-raw-int,width=32,depth={16,32}")); + GstCaps *srccaps = + gst_caps_from_string ("audio/x-raw-int,width={16,32},depth={16,32}"); + GstCaps *sinkcaps = + gst_caps_from_string ("audio/x-raw-int,width=32,depth={16,32}"); + GstPadTemplate *src_template; + GstPadTemplate *sink_template; GstCaps *caps; GstBuffer *buffer; /* 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); + gst_caps_unref (srccaps); + gst_caps_unref (sinkcaps); sink = gst_pad_new_from_template (sink_template, "sink"); fail_if (sink == NULL); gst_pad_set_chain_function (sink, gst_check_chain_func); @@ -588,17 +603,23 @@ caps = gst_caps_new_any (); templ = 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); fail_unless (GST_PAD_CAPS (pad) == NULL, "caps present on pad"); + /* This is a writable copy ! */ caps = gst_pad_get_caps (pad); /* we must own the caps */ ASSERT_OBJECT_REFCOUNT (caps, "caps", 1); /* cleanup */ + gst_object_unref (templ); gst_caps_unref (caps); gst_object_unref (pad); - gst_object_unref (templ); } GST_END_TEST; |