From eb8e429c800ef133184b097263f3e2cf48b3ca13 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Tue, 10 Mar 2020 16:01:02 +0000 Subject: [PATCH] timeline-element: make start and duration EXPLICIT_NOTIFY The properties will only have their signal emitted when they change in value, even when g_object_set, etc, methods are used. The _set_start method already did this, but start was missing the EXPLICIT_NOTIFY flag. There should be no need to check that the property has changed in ->set_start or ->set_duration --- ges/ges-timeline-element.c | 17 +++++++++++++---- ges/ges-timeline-element.h | 24 ++++++++++++++++++------ ges/ges-track-element.c | 6 ------ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ges/ges-timeline-element.c b/ges/ges-timeline-element.c index ad85b8a241..d7cac8dfc2 100644 --- a/ges/ges-timeline-element.c +++ b/ges/ges-timeline-element.c @@ -409,7 +409,8 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass) * to any source content. */ properties[PROP_START] = g_param_spec_uint64 ("start", "Start", - "The position in the timeline", 0, G_MAXUINT64, 0, G_PARAM_READWRITE); + "The position in the timeline", 0, G_MAXUINT64, 0, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); /** * GESTimelineElement:in-point: @@ -444,7 +445,8 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass) */ properties[PROP_DURATION] = g_param_spec_uint64 ("duration", "Duration", "The play duration", 0, - G_MAXUINT64, GST_CLOCK_TIME_NONE, G_PARAM_READWRITE); + G_MAXUINT64, GST_CLOCK_TIME_NONE, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); /** * GESTimelineElement:max-duration: @@ -1081,6 +1083,8 @@ ges_timeline_element_set_start (GESTimelineElement * self, GstClockTime start) klass = GES_TIMELINE_ELEMENT_GET_CLASS (self); if (klass->set_start) { gint res = klass->set_start (self, start); + if (res == FALSE) + return FALSE; if (res == TRUE && emit_notify) { self->start = start; g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_START]); @@ -1089,7 +1093,7 @@ ges_timeline_element_set_start (GESTimelineElement * self, GstClockTime start) GST_DEBUG_OBJECT (self, "New start: %" GST_TIME_FORMAT, GST_TIME_ARGS (GES_TIMELINE_ELEMENT_START (self))); - return ! !res; + return TRUE; } GST_WARNING_OBJECT (self, "No set_start virtual method implementation" @@ -1236,6 +1240,9 @@ ges_timeline_element_set_duration (GESTimelineElement * self, g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), FALSE); + if (duration == self->duration) + return TRUE; + toplevel = ges_timeline_element_get_toplevel_parent (self); if (self->timeline && !ELEMENT_FLAG_IS_SET (self, GES_TIMELINE_ELEMENT_SET_SIMPLE) && @@ -1264,12 +1271,14 @@ ges_timeline_element_set_duration (GESTimelineElement * self, klass = GES_TIMELINE_ELEMENT_GET_CLASS (self); if (klass->set_duration) { gint res = klass->set_duration (self, duration); + if (res == FALSE) + return FALSE; if (res == TRUE && emit_notify) { self->duration = duration; g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DURATION]); } - return ! !res; + return TRUE; } GST_WARNING_OBJECT (self, "No set_duration virtual method implementation" diff --git a/ges/ges-timeline-element.h b/ges/ges-timeline-element.h index 94af06b993..9618a71672 100644 --- a/ges/ges-timeline-element.h +++ b/ges/ges-timeline-element.h @@ -168,12 +168,24 @@ struct _GESTimelineElement * @set_parent: Method called just before the #GESTimelineElement:parent * is set. * @set_start: Method called just before the #GESTimelineElement:start is - * set. A return of -1 means that the subclass handled emitting the notify - * signal and the base class should return %TRUE. - * @set_duration: Method called just before the - * #GESTimelineElement:duration is set. A return of -1 means that the - * subclass handled emitting the notify signal and the base class should - * return %TRUE. + * set. This method should check whether the #GESTimelineElement:start can + * be changed to the new value and to otherwise prepare the element in + * response to what the new value will be. A return of %FALSE means that + * the property should not be set. A return of %TRUE means that the + * property should be set to the value given to the setter and a notify + * emitted. A return of -1 means that the property should not be set but + * the setter should still return %TRUE (normally because the method + * already handled setting the value, potentially to a snapped value, and + * emitted the notify signal). + * #GESTimelineElement:duration is set. This method should check + * whether the #GESTimelineElement:duration can be changed to the new + * value and to otherwise prepare the element in response to what the new + * value will be. A return of %FALSE means that the property should not be + * set. A return of %TRUE means that the property should be set to the + * value given to the setter and a notify emitted. A return of -1 means + * that the property should not be set but the setter should still return + * %TRUE (normally because the method already handled setting the value, + * potentially to a snapped value, and emitted the notify signal). * @set_inpoint: Method called just before the * #GESTimelineElement:in-point is set to a new value. This method should * not set the #GESTimelineElement:in-point itself, but should check diff --git a/ges/ges-track-element.c b/ges/ges-track-element.c index d3f3381f40..1a2483fc1e 100644 --- a/ges/ges-track-element.c +++ b/ges/ges-track-element.c @@ -580,9 +580,6 @@ _set_start (GESTimelineElement * element, GstClockTime start) g_return_val_if_fail (object->priv->nleobject, FALSE); - if (G_UNLIKELY (start == _START (object))) - return -1; - g_object_set (object->priv->nleobject, "start", start, NULL); return TRUE; @@ -628,9 +625,6 @@ _set_duration (GESTimelineElement * element, GstClockTime duration) duration > _INPOINT (object) + _MAXDURATION (element)) duration = _MAXDURATION (element) - _INPOINT (object); - if (G_UNLIKELY (duration == _DURATION (object))) - return -1; - g_object_set (priv->nleobject, "duration", duration, NULL); _update_control_bindings (element, ges_timeline_element_get_inpoint (element),