pad: Let template related functions return new references
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 17 May 2011 09:59:00 +0000 (11:59 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 17 May 2011 10:00:18 +0000 (12:00 +0200)
gst_pad_template_get_caps(), gst_pad_get_pad_template_caps()
and gst_pad_get_pad_template() return a new reference of the
caps or template now and the return value needs to be
unreffed after usage.

docs/random/porting-to-0.11.txt
gst/gstpad.c
gst/gstpad.h
gst/gstpadtemplate.c

index bcf3a53..5d50132 100644 (file)
@@ -88,6 +88,14 @@ The 0.11 porting guide
     gst_pad_proxy_getcaps() now takes a GstCaps* parameter to inform
     the other side about the possible caps and preferences.
 
+    gst_pad_get_pad_template_caps() and gst_pad_get_pad_template()
+    return a new reference of the caps or template now and the return
+    value needs to be unreffed after usage.
+
+* GstPadTemplate
+    gst_pad_template_get_caps() returns a new reference of the caps
+    and the return value needs to be unreffed after usage.
+
 * GstMiniObject
     A miniobject is now a simple refcounted structure holding the information
     common to buffers, events, messages, queries and caps.
index 3104940..dca4c4f 100644 (file)
@@ -2171,19 +2171,21 @@ gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ)
  *
  * Gets the template for @pad.
  *
- * Returns: (transfer none): the #GstPadTemplate from which this pad was
- *     instantiated, or %NULL if this pad has no template.
- *
- * FIXME: currently returns an unrefcounted padtemplate.
+ * Returns: (transfer full): the #GstPadTemplate from which this pad was
+ *     instantiated, or %NULL if this pad has no template. Unref after
+ *     usage.
  */
 GstPadTemplate *
 gst_pad_get_pad_template (GstPad * pad)
 {
+  GstPadTemplate *templ;
+
   g_return_val_if_fail (GST_IS_PAD (pad), NULL);
 
-  return GST_PAD_PAD_TEMPLATE (pad);
-}
+  templ = GST_PAD_PAD_TEMPLATE (pad);
 
+  return (templ ? gst_object_ref (templ) : NULL);
+}
 
 /* should be called with the pad LOCK held */
 /* refs the caps, so caller is responsible for getting it unreffed */
@@ -2815,10 +2817,10 @@ no_function:
  *
  * Gets the capabilities for @pad's template.
  *
- * Returns: (transfer none): the #GstCaps of this pad template. If you intend
- *     to keep a reference on the caps, make a copy (see gst_caps_copy ()).
+ * Returns: (transfer full): the #GstCaps of this pad template.
+ * Unref after usage.
  */
-const GstCaps *
+GstCaps *
 gst_pad_get_pad_template_caps (GstPad * pad)
 {
   static GstStaticCaps anycaps = GST_STATIC_CAPS ("ANY");
@@ -2826,7 +2828,7 @@ gst_pad_get_pad_template_caps (GstPad * pad)
   g_return_val_if_fail (GST_IS_PAD (pad), NULL);
 
   if (GST_PAD_PAD_TEMPLATE (pad))
-    return GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (pad));
+    return gst_pad_template_get_caps (GST_PAD_PAD_TEMPLATE (pad));
 
   return gst_static_caps_get (&anycaps);
 }
index 198a0ca..566afc7 100644 (file)
@@ -846,7 +846,7 @@ void                        gst_pad_set_acceptcaps_function         (GstPad *pad, GstPadAcceptCapsFunction a
 void                   gst_pad_set_fixatecaps_function         (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
 void                   gst_pad_set_setcaps_function            (GstPad *pad, GstPadSetCapsFunction setcaps);
 
-G_CONST_RETURN GstCaps*        gst_pad_get_pad_template_caps           (GstPad *pad);
+GstCaps*                gst_pad_get_pad_template_caps          (GstPad *pad);
 
 /* capsnego function for linked/unlinked pads */
 GstCaps *              gst_pad_get_current_caps                (GstPad * pad);
index 06c4d55..65a7f4d 100644 (file)
@@ -397,15 +397,18 @@ gst_static_pad_template_get_caps (GstStaticPadTemplate * templ)
  *
  * Gets the capabilities of the pad template.
  *
- * Returns: (transfer none): the #GstCaps of the pad template. If you need to
- *     keep a reference to the caps, take a ref (see gst_caps_ref ()).
+ * Returns: (transfer full): the #GstCaps of the pad template.
+ * Unref after usage.
  */
 GstCaps *
 gst_pad_template_get_caps (GstPadTemplate * templ)
 {
+  GstCaps *caps;
   g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
 
-  return GST_PAD_TEMPLATE_CAPS (templ);
+  caps = GST_PAD_TEMPLATE_CAPS (templ);
+
+  return (caps ? gst_caps_ref (caps) : NULL);
 }
 
 /**