controller: the object needs a ref to the controller for the convenience api

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).
This commit is contained in:
Stefan Sauer 2011-11-04 21:37:45 +01:00
parent 593d2b297b
commit 618be218e8
2 changed files with 11 additions and 1 deletions

View 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)) {

View 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,