libs/gst/controller/: Save last synced value from the list to continue searching...
authorSebastian Dröge <slomo@circular-chaos.org>
Thu, 17 May 2007 17:16:09 +0000 (17:16 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Thu, 17 May 2007 17:16:09 +0000 (17:16 +0000)
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_controller_unset),
(gst_controller_unset_all):
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node):
Save last synced value from the list to continue searching from there
in future syncs. This speeds everything up a bit.

ChangeLog
libs/gst/controller/gstcontroller.c
libs/gst/controller/gstcontrollerprivate.h
libs/gst/controller/gstinterpolation.c

index f7a5818..1bc4d52 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 
        reviewed by: Stefan Kost <ensonic@users.sf.net>
 
+       * libs/gst/controller/gstcontroller.c: (gst_controller_unset),
+       (gst_controller_unset_all):
+       * libs/gst/controller/gstcontrollerprivate.h:
+       * libs/gst/controller/gstinterpolation.c:
+       (gst_controlled_property_find_control_point_node):
+       Save last synced value from the list to continue searching from there
+       in future syncs. This speeds everything up a bit.
+       
+2007-05-17  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       reviewed by: Stefan Kost <ensonic@users.sf.net>
+
        * libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
        (gst_control_point_find), (gst_controlled_property_new),
        (gst_control_point_free), (gst_controlled_property_free),
index 3930ed2..43141e6 100644 (file)
@@ -853,6 +853,8 @@ gst_controller_unset (GstController * self, gchar * property_name,
     /* check if a control point for the timestamp exists */
     if ((node = g_list_find_custom (prop->values, &timestamp,
                 gst_control_point_find))) {
+      if (node == prop->last_requested_value)
+        prop->last_requested_value = NULL;
       gst_control_point_free (node->data);      /* free GstControlPoint */
       prop->values = g_list_delete_link (prop->values, node);
       res = TRUE;
@@ -888,6 +890,7 @@ gst_controller_unset_all (GstController * self, gchar * property_name)
     /* free GstControlPoint structures */
     g_list_foreach (prop->values, (GFunc) gst_control_point_free, NULL);
     g_list_free (prop->values);
+    prop->last_requested_value = NULL;
     prop->values = NULL;
     res = TRUE;
   }
index 8bfd067..398ae67 100644 (file)
@@ -106,9 +106,7 @@ typedef struct _GstControlledProperty
   InterpolateGetValueArray get_value_array;
 
   GList *values;                /* List of GstControlPoint */
-  /* TODO keep the last search result to be able to continue
-     GList      *last_value;     // last search result, can be used for incremental searches
-   */
+  GList *last_requested_value;  /* last search result, can be used for incremental searches */
 
   /*< private >*/
   gpointer       _gst_reserved[GST_PADDING];
index c33442a..c7c4c79 100644 (file)
@@ -44,23 +44,20 @@ GList *
 gst_controlled_property_find_control_point_node (GstControlledProperty * prop,
     GstClockTime timestamp)
 {
-  /* GList *prev_node = NULL; */
   GList *prev_node = g_list_last (prop->values);
   GList *node;
   GstControlPoint *cp;
 
-  /*
-     if((prop->last_value) &&
-     (timestamp>((GstTimedValue *)(prop->last_value->data))->timestamp)) {
-     node=prop->last_value;
-     }
-     else {
-     node=prop->values;
-     }
-   */
+  node = prop->values;
+  if (prop->last_requested_value) {
+    GstControlPoint *last_cp = prop->last_requested_value->data;
+
+    if (timestamp > last_cp->timestamp)
+      node = prop->last_requested_value;
+  }
 
   /* iterate over timed value list */
-  for (node = prop->values; node; node = g_list_next (node)) {
+  for (; node; node = g_list_next (node)) {
     cp = node->data;
     /* this timestamp is newer that the one we look for */
     if (timestamp < cp->timestamp) {
@@ -69,11 +66,10 @@ gst_controlled_property_find_control_point_node (GstControlledProperty * prop,
       break;
     }
   }
-  /*
-     if(node) {
-     prop->last_value=prev_node;
-     }
-   */
+
+  if (prev_node)
+    prop->last_requested_value = prev_node;
+
   return (prev_node);
 }