Remove deprecated GTimeVal
authorOlivier Crête <olivier.crete@collabora.com>
Tue, 10 Dec 2019 22:06:02 +0000 (17:06 -0500)
committerOlivier Crête <olivier.crete@collabora.com>
Wed, 11 Dec 2019 00:18:32 +0000 (19:18 -0500)
GTimeVal won't work past 2038

gst/gstsystemclock.c
libs/gst/base/gstcollectpads.c
tests/check/elements/tee.c

index df155d79597c23f629b1d5feeb406ab70dc6f2f8..2d56d2079350f06d2968b32e3cce2d4cdee29bde 100644 (file)
@@ -589,11 +589,11 @@ gst_system_clock_get_internal_time (GstClock * clock)
 #endif /* G_OS_WIN32 */
 #if !defined HAVE_POSIX_TIMERS || !defined HAVE_CLOCK_GETTIME
   {
-    GTimeVal timeval;
+    gint64 monotime;
 
-    g_get_current_time (&timeval);
+    monotime = g_get_monotonic_time ();
 
-    return GST_TIMEVAL_TO_TIME (timeval);
+    return monotime * 1000;
   }
 #else
   {
index dec4fb306a57b014cbfbe40105516416ddbc88ac..9fb4616dc2636fb09a6f206fcae1e77967df1390 100644 (file)
@@ -171,16 +171,13 @@ static gboolean gst_collect_pads_query_default_internal (GstCollectPads *
   g_mutex_unlock (GST_COLLECT_PADS_GET_EVT_LOCK (pads));          \
 } G_STMT_END
 #define GST_COLLECT_PADS_EVT_WAIT_TIMED(pads, cookie, timeout) G_STMT_START { \
-  GTimeVal __tv; \
-  \
-  g_get_current_time (&tv); \
-  g_time_val_add (&tv, timeout); \
+  gint64 end_time = g_get_monotonic_time () + timeout; \
   \
   g_mutex_lock (GST_COLLECT_PADS_GET_EVT_LOCK (pads));            \
   /* should work unless a lot of event'ing and thread starvation */\
   while (cookie == ((GstCollectPads *) pads)->priv->evt_cookie)         \
-    g_cond_timed_wait (GST_COLLECT_PADS_GET_EVT_COND (pads),            \
-        GST_COLLECT_PADS_GET_EVT_LOCK (pads), &tv);                    \
+    g_cond_wait_until (GST_COLLECT_PADS_GET_EVT_COND (pads),            \
+        GST_COLLECT_PADS_GET_EVT_LOCK (pads), end_time);                    \
   cookie = ((GstCollectPads *) pads)->priv->evt_cookie;                 \
   g_mutex_unlock (GST_COLLECT_PADS_GET_EVT_LOCK (pads));          \
 } G_STMT_END
index acee40c701f8cfe86405e5a3f6cee6a0cc13560b..7e0f4c09fd43daa6a62d8d422d4e202e5540811c 100644 (file)
@@ -265,7 +265,7 @@ final_sinkpad_bufferalloc (GstPad * pad, guint64 offset, guint size,
     GstCaps * caps, GstBuffer ** buf)
 {
   BufferAllocHarness *h;
-  GTimeVal deadline;
+  gint64 deadline;
 
   h = g_object_get_qdata (G_OBJECT (pad),
       g_quark_from_static_string ("buffer-alloc-harness"));
@@ -288,10 +288,10 @@ final_sinkpad_bufferalloc (GstPad * pad, guint64 offset, guint size,
     /* Now wait for it to do that within a second, to avoid deadlocking
      * in the event of future changes to the locking semantics. */
     g_mutex_lock (&check_mutex);
-    g_get_current_time (&deadline);
-    deadline.tv_sec += 1;
+    deadline = g_get_monotonic_time ();
+    deadline += G_USEC_PER_SEC;
     while (h->bufferalloc_blocked) {
-      if (!g_cond_timed_wait (&check_cond, &check_mutex, &deadline))
+      if (!g_cond_wait_until (&check_cond, &check_mutex, deadline))
         break;
     }
     g_mutex_unlock (&check_mutex);