clutter-master-clock: Don't wait for a frame if time goes backwards
authorNeil Roberts <neil@linux.intel.com>
Fri, 5 Feb 2010 21:56:31 +0000 (21:56 +0000)
committerNeil Roberts <neil@linux.intel.com>
Mon, 8 Feb 2010 11:13:55 +0000 (11:13 +0000)
If we aren't syncing to vblank or if the last dispatch didn't cause a
redraw then the master clock will try to wait at least a small amount
of time before dispatching again. However if time goes backwards then
it would not do a dispatch until time catches up again. To fix this it
know just runs a dispatch immediately if time goes backwards.

This is related to Moblin bug #3839. There was a similar fix for this
in 9dc012c07, however that only fixed the case where timelines
wouldn't update. If there are no animations running then the master
clock won't even try updating timelines until time catches up.

http://bugzilla.o-hand.com/show_bug.cgi?id=1974

clutter/clutter-master-clock.c

index 9e54b9e..ee66396 100644 (file)
@@ -179,6 +179,17 @@ master_clock_next_frame_delay (ClutterMasterClock *master_clock)
   g_source_get_current_time (master_clock->source, &now);
 
   next = master_clock->prev_tick;
+
+  /* If time has gone backwards then there's no way of knowing how
+     long we should wait so let's just dispatch immediately */
+  if (now.tv_sec < next.tv_sec ||
+      (now.tv_sec == next.tv_sec && now.tv_usec <= next.tv_usec))
+    {
+      CLUTTER_NOTE (SCHEDULER, "Time has gone backwards");
+
+      return 0;
+    }
+
   g_time_val_add (&next, 1000000L / (gulong) clutter_get_default_frame_rate ());
 
   if (next.tv_sec < now.tv_sec ||