Start using the monotonic API in GLib ≥ 2.27

Starting from the 2.27 cycle, GLib is exposing a monotonic clock with
microseconds granularity throughout the time-based API. We can start
using it, given that the old, non-monotonic version is going to be
deprecated by the same cycle.
This commit is contained in:
Emmanuele Bassi
2010-11-07 16:20:51 +00:00
parent 68d7a5e847
commit 8f60d5a3a2
4 changed files with 49 additions and 18 deletions

View File

@ -34,12 +34,17 @@ void
_clutter_timeout_interval_init (ClutterTimeoutInterval *interval,
guint fps)
{
GTimeVal start_time;
#if GLIB_CHECK_VERSION (2, 27, 3)
interval->start_time = g_get_monotonic_time () / 1000;
#else
{
GTimeVal start_time;
g_get_current_time (&start_time);
interval->start_time = start_time.tv_sec * 1000
+ start_time.tv_usec / 1000;
}
#endif
g_get_current_time (&start_time);
interval->start_time = start_time.tv_sec * 1000
+ start_time.tv_usec / 1000;
interval->fps = fps;
interval->frame_count = 0;
}