From 627c40985bded4882dcb0ed47a059c44f7f98d72 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Mon, 17 Nov 2008 21:41:35 +0000 Subject: [PATCH] libs/gst/controller/: Keep last-value and only call set_property if value has changed. This supresses all the g_objec... Original commit message from CVS: * libs/gst/controller/gstcontroller.c: * libs/gst/controller/gstcontrollerprivate.h: Keep last-value and only call set_property if value has changed. This supresses all the g_object_notifies we would trigger otherwise. It also allows the user to chage the value while there is no controller change. --- ChangeLog | 9 +++++++++ libs/gst/controller/gstcontroller.c | 8 +++++++- libs/gst/controller/gstcontrollerprivate.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d479772..cc5f182 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2008-11-17 Stefan Kost + * libs/gst/controller/gstcontroller.c: + * libs/gst/controller/gstcontrollerprivate.h: + Keep last-value and only call set_property if value has changed. This + supresses all the g_object_notifies we would trigger otherwise. It + also allows the user to chage the value while there is no controller + change. + +2008-11-17 Stefan Kost + * gst/gstvalue.c: Don't crash if either of the string GValues is empty. diff --git a/libs/gst/controller/gstcontroller.c b/libs/gst/controller/gstcontroller.c index 8549901..b9d37e1 100644 --- a/libs/gst/controller/gstcontroller.c +++ b/libs/gst/controller/gstcontroller.c @@ -146,6 +146,8 @@ gst_controlled_property_new (GObject * object, const gchar * name) prop->pspec = pspec; prop->name = pspec->name; prop->disabled = FALSE; + memset (&prop->last_value, 0, sizeof (GValue)); + g_value_init (&prop->last_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec)); } } else { GST_WARNING ("class '%s' has no property '%s'", G_OBJECT_TYPE_NAME (object), @@ -166,6 +168,7 @@ gst_controlled_property_free (GstControlledProperty * prop) { if (prop->csource) g_object_unref (prop->csource); + g_value_unset (&prop->last_value); g_free (prop); } @@ -691,7 +694,10 @@ gst_controller_sync_values (GstController * self, GstClockTime timestamp) g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec)); ret = gst_control_source_get_value (prop->csource, timestamp, &value); if (G_LIKELY (ret)) { - g_object_set_property (self->object, prop->name, &value); + if (gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) { + g_object_set_property (self->object, prop->name, &value); + g_value_copy (&value, &prop->last_value); + } } else { GST_LOG ("no control value"); } diff --git a/libs/gst/controller/gstcontrollerprivate.h b/libs/gst/controller/gstcontrollerprivate.h index ab600e9..9b578c8 100644 --- a/libs/gst/controller/gstcontrollerprivate.h +++ b/libs/gst/controller/gstcontrollerprivate.h @@ -41,6 +41,7 @@ typedef struct _GstControlledProperty gchar *name; /* name of the property */ GstControlSource *csource; /* GstControlSource for this property */ gboolean disabled; + GValue last_value; } GstControlledProperty; #define GST_CONTROLLED_PROPERTY(obj) ((GstControlledProperty *)(obj)) -- 2.7.4