From: Tim-Philipp Müller Date: Fri, 29 Sep 2006 12:24:50 +0000 (+0000) Subject: libs/gst/controller/gstcontroller.c: Don't g_return_val_if_fail() on timed values... X-Git-Tag: RELEASE-0_10_11~107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3040ad0e2dabf9af36b6ec37327fdcf2eb19c606;p=platform%2Fupstream%2Fgstreamer.git libs/gst/controller/gstcontroller.c: Don't g_return_val_if_fail() on timed values with invalid timestamps inside a cr... Original commit message from CVS: * libs/gst/controller/gstcontroller.c: (gst_controller_new_valist), (gst_controller_set_from_list): Don't g_return_val_if_fail() on timed values with invalid timestamps inside a critical section without unlocking the mutex. Spotted by René Stadler. (#357617) Also, fix up refcounting properly: when returning an existing controller, we should increase the reference only once and not once per property and when trying to control a property again we should also increase the refcount. --- diff --git a/ChangeLog b/ChangeLog index 1e1a1a2..0fa2ef1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-09-29 Tim-Philipp Müller + + * libs/gst/controller/gstcontroller.c: (gst_controller_new_valist), + (gst_controller_set_from_list): + Don't g_return_val_if_fail() on timed values with invalid timestamps + inside a critical section without unlocking the mutex. Spotted by + René Stadler. (#357617) + Also, fix up refcounting properly: when returning an existing + controller, we should increase the reference only once and not + once per property and when trying to control a property again + we should also increase the refcount. + 2006-09-29 Wim Taymans * libs/gst/net/gstnetclientclock.c: (gst_net_client_clock_thread): diff --git a/common b/common index bdd0108..9991f6f 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit bdd0108b3540ffadeb82cee28b8867a8a6e7ae78 +Subproject commit 9991f6fa61ee11475c390dd6675ef7952f079e43 diff --git a/libs/gst/controller/gstcontroller.c b/libs/gst/controller/gstcontroller.c index fcb80e1..acb73d8 100644 --- a/libs/gst/controller/gstcontroller.c +++ b/libs/gst/controller/gstcontroller.c @@ -455,6 +455,7 @@ gst_controller_new_valist (GObject * object, va_list var_args) { GstController *self; GstControlledProperty *prop; + gboolean ref_existing = TRUE; gchar *name; g_return_val_if_fail (G_IS_OBJECT (object), NULL); @@ -485,14 +486,23 @@ gst_controller_new_valist (GObject * object, va_list var_args) self->object = object; /* store the controller */ g_object_set_qdata (object, __gst_controller_key, self); + ref_existing = FALSE; } else { - g_object_ref (self); - GST_INFO ("returning existing controller"); + /* only want one single _ref(), even for multiple properties */ + if (ref_existing) { + g_object_ref (self); + ref_existing = FALSE; + GST_INFO ("returning existing controller"); + } } self->properties = g_list_prepend (self->properties, prop); } } else { GST_WARNING ("trying to control property again"); + if (ref_existing) { + g_object_ref (self); + ref_existing = FALSE; + } } } va_end (var_args); @@ -760,11 +770,15 @@ gst_controller_set_from_list (GstController * self, gchar * property_name, for (node = timedvalues; node; node = g_slist_next (node)) { tv = node->data; if (G_VALUE_TYPE (&tv->value) == prop->type) { - g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (tv->timestamp), FALSE); - /* TODO copy the timed value or just link in? */ - prop->values = - g_list_insert_sorted (prop->values, tv, gst_timed_value_compare); - res = TRUE; + if (GST_CLOCK_TIME_IS_VALID (tv->timestamp)) { + /* TODO copy the timed value or just link in? */ + prop->values = + g_list_insert_sorted (prop->values, tv, gst_timed_value_compare); + res = TRUE; + } else { + g_warning ("GstTimedValued with invalid timestamp passed to %s " + "for property '%s'", GST_FUNCTION, property_name); + } } else { GST_WARNING ("incompatible value type for property '%s'", prop->name); }