controller: add api to check for active controllers (needed for e.g. volume)
authorStefan Sauer <ensonic@users.sf.net>
Fri, 4 Nov 2011 19:50:58 +0000 (20:50 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Fri, 4 Nov 2011 19:50:58 +0000 (20:50 +0100)
docs/gst/gstreamer-sections.txt
gst/gstcontroller.c
gst/gstcontroller.h
gst/gstobject.c
gst/gstobject.h

index 0f6b873..a558a54 100644 (file)
@@ -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
index 5d8baae..7015f9f 100644 (file)
@@ -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
index b4b0c3f..ec090c6 100644 (file)
@@ -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);
index 8861b38..411ade0 100644 (file)
@@ -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)
index a46118c..5c15065 100644 (file)
@@ -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);