From 24338a7511cd09298695f0a0b51ea6a97fa6786a Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 5 Feb 2010 21:56:31 +0000 Subject: [PATCH] clutter-master-clock: Don't wait for a frame if time goes backwards 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/clutter/clutter-master-clock.c b/clutter/clutter-master-clock.c index 9e54b9e..ee66396 100644 --- a/clutter/clutter-master-clock.c +++ b/clutter/clutter-master-clock.c @@ -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 || -- 2.7.4