From 7bceb6c3ff6e24663cfab1432157a2634fbee5ff Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 6 Nov 2019 14:36:11 +0100 Subject: [PATCH] bad: Avoid using deprecated API GTimeval is deprecated --- ext/opencv/gstmotioncells.cpp | 3 +-- ext/opencv/gstmotioncells.h | 1 - gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 14 ++++---------- gst-libs/gst/uridownloader/gsturidownloader.c | 1 - gst/asfmux/gstasfobjects.c | 8 ++++---- gst/mxf/mxftypes.c | 8 ++++---- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ext/opencv/gstmotioncells.cpp b/ext/opencv/gstmotioncells.cpp index b0a6d1ab90..47790edc2d 100644 --- a/ext/opencv/gstmotioncells.cpp +++ b/ext/opencv/gstmotioncells.cpp @@ -359,8 +359,7 @@ gst_motion_cells_init (GstMotioncells * filter) filter->prev_buff_timestamp = 0; filter->cur_buff_timestamp = 0; filter->diff_timestamp = -1; - g_get_current_time (&filter->tv); - filter->starttime = 1000 * filter->tv.tv_sec; + filter->starttime = 1000 * g_get_real_time(); filter->previous_motion = FALSE; filter->changed_datafile = FALSE; filter->postallmotion = FALSE; diff --git a/ext/opencv/gstmotioncells.h b/ext/opencv/gstmotioncells.h index 5f293ad243..804923890d 100644 --- a/ext/opencv/gstmotioncells.h +++ b/ext/opencv/gstmotioncells.h @@ -86,7 +86,6 @@ struct _GstMotioncells gint64 diff_timestamp, starttime; guint64 consecutive_motion; gint width, height; - GTimeVal tv; double framerate; //Video width and height are known in "gst_motion_cells_handle_sink_event", // but not when setting the "motionmaskcoords". diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 4258cf2bb5..e84f7ecb1d 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -480,14 +480,12 @@ gst_adaptive_demux_init (GstAdaptiveDemux * demux, } else { GDateTime *utc_now; GstClockTime rtc_now; - GTimeVal gtv; utc_now = g_date_time_new_now_utc (); rtc_now = gst_clock_get_time (demux->realtime_clock); - g_date_time_to_timeval (utc_now, >v); demux->clock_offset = - gtv.tv_sec * G_TIME_SPAN_SECOND + gtv.tv_usec - - GST_TIME_AS_USECONDS (rtc_now); + g_date_time_to_unix (utc_now) * G_TIME_SPAN_SECOND + + g_date_time_get_microsecond (utc_now) - GST_TIME_AS_USECONDS (rtc_now); g_date_time_unref (utc_now); } g_rec_mutex_init (&demux->priv->updates_lock); @@ -4478,14 +4476,10 @@ GDateTime * gst_adaptive_demux_get_client_now_utc (GstAdaptiveDemux * demux) { GstClockTime rtc_now; - gint64 utc_now; - GTimeVal gtv; rtc_now = gst_clock_get_time (demux->realtime_clock); - utc_now = demux->clock_offset + GST_TIME_AS_USECONDS (rtc_now); - gtv.tv_sec = utc_now / G_TIME_SPAN_SECOND; - gtv.tv_usec = utc_now % G_TIME_SPAN_SECOND; - return g_date_time_new_from_timeval_utc (>v); + return g_date_time_new_from_unix_utc (demux->clock_offset + + GST_TIME_AS_USECONDS (rtc_now)); } /** diff --git a/gst-libs/gst/uridownloader/gsturidownloader.c b/gst-libs/gst/uridownloader/gsturidownloader.c index db27513d4a..865a014ffd 100644 --- a/gst-libs/gst/uridownloader/gsturidownloader.c +++ b/gst-libs/gst/uridownloader/gsturidownloader.c @@ -36,7 +36,6 @@ struct _GstUriDownloaderPrivate GstElement *urisrc; GstBus *bus; GstPad *pad; - GTimeVal *timeout; GstFragment *download; gboolean got_buffer; GMutex download_lock; /* used to restrict to one download only */ diff --git a/gst/asfmux/gstasfobjects.c b/gst/asfmux/gstasfobjects.c index 78e5038b84..d973982638 100644 --- a/gst/asfmux/gstasfobjects.c +++ b/gst/asfmux/gstasfobjects.c @@ -240,14 +240,14 @@ gst_asf_payload_free (AsfPayload * payload) guint64 gst_asf_get_current_time (void) { - GTimeVal timeval; + gint64 now; guint64 secs; guint64 usecs; - g_get_current_time (&timeval); + now = g_get_real_time (); - secs = (guint64) timeval.tv_sec; - usecs = (guint64) timeval.tv_usec; + secs = (guint64) now / G_USEC_PER_SEC; + usecs = (guint64) now % G_USEC_PER_SEC; return secs * G_GUINT64_CONSTANT (10000000) + usecs * 10 + G_GUINT64_CONSTANT (116444628000000000); } diff --git a/gst/mxf/mxftypes.c b/gst/mxf/mxftypes.c index e077f3f234..e7d9fb0ce9 100644 --- a/gst/mxf/mxftypes.c +++ b/gst/mxf/mxftypes.c @@ -555,7 +555,7 @@ mxf_timestamp_to_string (const MXFTimestamp * t, gchar str[32]) void mxf_timestamp_set_now (MXFTimestamp * timestamp) { - GTimeVal tv; + gint64 now; time_t t; struct tm *tm; @@ -563,8 +563,8 @@ mxf_timestamp_set_now (MXFTimestamp * timestamp) struct tm tm_; #endif - g_get_current_time (&tv); - t = (time_t) tv.tv_sec; + now = g_get_real_time (); + t = now / G_USEC_PER_SEC; #ifdef HAVE_GMTIME_R tm = gmtime_r (&t, &tm_); @@ -578,7 +578,7 @@ mxf_timestamp_set_now (MXFTimestamp * timestamp) timestamp->hour = tm->tm_hour; timestamp->minute = tm->tm_min; timestamp->second = tm->tm_sec; - timestamp->msecond = tv.tv_usec / 1000; + timestamp->msecond = now / 1000; } void