libs/gst/controller/gstcontroller.c: Aggregate return value for gst_controller_sync_v...
authorStefan Kost <ensonic@users.sourceforge.net>
Tue, 9 Dec 2008 09:56:25 +0000 (09:56 +0000)
committerStefan Kost <ensonic@users.sourceforge.net>
Tue, 9 Dec 2008 09:56:25 +0000 (09:56 +0000)
Original commit message from CVS:
* libs/gst/controller/gstcontroller.c:
Aggregate return value for gst_controller_sync_values(). More info in
logging. Always set values on first sync-call.
* libs/gst/controller/gstcontrolsource.c:
Microoptimizations.
* libs/gst/controller/gsthelper.c:
Fix return code and comment.

ChangeLog
libs/gst/controller/gstcontroller.c
libs/gst/controller/gstcontrolsource.c
libs/gst/controller/gsthelper.c

index 975adaf..7f3d0c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2008-12-09  Stefan Kost  <ensonic@users.sf.net>
 
+       * libs/gst/controller/gstcontroller.c:
+         Aggregate return value for gst_controller_sync_values(). More info in
+         logging. Always set values on first sync-call.
+
+       * libs/gst/controller/gstcontrolsource.c:
+         Microoptimizations.
+
+       * libs/gst/controller/gsthelper.c:
+         Fix return code and comment.
+         
+
+2008-12-09  Stefan Kost  <ensonic@users.sf.net>
+
        * tools/gst-launch.1.in:
          Fix description of how to specify a type in caps. Fixes #553873.
          Also ranges and list contain values and not property-assignments.
index b9d37e1..cf3bebc 100644 (file)
@@ -586,7 +586,8 @@ gst_controller_get_control_source (GstController * self, gchar * property_name)
  * Gets the value for the given controller-handled property at the requested
  * time.
  *
- * Returns: the GValue of the property at the given time, or %NULL if the property isn't handled by the controller
+ * Returns: the GValue of the property at the given time, or %NULL if the
+ * property isn't handled by the controller
  */
 GValue *
 gst_controller_get (GstController * self, gchar * property_name,
@@ -661,6 +662,9 @@ gst_controller_suggest_next_sync (GstController * self)
  * Sets the properties of the element, according to the controller that (maybe)
  * handles them and for the given timestamp.
  *
+ * If this function fails, it is most likely the application developers fault.
+ * Most probably the control sources are not setup correctly.
+ *
  * Returns: %TRUE if the controller values could be applied to the object
  * properties, %FALSE otherwise
  */
@@ -669,7 +673,7 @@ gst_controller_sync_values (GstController * self, GstClockTime timestamp)
 {
   GstControlledProperty *prop;
   GList *node;
-  gboolean ret = FALSE;
+  gboolean ret = TRUE, val_ret;
   GValue value = { 0, };
 
   g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
@@ -683,25 +687,31 @@ gst_controller_sync_values (GstController * self, GstClockTime timestamp)
   for (node = self->properties; node; node = g_list_next (node)) {
     prop = node->data;
 
-    GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
-
     if (!prop->csource || prop->disabled)
       continue;
 
+    GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
+
     /* we can make this faster
      * http://bugzilla.gnome.org/show_bug.cgi?id=536939
      */
     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)) {
-      if (gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) {
+    val_ret = gst_control_source_get_value (prop->csource, timestamp, &value);
+    if (G_LIKELY (val_ret)) {
+      /* always set the value for first time, but then only if it changed
+       * this should limit g_object_notify invocations.
+       * FIXME: can we detect negative playback rates?
+       */
+      if ((timestamp < self->priv->last_sync) ||
+          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");
+      GST_DEBUG ("no control value for param %s", prop->name);
     }
     g_value_unset (&value);
+    ret &= val_ret;
   }
   self->priv->last_sync = timestamp;
   g_object_thaw_notify (self->object);
index 4dc9045..284c084 100644 (file)
@@ -92,7 +92,7 @@ gst_control_source_get_value (GstControlSource * self, GstClockTime timestamp,
 {
   g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE);
 
-  if (self->get_value) {
+  if (G_LIKELY (self->get_value)) {
     return self->get_value (self, timestamp, value);
   } else {
     GST_ERROR ("Not bound to a specific property yet!");
@@ -122,7 +122,7 @@ gst_control_source_get_value_array (GstControlSource * self,
 {
   g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE);
 
-  if (self->get_value_array) {
+  if (G_LIKELY (self->get_value_array)) {
     return self->get_value_array (self, timestamp, value_array);
   } else {
     GST_ERROR ("Not bound to a specific property yet!");
index 55bacfd..01dafae 100644 (file)
@@ -186,7 +186,10 @@ gst_object_sync_values (GObject * object, GstClockTime timestamp)
   if ((ctrl = g_object_get_qdata (object, priv_gst_controller_key))) {
     return gst_controller_sync_values (ctrl, timestamp);
   }
-  return (FALSE);
+  /* this is no failure, its called by elements regardless if there is a
+   * controller assigned or not
+   */
+  return (TRUE);
 }
 
 /**