element: Consider GstPadTemplate as immutable
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 17 May 2011 10:12:23 +0000 (12:12 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 17 May 2011 11:13:51 +0000 (13:13 +0200)
Don't copy the templates when creating subclasses but only increase
their refcount.

docs/random/porting-to-0.11.txt
gst/gstelement.c

index eb8eeea..e5b51b1 100644 (file)
@@ -101,6 +101,9 @@ The 0.11 porting guide
     GstPadTemplate is now created with a floating ref and
     gst_element_class_add_pad_template() takes ownership of this floating ref.
 
+    GstPadTemplate instances are considered immutable and must not be
+    changed.
+
 * GstMiniObject
     A miniobject is now a simple refcounted structure holding the information
     common to buffers, events, messages, queries and caps.
index f8afa3d..a6157b8 100644 (file)
@@ -251,14 +251,10 @@ gst_element_base_class_init (gpointer g_class)
    * from their base class but elements can add pad templates in class_init
    * instead of base_init.
    */
-  /* FIXME: Do we consider GstPadTemplates as immutable? If so we can
-   * simply ref them instead of copying.
-   */
   padtemplates = g_list_copy (element_class->padtemplates);
   for (node = padtemplates; node != NULL; node = node->next) {
     GstPadTemplate *tmpl = (GstPadTemplate *) node->data;
-    node->data = gst_pad_template_new (tmpl->name_template,
-        tmpl->direction, tmpl->presence, gst_caps_copy (tmpl->caps));
+    gst_object_ref (tmpl);
   }
   element_class->padtemplates = padtemplates;