tests: Remove deprecated GTimeVal
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Tue, 10 Dec 2019 22:09:57 +0000 (17:09 -0500)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 18 Dec 2019 18:20:25 +0000 (18:20 +0000)
GTimeVal won't work past 2038

tests/examples/gl/qt/mousevideooverlay/pipeline.cpp
tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp

index 28d8cf8..bca4862 100644 (file)
@@ -175,8 +175,8 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
 //client draw callback
 gboolean Pipeline::drawCallback (void * sink, void *context, GstSample * sample, gpointer data)
 {
-    static GTimeVal current_time;
-    static glong last_sec = current_time.tv_sec;
+    static gint64 current_time;
+    static glong last_sec = 0;
     static gint nbFrames = 0;
 
     GstVideoFrame v_frame;
@@ -194,14 +194,14 @@ gboolean Pipeline::drawCallback (void * sink, void *context, GstSample * sample,
 
     texture = *(guint *) v_frame.data[0];
 
-    g_get_current_time (&current_time);
+    current_time = g_get_monotonic_time ();
     nbFrames++ ;
     
-    if ((current_time.tv_sec - last_sec) >= 1)
+    if ((current_time / G_USEC_PER_SEC - last_sec) >= 1)
     {
         qDebug ("GRAPHIC FPS = %d", nbFrames);
         nbFrames = 0;
-        last_sec = current_time.tv_sec;
+        last_sec = current_time / G_USEC_PER_SEC;
     }
   
     glEnable(GL_DEPTH_TEST);
index 301d3b6..21e38f2 100644 (file)
@@ -160,8 +160,8 @@ gboolean Pipeline::drawCallback (GstElement * gl_sink, void *context, GstSample
     static GLfloat     xrot = 0;
     static GLfloat     yrot = 0;                               
     static GLfloat     zrot = 0;
-    static GTimeVal current_time;
-    static glong last_sec = current_time.tv_sec;
+    static gint64 current_time;
+    static glong last_sec = 0;
     static gint nbFrames = 0;  
 
     GstVideoFrame v_frame;
@@ -179,14 +179,14 @@ gboolean Pipeline::drawCallback (GstElement * gl_sink, void *context, GstSample
 
     texture = *(guint *) v_frame.data[0];
 
-    g_get_current_time (&current_time);
+    current_time = g_get_monotonic_time ();
     nbFrames++ ;
     
-    if ((current_time.tv_sec - last_sec) >= 1)
+    if ((current_time / G_USEC_PER_SEC - last_sec) >= 1)
     {
         qDebug ("GRPHIC FPS = %d", nbFrames);
         nbFrames = 0;
-        last_sec = current_time.tv_sec;
+        last_sec = current_time / G_USEC_PER_SEC;
     }
   
     glEnable(GL_DEPTH_TEST);