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.
This commit is contained in:
Stefan Kost 2008-11-17 21:41:35 +00:00
parent d27aea0391
commit 627c40985b
3 changed files with 17 additions and 1 deletions

View file

@ -1,3 +1,12 @@
2008-11-17 Stefan Kost <ensonic@users.sf.net>
* 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 <ensonic@users.sf.net> 2008-11-17 Stefan Kost <ensonic@users.sf.net>
* gst/gstvalue.c: * gst/gstvalue.c:

View file

@ -146,6 +146,8 @@ gst_controlled_property_new (GObject * object, const gchar * name)
prop->pspec = pspec; prop->pspec = pspec;
prop->name = pspec->name; prop->name = pspec->name;
prop->disabled = FALSE; prop->disabled = FALSE;
memset (&prop->last_value, 0, sizeof (GValue));
g_value_init (&prop->last_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
} }
} else { } else {
GST_WARNING ("class '%s' has no property '%s'", G_OBJECT_TYPE_NAME (object), 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) if (prop->csource)
g_object_unref (prop->csource); g_object_unref (prop->csource);
g_value_unset (&prop->last_value);
g_free (prop); 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)); g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
ret = gst_control_source_get_value (prop->csource, timestamp, &value); ret = gst_control_source_get_value (prop->csource, timestamp, &value);
if (G_LIKELY (ret)) { 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 { } else {
GST_LOG ("no control value"); GST_LOG ("no control value");
} }

View file

@ -41,6 +41,7 @@ typedef struct _GstControlledProperty
gchar *name; /* name of the property */ gchar *name; /* name of the property */
GstControlSource *csource; /* GstControlSource for this property */ GstControlSource *csource; /* GstControlSource for this property */
gboolean disabled; gboolean disabled;
GValue last_value;
} GstControlledProperty; } GstControlledProperty;
#define GST_CONTROLLED_PROPERTY(obj) ((GstControlledProperty *)(obj)) #define GST_CONTROLLED_PROPERTY(obj) ((GstControlledProperty *)(obj))