From efd4402ee0290a8c67f06a876fed058afb433408 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 4 Nov 2011 20:50:58 +0100 Subject: [PATCH] controller: add api to check for active controllers (needed for e.g. volume) --- docs/gst/gstreamer-sections.txt | 2 ++ gst/gstcontroller.c | 30 ++++++++++++++++++++++++++-- gst/gstcontroller.h | 1 + gst/gstobject.c | 43 +++++++++++++++++++++++++++++++++++++++-- gst/gstobject.h | 1 + 5 files changed, 73 insertions(+), 4 deletions(-) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 0f6b873..a558a54 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -569,6 +569,7 @@ gst_controller_add_properties_valist gst_controller_remove_properties gst_controller_remove_properties_list gst_controller_remove_properties_valist +gst_controller_is_active gst_controller_set_disabled gst_controller_set_property_disabled gst_controller_suggest_next_sync @@ -1575,6 +1576,7 @@ gst_object_control_properties gst_object_uncontrol_properties gst_object_suggest_next_sync gst_object_sync_values +gst_object_has_active_automation gst_object_set_automation_disabled gst_object_set_property_automation_disabled gst_object_get_control_source diff --git a/gst/gstcontroller.c b/gst/gstcontroller.c index 5d8baae..7015f9f 100644 --- a/gst/gstcontroller.c +++ b/gst/gstcontroller.c @@ -491,6 +491,34 @@ gst_controller_remove_properties (GstController * self, ...) } /** + * gst_controller_is_active: + * @self: the #GstController which should be disabled + * + * Check if the controller is active. It is active if it has at least one + * controlled property that is not disabled. + * + * Returns: %TRUE if the controller is active + */ +gboolean +gst_controller_is_active (GstController * self) +{ + gboolean active = FALSE; + GList *node; + GstControlledProperty *prop; + + g_return_if_fail (GST_IS_CONTROLLER (self)); + + g_mutex_lock (self->lock); + for (node = self->properties; node; node = node->next) { + prop = node->data; + active |= !prop->disabled; + } + g_mutex_unlock (self->lock); + + return active; +} + +/** * gst_controller_set_property_disabled: * @self: the #GstController which should be disabled * @property_name: property to disable @@ -501,7 +529,6 @@ gst_controller_remove_properties (GstController * self, ...) * some time, i.e. gst_controller_sync_values() will do nothing for the * property. */ - void gst_controller_set_property_disabled (GstController * self, const gchar * property_name, gboolean disabled) @@ -518,7 +545,6 @@ gst_controller_set_property_disabled (GstController * self, g_mutex_unlock (self->lock); } - /** * gst_controller_set_disabled: * @self: the #GstController which should be disabled diff --git a/gst/gstcontroller.h b/gst/gstcontroller.h index b4b0c3f..ec090c6 100644 --- a/gst/gstcontroller.h +++ b/gst/gstcontroller.h @@ -93,6 +93,7 @@ gboolean gst_controller_remove_properties_valist (GstController * self, va_list gboolean gst_controller_remove_properties_list (GstController * self, GList *list); gboolean gst_controller_remove_properties (GstController * self, ...) G_GNUC_NULL_TERMINATED; +gboolean gst_controller_is_active (GstController * self); void gst_controller_set_disabled (GstController *self, gboolean disabled); void gst_controller_set_property_disabled (GstController *self, const gchar * property_name, gboolean disabled); gboolean gst_controller_set_control_source (GstController *self, const gchar * property_name, GstControlSource *csource); diff --git a/gst/gstobject.c b/gst/gstobject.c index 8861b38..411ade0 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -1059,7 +1059,36 @@ gst_object_sync_values (GstObject * object, GstClockTime timestamp) return (TRUE); } -// FIXME: docs +/** + * gst_object_has_active_automation: + * @object: the object that has controlled properties + * + * Check if the object has an active controller. It has one if it has at least + * one controlled property that is not disabled. + * + * Returns: %TRUE if the controller is active + */ +gboolean +gst_object_has_active_automation (GstObject * object) +{ + gboolean res = FALSE; + + g_return_if_fail (GST_IS_OBJECT (object)); + + if (object->ctrl) + res = gst_controller_is_active ((GstController *) object->ctrl); + return res; +} + +/** + * gst_object_set_automation_disabled: + * @object: the object that has controlled properties + * @disabled: boolean that specifies whether to disable the controller + * or not. + * + * This function is used to disable all properties of the #GstController + * for some time, i.e. gst_object_sync_values() will do nothing.. + */ void gst_object_set_automation_disabled (GstObject * object, gboolean disabled) { @@ -1069,7 +1098,17 @@ gst_object_set_automation_disabled (GstObject * object, gboolean disabled) gst_controller_set_disabled (object->ctrl, disabled); } -// FIXME: docs +/** + * gst_object_set_property_automation_disabled: + * @object: the object that has controlled properties + * @property_name: property to disable + * @disabled: boolean that specifies whether to disable the controller + * or not. + * + * This function is used to disable the #GstController on a property for + * some time, i.e. gst_controller_sync_values() will do nothing for the + * property. + */ void gst_object_set_property_automation_disabled (GstObject * object, const gchar * property_name, gboolean disabled) diff --git a/gst/gstobject.h b/gst/gstobject.h index a46118c..5c15065 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -238,6 +238,7 @@ gboolean gst_object_uncontrol_properties (GstObject * object, ...) G_GNUC_NULL_T GstClockTime gst_object_suggest_next_sync (GstObject * object); gboolean gst_object_sync_values (GstObject * object, GstClockTime timestamp); +gboolean gst_object_has_active_automation (GstObject *object); void gst_object_set_automation_disabled (GstObject *object, gboolean disabled); void gst_object_set_property_automation_disabled (GstObject *object, const gchar * property_name, gboolean disabled); -- 2.7.4