From: Edward Hervey Date: Thu, 10 Oct 2019 15:18:34 +0000 (+0200) Subject: base: Avoid usage of deprecated API X-Git-Tag: 1.19.3~511^2~910 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2409f4f3609d2dce3f65d1a8c4be5e470b7cf9d3;p=platform%2Fupstream%2Fgstreamer.git base: Avoid usage of deprecated API GTimeval and related functions are now deprecated in glib. Replacement APIs have been present since 2.26 --- diff --git a/gst/tcp/gstmultifdsink.c b/gst/tcp/gstmultifdsink.c index b3d9475..900a8ff 100644 --- a/gst/tcp/gstmultifdsink.c +++ b/gst/tcp/gstmultifdsink.c @@ -673,7 +673,6 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink, gboolean more; gboolean flushing; GstClockTime now; - GTimeVal nowtv; GstMultiHandleSink *mhsink = GST_MULTI_HANDLE_SINK (sink); GstMultiHandleSinkClass *mhsinkclass = GST_MULTI_HANDLE_SINK_GET_CLASS (mhsink); @@ -686,8 +685,7 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink, do { gint maxsize; - g_get_current_time (&nowtv); - now = GST_TIMEVAL_TO_TIME (nowtv); + now = g_get_real_time () * GST_USECOND; if (!mhclient->sending) { /* client is not working on a buffer */ @@ -905,10 +903,8 @@ gst_multi_fd_sink_handle_clients (GstMultiFdSink * sink) * and will not disconnect inactive client in the streaming thread. */ if (G_UNLIKELY (result == 0)) { GstClockTime now; - GTimeVal nowtv; - g_get_current_time (&nowtv); - now = GST_TIMEVAL_TO_TIME (nowtv); + now = g_get_real_time () * GST_USECOND; CLIENTS_LOCK (mhsink); for (clients = mhsink->clients; clients; clients = next) { diff --git a/gst/tcp/gstmultihandlesink.c b/gst/tcp/gstmultihandlesink.c index 44a336d..d595567 100644 --- a/gst/tcp/gstmultihandlesink.c +++ b/gst/tcp/gstmultihandlesink.c @@ -599,8 +599,6 @@ void gst_multi_handle_sink_client_init (GstMultiHandleClient * client, GstSyncMethod sync_method) { - GTimeVal now; - client->status = GST_CLIENT_STATUS_OK; client->bufpos = -1; client->flushcount = -1; @@ -616,8 +614,7 @@ gst_multi_handle_sink_client_init (GstMultiHandleClient * client, client->currently_removing = FALSE; /* update start time */ - g_get_current_time (&now); - client->connect_time = GST_TIMEVAL_TO_TIME (now); + client->connect_time = g_get_real_time () * GST_USECOND; client->disconnect_time = 0; /* set last activity time to connect time */ client->last_activity_time = client->connect_time; @@ -883,11 +880,7 @@ gst_multi_handle_sink_get_stats (GstMultiHandleSink * sink, result = gst_structure_new_empty ("multihandlesink-stats"); if (mhclient->disconnect_time == 0) { - GTimeVal nowtv; - - g_get_current_time (&nowtv); - - interval = GST_TIMEVAL_TO_TIME (nowtv) - mhclient->connect_time; + interval = (g_get_real_time () * GST_USECOND) - mhclient->connect_time; } else { interval = mhclient->disconnect_time - mhclient->connect_time; } @@ -924,7 +917,6 @@ void gst_multi_handle_sink_remove_client_link (GstMultiHandleSink * sink, GList * link) { - GTimeVal now; GstMultiHandleClient *mhclient = (GstMultiHandleClient *) link->data; GstMultiHandleSinkClass *mhsinkclass = GST_MULTI_HANDLE_SINK_GET_CLASS (sink); @@ -970,8 +962,7 @@ gst_multi_handle_sink_remove_client_link (GstMultiHandleSink * sink, mhsinkclass->hash_removing (sink, mhclient); - g_get_current_time (&now); - mhclient->disconnect_time = GST_TIMEVAL_TO_TIME (now); + mhclient->disconnect_time = g_get_real_time () * GST_USECOND; /* free client buffers */ g_slist_foreach (mhclient->sending, (GFunc) gst_mini_object_unref, NULL); @@ -1681,7 +1672,6 @@ gst_multi_handle_sink_queue_buffer (GstMultiHandleSink * mhsink, gboolean hash_changed = FALSE; gint max_buffer_usage; gint i; - GTimeVal nowtv; GstClockTime now; gint max_buffers, soft_max_buffers; guint cookie; @@ -1734,8 +1724,7 @@ gst_multi_handle_sink_queue_buffer (GstMultiHandleSink * mhsink, } max_buffer_usage = 0; - g_get_current_time (&nowtv); - now = GST_TIMEVAL_TO_TIME (nowtv); + now = g_get_real_time () * GST_USECOND; /* now check for new or slow clients */ restart: diff --git a/gst/tcp/gstmultisocketsink.c b/gst/tcp/gstmultisocketsink.c index 9a5a72c..e064ccb 100644 --- a/gst/tcp/gstmultisocketsink.c +++ b/gst/tcp/gstmultisocketsink.c @@ -823,7 +823,6 @@ gst_multi_socket_sink_handle_client_write (GstMultiSocketSink * sink, gboolean more; gboolean flushing; GstClockTime now; - GTimeVal nowtv; GError *err = NULL; GstMultiHandleSink *mhsink = GST_MULTI_HANDLE_SINK (sink); GstMultiHandleClient *mhclient = (GstMultiHandleClient *) client; @@ -831,8 +830,7 @@ gst_multi_socket_sink_handle_client_write (GstMultiSocketSink * sink, GST_MULTI_HANDLE_SINK_GET_CLASS (mhsink); - g_get_current_time (&nowtv); - now = GST_TIMEVAL_TO_TIME (nowtv); + now = g_get_real_time () * GST_USECOND; flushing = mhclient->status == GST_CLIENT_STATUS_FLUSHING; @@ -1111,12 +1109,10 @@ static gboolean gst_multi_socket_sink_timeout (GstMultiSocketSink * sink) { GstClockTime now; - GTimeVal nowtv; GList *clients; GstMultiHandleSink *mhsink = GST_MULTI_HANDLE_SINK (sink); - g_get_current_time (&nowtv); - now = GST_TIMEVAL_TO_TIME (nowtv); + now = g_get_real_time () * GST_USECOND; CLIENTS_LOCK (mhsink); for (clients = mhsink->clients; clients; clients = clients->next) { diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index e4136a0..bbe5380 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -1081,7 +1081,7 @@ gst_video_test_src_ball (GstVideoTestSrc * v, GstClockTime pts, int i; int radius = 20; int w = frame->info.width, h = frame->info.height; - GTimeVal rand_tv; + gint64 wall_time; gdouble rad = 0; double x, y; int flipit = 0; @@ -1099,10 +1099,10 @@ gst_video_test_src_ball (GstVideoTestSrc * v, GstClockTime pts, flipit = (v->n_frames / 50) % 2; break; case GST_VIDEO_TEST_SRC_WALL_TIME: - g_get_current_time (&rand_tv); + wall_time = g_get_real_time (); - rad = (gdouble) (rand_tv.tv_usec) / 1000000.0 + rand_tv.tv_sec; - flipit = rand_tv.tv_sec % 2; + rad = (gdouble) wall_time / 1000000.0; + flipit = (wall_time / 1000000) % 2; break; case GST_VIDEO_TEST_SRC_RUNNING_TIME: rad = (gdouble) (pts) / GST_SECOND; diff --git a/tests/examples/gl/generic/cube/main.cpp b/tests/examples/gl/generic/cube/main.cpp index 730d952..ce78459 100644 --- a/tests/examples/gl/generic/cube/main.cpp +++ b/tests/examples/gl/generic/cube/main.cpp @@ -79,8 +79,8 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa 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 GstClockTime current_time; + static GstClockTime last_time = gst_util_get_timestamp(); static gint nbFrames = 0; GstVideoFrame v_frame; @@ -98,14 +98,14 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa texture = *(guint *) v_frame.data[0]; - g_get_current_time (¤t_time); + current_time = gst_util_get_timestamp (); nbFrames++ ; - if ((current_time.tv_sec - last_sec) >= 1) + if ((current_time - last_time) >= GST_SECOND) { - std::cout << "GRPHIC FPS = " << nbFrames << std::endl; + std::cout << "GRAPHIC FPS = " << nbFrames << std::endl; nbFrames = 0; - last_sec = current_time.tv_sec; + last_time = current_time; } glEnable(GL_DEPTH_TEST); diff --git a/tests/examples/gl/generic/cubeyuv/main.cpp b/tests/examples/gl/generic/cubeyuv/main.cpp index cc1bb51..dc6b057 100644 --- a/tests/examples/gl/generic/cubeyuv/main.cpp +++ b/tests/examples/gl/generic/cubeyuv/main.cpp @@ -100,8 +100,8 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa 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 GstClockTime current_time; + static GstClockTime last_time = gst_util_get_timestamp(); static gint nbFrames = 0; GstVideoFrame v_frame; @@ -119,14 +119,14 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa texture = *(guint *) v_frame.data[0]; - g_get_current_time (¤t_time); + current_time = gst_util_get_timestamp (); nbFrames++ ; - if ((current_time.tv_sec - last_sec) >= 1) + if ((current_time - last_time) >= GST_SECOND) { - std::cout << "GRPHIC FPS = " << nbFrames << std::endl; + std::cout << "GRAPHIC FPS = " << nbFrames << std::endl; nbFrames = 0; - last_sec = current_time.tv_sec; + last_time = current_time; } glEnable(GL_DEPTH_TEST); diff --git a/tests/examples/gl/generic/doublecube/main.cpp b/tests/examples/gl/generic/doublecube/main.cpp index 73f39cb..71c2720 100644 --- a/tests/examples/gl/generic/doublecube/main.cpp +++ b/tests/examples/gl/generic/doublecube/main.cpp @@ -102,8 +102,8 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa 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 GstClockTime current_time; + static GstClockTime last_time = gst_util_get_timestamp(); static gint nbFrames = 0; GstVideoFrame v_frame; @@ -121,14 +121,14 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa texture = *(guint *) v_frame.data[0]; - g_get_current_time (¤t_time); + current_time = gst_util_get_timestamp (); nbFrames++ ; - if ((current_time.tv_sec - last_sec) >= 1) + if ((current_time - last_time) >= GST_SECOND) { std::cout << "GRAPHIC FPS of the scene which contains the custom cube) = " << nbFrames << std::endl; nbFrames = 0; - last_sec = current_time.tv_sec; + last_time = current_time; } glEnable(GL_DEPTH_TEST); diff --git a/tests/examples/gl/generic/recordgraphic/main.cpp b/tests/examples/gl/generic/recordgraphic/main.cpp index c7436d4..16c315c 100644 --- a/tests/examples/gl/generic/recordgraphic/main.cpp +++ b/tests/examples/gl/generic/recordgraphic/main.cpp @@ -70,18 +70,18 @@ static gboolean drawCallback (void *filter, void *context, GLuint texture, GLuin 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 GstClockTime current_time; + static GstClockTime last_time = gst_util_get_timestamp(); static gint nbFrames = 0; - g_get_current_time (¤t_time); + current_time = gst_util_get_timestamp (); nbFrames++ ; - if ((current_time.tv_sec - last_sec) >= 1) + if ((current_time - last_time) >= GST_SECOND) { - std::cout << "GRPHIC FPS = " << nbFrames << std::endl; + std::cout << "GRAPHIC FPS = " << nbFrames << std::endl; nbFrames = 0; - last_sec = current_time.tv_sec; + last_time = current_time; } glEnable(GL_DEPTH_TEST); diff --git a/tests/examples/seek/scrubby.c b/tests/examples/seek/scrubby.c index f9b8c8c..d4cba72 100644 --- a/tests/examples/seek/scrubby.c +++ b/tests/examples/seek/scrubby.c @@ -199,7 +199,6 @@ do_seek (GtkWidget * widget, gboolean flush, gboolean segment) gboolean res = FALSE; GstEvent *s_event; gdouble rate; - GTimeVal tv; gboolean valid; gdouble new_range; @@ -222,8 +221,7 @@ do_seek (GtkWidget * widget, gboolean flush, gboolean segment) cur_range = new_range; - g_get_current_time (&tv); - cur_time = GST_TIMEVAL_TO_TIME (tv); + cur_time = g_get_real_time () * GST_USECOND; if (!valid) return FALSE;