Skip to content

Commit

Permalink
base: Avoid usage of deprecated API
Browse files Browse the repository at this point in the history
GTimeval and related functions are now deprecated in glib.
Replacement APIs have been present since 2.26
  • Loading branch information
bilboed authored and sdroege committed Oct 11, 2019
1 parent 7eb98ba commit 2409f4f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 57 deletions.
8 changes: 2 additions & 6 deletions gst/tcp/gstmultifdsink.c
Expand Up @@ -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);
Expand All @@ -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 */
Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 4 additions & 15 deletions gst/tcp/gstmultihandlesink.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 2 additions & 6 deletions gst/tcp/gstmultisocketsink.c
Expand Up @@ -823,16 +823,14 @@ 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;
GstMultiHandleSinkClass *mhsinkclass =
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;

Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions gst/videotestsrc/videotestsrc.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions tests/examples/gl/generic/cube/main.cpp
Expand Up @@ -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;
Expand All @@ -98,14 +98,14 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa

texture = *(guint *) v_frame.data[0];

g_get_current_time (&current_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);
Expand Down
12 changes: 6 additions & 6 deletions tests/examples/gl/generic/cubeyuv/main.cpp
Expand Up @@ -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;
Expand All @@ -119,14 +119,14 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa

texture = *(guint *) v_frame.data[0];

g_get_current_time (&current_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);
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/gl/generic/doublecube/main.cpp
Expand Up @@ -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;
Expand All @@ -121,14 +121,14 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa

texture = *(guint *) v_frame.data[0];

g_get_current_time (&current_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);
Expand Down
12 changes: 6 additions & 6 deletions tests/examples/gl/generic/recordgraphic/main.cpp
Expand Up @@ -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 (&current_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);
Expand Down
4 changes: 1 addition & 3 deletions tests/examples/seek/scrubby.c
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 2409f4f

Please sign in to comment.