bad: Avoid using deprecated API

GTimeval is deprecated
This commit is contained in:
Edward Hervey 2019-11-06 14:36:11 +01:00 committed by Edward Hervey
parent dca3e47bce
commit 7bceb6c3ff
6 changed files with 13 additions and 22 deletions

View file

@ -359,8 +359,7 @@ gst_motion_cells_init (GstMotioncells * filter)
filter->prev_buff_timestamp = 0; filter->prev_buff_timestamp = 0;
filter->cur_buff_timestamp = 0; filter->cur_buff_timestamp = 0;
filter->diff_timestamp = -1; filter->diff_timestamp = -1;
g_get_current_time (&filter->tv); filter->starttime = 1000 * g_get_real_time();
filter->starttime = 1000 * filter->tv.tv_sec;
filter->previous_motion = FALSE; filter->previous_motion = FALSE;
filter->changed_datafile = FALSE; filter->changed_datafile = FALSE;
filter->postallmotion = FALSE; filter->postallmotion = FALSE;

View file

@ -86,7 +86,6 @@ struct _GstMotioncells
gint64 diff_timestamp, starttime; gint64 diff_timestamp, starttime;
guint64 consecutive_motion; guint64 consecutive_motion;
gint width, height; gint width, height;
GTimeVal tv;
double framerate; double framerate;
//Video width and height are known in "gst_motion_cells_handle_sink_event", //Video width and height are known in "gst_motion_cells_handle_sink_event",
// but not when setting the "motionmaskcoords". // but not when setting the "motionmaskcoords".

View file

@ -480,14 +480,12 @@ gst_adaptive_demux_init (GstAdaptiveDemux * demux,
} else { } else {
GDateTime *utc_now; GDateTime *utc_now;
GstClockTime rtc_now; GstClockTime rtc_now;
GTimeVal gtv;
utc_now = g_date_time_new_now_utc (); utc_now = g_date_time_new_now_utc ();
rtc_now = gst_clock_get_time (demux->realtime_clock); rtc_now = gst_clock_get_time (demux->realtime_clock);
g_date_time_to_timeval (utc_now, &gtv);
demux->clock_offset = demux->clock_offset =
gtv.tv_sec * G_TIME_SPAN_SECOND + gtv.tv_usec - g_date_time_to_unix (utc_now) * G_TIME_SPAN_SECOND +
GST_TIME_AS_USECONDS (rtc_now); g_date_time_get_microsecond (utc_now) - GST_TIME_AS_USECONDS (rtc_now);
g_date_time_unref (utc_now); g_date_time_unref (utc_now);
} }
g_rec_mutex_init (&demux->priv->updates_lock); g_rec_mutex_init (&demux->priv->updates_lock);
@ -4478,14 +4476,10 @@ GDateTime *
gst_adaptive_demux_get_client_now_utc (GstAdaptiveDemux * demux) gst_adaptive_demux_get_client_now_utc (GstAdaptiveDemux * demux)
{ {
GstClockTime rtc_now; GstClockTime rtc_now;
gint64 utc_now;
GTimeVal gtv;
rtc_now = gst_clock_get_time (demux->realtime_clock); rtc_now = gst_clock_get_time (demux->realtime_clock);
utc_now = demux->clock_offset + GST_TIME_AS_USECONDS (rtc_now); return g_date_time_new_from_unix_utc (demux->clock_offset +
gtv.tv_sec = utc_now / G_TIME_SPAN_SECOND; GST_TIME_AS_USECONDS (rtc_now));
gtv.tv_usec = utc_now % G_TIME_SPAN_SECOND;
return g_date_time_new_from_timeval_utc (&gtv);
} }
/** /**

View file

@ -36,7 +36,6 @@ struct _GstUriDownloaderPrivate
GstElement *urisrc; GstElement *urisrc;
GstBus *bus; GstBus *bus;
GstPad *pad; GstPad *pad;
GTimeVal *timeout;
GstFragment *download; GstFragment *download;
gboolean got_buffer; gboolean got_buffer;
GMutex download_lock; /* used to restrict to one download only */ GMutex download_lock; /* used to restrict to one download only */

View file

@ -240,14 +240,14 @@ gst_asf_payload_free (AsfPayload * payload)
guint64 guint64
gst_asf_get_current_time (void) gst_asf_get_current_time (void)
{ {
GTimeVal timeval; gint64 now;
guint64 secs; guint64 secs;
guint64 usecs; guint64 usecs;
g_get_current_time (&timeval); now = g_get_real_time ();
secs = (guint64) timeval.tv_sec; secs = (guint64) now / G_USEC_PER_SEC;
usecs = (guint64) timeval.tv_usec; usecs = (guint64) now % G_USEC_PER_SEC;
return secs * G_GUINT64_CONSTANT (10000000) + usecs * 10 return secs * G_GUINT64_CONSTANT (10000000) + usecs * 10
+ G_GUINT64_CONSTANT (116444628000000000); + G_GUINT64_CONSTANT (116444628000000000);
} }

View file

@ -555,7 +555,7 @@ mxf_timestamp_to_string (const MXFTimestamp * t, gchar str[32])
void void
mxf_timestamp_set_now (MXFTimestamp * timestamp) mxf_timestamp_set_now (MXFTimestamp * timestamp)
{ {
GTimeVal tv; gint64 now;
time_t t; time_t t;
struct tm *tm; struct tm *tm;
@ -563,8 +563,8 @@ mxf_timestamp_set_now (MXFTimestamp * timestamp)
struct tm tm_; struct tm tm_;
#endif #endif
g_get_current_time (&tv); now = g_get_real_time ();
t = (time_t) tv.tv_sec; t = now / G_USEC_PER_SEC;
#ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R
tm = gmtime_r (&t, &tm_); tm = gmtime_r (&t, &tm_);
@ -578,7 +578,7 @@ mxf_timestamp_set_now (MXFTimestamp * timestamp)
timestamp->hour = tm->tm_hour; timestamp->hour = tm->tm_hour;
timestamp->minute = tm->tm_min; timestamp->minute = tm->tm_min;
timestamp->second = tm->tm_sec; timestamp->second = tm->tm_sec;
timestamp->msecond = tv.tv_usec / 1000; timestamp->msecond = now / 1000;
} }
void void