glib-mainloop: Drop deprecated g_get_current_time() usage
authorArun Raghavan <arun@asymptotic.io>
Thu, 23 Jul 2020 23:36:11 +0000 (19:36 -0400)
committerArun Raghavan <arun@arunraghavan.net>
Mon, 23 Nov 2020 19:02:33 +0000 (19:02 +0000)
This uses the year 2038-safe g_get_real_time() as recommended instead.
Bumps GLib dependency to 2.28 as a result.

configure.ac
meson.build
src/pulse/glib-mainloop.c

index a519e63..caabef6 100644 (file)
@@ -894,7 +894,7 @@ AC_ARG_ENABLE([glib2],
     AS_HELP_STRING([--disable-glib2],[Disable optional GLib 2 support]))
 
 AS_IF([test "x$enable_glib2" != "xno"],
-    [PKG_CHECK_MODULES(GLIB20, [ glib-2.0 >= 2.4.0 ], HAVE_GLIB20=1, HAVE_GLIB20=0)],
+    [PKG_CHECK_MODULES(GLIB20, [ glib-2.0 >= 2.28.0 ], HAVE_GLIB20=1, HAVE_GLIB20=0)],
     HAVE_GLIB20=0)
 
 AS_IF([test "x$enable_glib2" = "xyes" && test "x$HAVE_GLIB20" = "x0"],
index 658eeee..1c671d3 100644 (file)
@@ -556,7 +556,7 @@ if gio_dep.found()
   cdata.set('HAVE_GSETTINGS', 1)
 endif
 
-glib_dep = dependency('glib-2.0', version : '>= 2.4.0', required: get_option('glib'))
+glib_dep = dependency('glib-2.0', version : '>= 2.28.0', required: get_option('glib'))
 if glib_dep.found()
   cdata.set('HAVE_GLIB', 1)
 endif
index 1ce3cd3..77295de 100644 (file)
@@ -482,16 +482,15 @@ static gboolean prepare_func(GSource *source, gint *timeout) {
         return TRUE;
     } else if (g->n_enabled_time_events) {
         pa_time_event *t;
-        GTimeVal now;
+        gint64 now;
         struct timeval tvnow;
         pa_usec_t usec;
 
         t = find_next_time_event(g);
         g_assert(t);
 
-        g_get_current_time(&now);
-        tvnow.tv_sec = now.tv_sec;
-        tvnow.tv_usec = now.tv_usec;
+        now = g_get_real_time();
+        pa_timeval_store(&tvnow, now);
 
         if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0) {
             *timeout = 0;
@@ -514,15 +513,14 @@ static gboolean check_func(GSource *source) {
         return TRUE;
     else if (g->n_enabled_time_events) {
         pa_time_event *t;
-        GTimeVal now;
+        gint64 now;
         struct timeval tvnow;
 
         t = find_next_time_event(g);
         g_assert(t);
 
-        g_get_current_time(&now);
-        tvnow.tv_sec = now.tv_sec;
-        tvnow.tv_usec = now.tv_usec;
+        now = g_get_real_time();
+        pa_timeval_store(&tvnow, now);
 
         if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0)
             return TRUE;
@@ -558,16 +556,15 @@ static gboolean dispatch_func(GSource *source, GSourceFunc callback, gpointer us
     }
 
     if (g->n_enabled_time_events) {
-        GTimeVal now;
+        gint64 now;
         struct timeval tvnow;
         pa_time_event *t;
 
         t = find_next_time_event(g);
         g_assert(t);
 
-        g_get_current_time(&now);
-        tvnow.tv_sec = now.tv_sec;
-        tvnow.tv_usec = now.tv_usec;
+        now = g_get_real_time();
+        pa_timeval_store(&tvnow, now);
 
         if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0) {