added another constructor for language bindings
authorStefan Kost <ensonic@users.sourceforge.net>
Wed, 28 Sep 2005 16:39:29 +0000 (16:39 +0000)
committerStefan Kost <ensonic@users.sourceforge.net>
Wed, 28 Sep 2005 16:39:29 +0000 (16:39 +0000)
Original commit message from CVS:
* docs/libs/gstreamer-libs-sections.txt:
* libs/gst/controller/gstcontroller.c: (gst_controller_new_valist),
(gst_controller_new_list):
* libs/gst/controller/gstcontroller.h:
added another constructor for language bindings

ChangeLog
docs/libs/gstreamer-libs-sections.txt
libs/gst/controller/gstcontroller.c
libs/gst/controller/gstcontroller.h

index 015588f..7fcb447 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-09-28  Stefan Kost  <ensonic@users.sf.net>
+
+       * docs/libs/gstreamer-libs-sections.txt:
+       * libs/gst/controller/gstcontroller.c: (gst_controller_new_valist),
+       (gst_controller_new_list):
+       * libs/gst/controller/gstcontroller.h:
+          added another constructor for language bindings
+
 2005-09-28  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * check/gst/gstpipeline.c: (GST_START_TEST), (gst_pipeline_suite):
index 491f703..4a4727b 100644 (file)
@@ -50,6 +50,7 @@ GstController
 GstInterpolateMode
 gst_controller_init
 gst_controller_new
+gst_controller_new_list
 gst_controller_new_valist
 gst_controller_remove_properties
 gst_controller_remove_properties_valist
index d09d34e..b78cb8f 100644 (file)
@@ -434,8 +434,6 @@ gst_controller_new_valist (GObject * object, va_list var_args)
           // store the controller
           g_object_set_qdata (object, __gst_controller_key, self);
         } else {
-          // increment ref-count (this causes red-count-leaks
-          //self = g_object_ref (self);
           GST_INFO ("returning existing controller");
         }
         self->properties = g_list_prepend (self->properties, prop);
@@ -452,6 +450,57 @@ gst_controller_new_valist (GObject * object, va_list var_args)
 }
 
 /**
+ * gst_controller_new_list:
+ * @object: the object of which some properties should be controlled
+ * @list: list of property names that should be controlled
+ *
+ * Creates a new GstController for the given object's properties
+ *
+ * Returns: the new controller.
+ * Since: 0.9
+ */
+GstController *
+gst_controller_new_list (GObject * object, GList * list)
+{
+  GstController *self;
+  GstControlledProperty *prop;
+  gchar *name;
+  GList *node;
+
+  g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+
+  GST_INFO ("setting up a new controller");
+
+  self = g_object_get_qdata (object, __gst_controller_key);
+  // create GstControlledProperty for each property
+  for (node = list; node; node = g_list_next (list)) {
+    name = (gchar *) node->data;
+    // test if this property isn't yet controlled
+    if (!self || !(prop = gst_controller_find_controlled_property (self, name))) {
+      // create GstControlledProperty and add to self->propeties List
+      if ((prop = gst_controlled_property_new (object, name))) {
+        // if we don't have a controller object yet, now is the time to create one
+        if (!self) {
+          self = g_object_new (GST_TYPE_CONTROLLER, NULL);
+          self->object = object;
+          // store the controller
+          g_object_set_qdata (object, __gst_controller_key, self);
+        } else {
+          GST_INFO ("returning existing controller");
+        }
+        self->properties = g_list_prepend (self->properties, prop);
+      }
+    } else {
+      GST_WARNING ("trying to control property again");
+    }
+  }
+
+  if (self)
+    GST_INFO ("controller->ref_count=%d", G_OBJECT (self)->ref_count);
+  return (self);
+}
+
+/**
  * gst_controller_new:
  * @object: the object of which some properties should be controlled
  * @...: %NULL terminated list of property names that should be controlled
index ddc4a2d..c3f9388 100644 (file)
@@ -204,6 +204,7 @@ GType gst_controller_get_type (void);
 /* GstController functions */
 
 GstController *gst_controller_new_valist (GObject * object, va_list var_args);
+GstController *gst_controller_new_list (GObject * object, GList *list);
 GstController *gst_controller_new (GObject * object, ...);
 
 gboolean gst_controller_remove_properties_valist (GstController * self,