controller: the object needs a ref to the controller for the convenience api
authorStefan Sauer <ensonic@users.sf.net>
Fri, 4 Nov 2011 20:37:45 +0000 (21:37 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Sat, 5 Nov 2011 10:02:42 +0000 (11:02 +0100)
Add a hack to ensure the object will have a ref to the controller once we
create it. Fixes the audio example (that uses the controller api directly).

gst/gstcontroller.c
gst/gstobject.c

index c58a1ff..c9f033c 100644 (file)
@@ -279,8 +279,12 @@ gst_controller_new_valist (GstObject * object, va_list var_args)
 
   g_return_val_if_fail (G_IS_OBJECT (object), NULL);
 
+  /* FIXME: storing the controller into the object is ugly
+   * we'd like to make the controller object completely internal
+   */
   self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
   self->object = g_object_ref (object);
+  object->ctrl = g_object_ref (self);
 
   /* create GstControlledProperty for each property */
   while ((name = va_arg (var_args, gchar *))) {
@@ -314,6 +318,7 @@ gst_controller_new_list (GstObject * object, GList * list)
 
   self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
   self->object = g_object_ref (object);
+  object->ctrl = g_object_ref (self);
 
   /* create GstControlledProperty for each property */
   for (node = list; node; node = g_list_next (node)) {
index 5a00ee0..47cd08b 100644 (file)
@@ -982,7 +982,12 @@ gst_object_control_properties (GstObject * object, ...)
 
   va_start (var_args, object);
   if (object->ctrl) {
-    object->ctrl = gst_controller_new_valist (object, var_args);
+    GstController *ctrl = gst_controller_new_valist (object, var_args);
+
+    /* FIXME: see gst_controller_new_*() */
+    g_object_unref (object->ctrl);
+    object->ctrl = ctrl;
+
     res = (object->ctrl != NULL);
   } else {
     res = gst_controller_add_properties_valist ((GstController *) object->ctrl,