mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-14 03:54:11 +00:00
good: Avoid usage of deprecated API
GTimeval and related functions are now deprecated in glib. Replacement APIs have been present since 2.26
This commit is contained in:
parent
3f21c89bb0
commit
8e1c224fbc
12 changed files with 35 additions and 56 deletions
|
@ -99,21 +99,19 @@ static GstFlowReturn
|
|||
gst_cpu_report_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||
{
|
||||
GstCpuReport *filter;
|
||||
GTimeVal cur_time;
|
||||
GstClockTime cur_time;
|
||||
clock_t cur_cpu_time;
|
||||
GstMessage *msg;
|
||||
GstStructure *s;
|
||||
gint64 time_taken;
|
||||
GstClockTimeDiff time_taken;
|
||||
|
||||
|
||||
g_get_current_time (&cur_time);
|
||||
cur_time = g_get_real_time () * GST_USECOND;
|
||||
cur_cpu_time = clock ();
|
||||
|
||||
filter = GST_CPU_REPORT (trans);
|
||||
|
||||
|
||||
time_taken = GST_TIMEVAL_TO_TIME (cur_time) -
|
||||
GST_TIMEVAL_TO_TIME (filter->last_time);
|
||||
time_taken = cur_time - filter->last_time;
|
||||
|
||||
s = gst_structure_new ("cpu-report", "cpu-time", G_TYPE_DOUBLE,
|
||||
((gdouble) (cur_cpu_time - filter->last_cpu_time)),
|
||||
|
@ -135,8 +133,7 @@ gst_cpu_report_start (GstBaseTransform * trans)
|
|||
|
||||
filter = GST_CPU_REPORT (trans);
|
||||
|
||||
g_get_current_time (&filter->last_time);
|
||||
filter->start_time = filter->last_time;
|
||||
filter->start_time = filter->last_time = g_get_real_time () * GST_USECOND;
|
||||
filter->last_cpu_time = clock ();
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ struct _GstCpuReport
|
|||
{
|
||||
GstBaseTransform basetransform;
|
||||
|
||||
GTimeVal start_time;
|
||||
GTimeVal last_time;
|
||||
GstClockTime start_time;
|
||||
GstClockTime last_time;
|
||||
clock_t last_cpu_time;
|
||||
};
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_progress_report_report (GstProgressReport * filter, GTimeVal cur_time,
|
||||
gst_progress_report_report (GstProgressReport * filter, gint64 cur_time_s,
|
||||
GstBuffer * buf)
|
||||
{
|
||||
GstFormat try_formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES,
|
||||
|
@ -338,7 +338,7 @@ gst_progress_report_report (GstProgressReport * filter, GTimeVal cur_time,
|
|||
glong run_time;
|
||||
gint hh, mm, ss;
|
||||
|
||||
run_time = cur_time.tv_sec - filter->start_time.tv_sec;
|
||||
run_time = cur_time_s - filter->start_time_s;
|
||||
|
||||
hh = (run_time / 3600) % 100;
|
||||
mm = (run_time / 60) % 60;
|
||||
|
@ -387,10 +387,9 @@ gst_progress_report_sink_event (GstBaseTransform * trans, GstEvent * event)
|
|||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_EOS:
|
||||
{
|
||||
GTimeVal cur_time;
|
||||
gint64 cur_time_s = g_get_real_time () / G_USEC_PER_SEC;
|
||||
|
||||
g_get_current_time (&cur_time);
|
||||
gst_progress_report_report (filter, cur_time, NULL);
|
||||
gst_progress_report_report (filter, cur_time_s, NULL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -404,23 +403,22 @@ gst_progress_report_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
|||
{
|
||||
GstProgressReport *filter;
|
||||
gboolean need_update;
|
||||
GTimeVal cur_time;
|
||||
gint64 cur_time;
|
||||
|
||||
g_get_current_time (&cur_time);
|
||||
cur_time = g_get_real_time () / G_USEC_PER_SEC;
|
||||
|
||||
filter = GST_PROGRESS_REPORT (trans);
|
||||
|
||||
/* Check if update_freq seconds have passed since the last update */
|
||||
GST_OBJECT_LOCK (filter);
|
||||
need_update =
|
||||
((cur_time.tv_sec - filter->last_report.tv_sec) >= filter->update_freq);
|
||||
need_update = (cur_time - filter->last_report_s) >= filter->update_freq;
|
||||
filter->buffer_count++;
|
||||
GST_OBJECT_UNLOCK (filter);
|
||||
|
||||
if (need_update) {
|
||||
gst_progress_report_report (filter, cur_time, buf);
|
||||
GST_OBJECT_LOCK (filter);
|
||||
filter->last_report = cur_time;
|
||||
filter->last_report_s = cur_time;
|
||||
GST_OBJECT_UNLOCK (filter);
|
||||
}
|
||||
|
||||
|
@ -434,8 +432,8 @@ gst_progress_report_start (GstBaseTransform * trans)
|
|||
|
||||
filter = GST_PROGRESS_REPORT (trans);
|
||||
|
||||
g_get_current_time (&filter->last_report);
|
||||
filter->start_time = filter->last_report;
|
||||
filter->start_time_s = filter->last_report_s =
|
||||
g_get_real_time () / G_USEC_PER_SEC;
|
||||
filter->buffer_count = 0;
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -48,8 +48,8 @@ struct _GstProgressReport
|
|||
gint update_freq;
|
||||
gboolean silent;
|
||||
gboolean do_query;
|
||||
GTimeVal start_time;
|
||||
GTimeVal last_report;
|
||||
gint64 start_time_s;
|
||||
gint64 last_report_s;
|
||||
gint64 buffer_count;
|
||||
|
||||
/* Format used for querying. Using a string here because the
|
||||
|
|
|
@ -1083,7 +1083,6 @@ tags:
|
|||
tags_written++;
|
||||
|
||||
{
|
||||
GTimeVal tv = { 0, };
|
||||
time_t secs;
|
||||
struct tm *tm;
|
||||
gchar *s;
|
||||
|
@ -1095,8 +1094,7 @@ tags:
|
|||
"Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
g_get_current_time (&tv);
|
||||
secs = tv.tv_sec;
|
||||
secs = g_get_real_time () / G_USEC_PER_SEC;
|
||||
tm = gmtime (&secs);
|
||||
|
||||
s = g_strdup_printf ("%s %s %d %02d:%02d:%02d %d", weekdays[tm->tm_wday],
|
||||
|
|
|
@ -78,11 +78,10 @@ atoms_context_free (AtomsContext * context)
|
|||
guint64
|
||||
atoms_get_current_qt_time (void)
|
||||
{
|
||||
GTimeVal timeval;
|
||||
gint64 curtime_s = g_get_real_time () / G_USEC_PER_SEC;
|
||||
|
||||
g_get_current_time (&timeval);
|
||||
/* FIXME this should use UTC coordinated time */
|
||||
return timeval.tv_sec + (((1970 - 1904) * (guint64) 365) +
|
||||
return curtime_s + (((1970 - 1904) * (guint64) 365) +
|
||||
LEAP_YEARS_FROM_1904_TO_1970) * SECS_PER_DAY;
|
||||
}
|
||||
|
||||
|
|
|
@ -14161,12 +14161,12 @@ qtdemux_parse_tree (GstQTDemux * qtdemux)
|
|||
if (creation_time != 0) {
|
||||
/* Try to use epoch first as it should be faster and more commonly found */
|
||||
if (creation_time >= QTDEMUX_SECONDS_FROM_1904_TO_1970) {
|
||||
GTimeVal now;
|
||||
gint64 now_s;
|
||||
|
||||
creation_time -= QTDEMUX_SECONDS_FROM_1904_TO_1970;
|
||||
/* some data cleansing sanity */
|
||||
g_get_current_time (&now);
|
||||
if (now.tv_sec + 24 * 3600 < creation_time) {
|
||||
now_s = g_get_real_time () / G_USEC_PER_SEC;
|
||||
if (now_s + 24 * 3600 < creation_time) {
|
||||
GST_DEBUG_OBJECT (qtdemux, "discarding bogus future creation time");
|
||||
} else {
|
||||
datetime = gst_date_time_new_from_unix_epoch_utc (creation_time);
|
||||
|
|
|
@ -2960,7 +2960,6 @@ gst_matroska_mux_start (GstMatroskaMux * mux, GstMatroskaPad * first_pad,
|
|||
GstClockTime earliest_time = GST_CLOCK_TIME_NONE;
|
||||
GstClockTime duration = 0;
|
||||
guint32 segment_uid[4];
|
||||
GTimeVal time = { 0, 0 };
|
||||
gchar s_id[32];
|
||||
GstToc *toc;
|
||||
|
||||
|
@ -3098,8 +3097,8 @@ gst_matroska_mux_start (GstMatroskaMux * mux, GstMatroskaPad * first_pad,
|
|||
if (mux->writing_app && mux->writing_app[0]) {
|
||||
gst_ebml_write_utf8 (ebml, GST_MATROSKA_ID_WRITINGAPP, mux->writing_app);
|
||||
}
|
||||
g_get_current_time (&time);
|
||||
gst_ebml_write_date (ebml, GST_MATROSKA_ID_DATEUTC, time.tv_sec);
|
||||
gst_ebml_write_date (ebml, GST_MATROSKA_ID_DATEUTC,
|
||||
g_get_real_time () / G_USEC_PER_SEC);
|
||||
gst_ebml_write_master_finish (ebml, master);
|
||||
|
||||
/* tracks */
|
||||
|
|
|
@ -1214,11 +1214,8 @@ get_current_times (GstRtpBin * bin, GstClockTime * running_time,
|
|||
switch (bin->ntp_time_source) {
|
||||
case GST_RTP_NTP_TIME_SOURCE_NTP:
|
||||
case GST_RTP_NTP_TIME_SOURCE_UNIX:{
|
||||
GTimeVal current;
|
||||
|
||||
/* get current NTP time */
|
||||
g_get_current_time (¤t);
|
||||
ntpns = GST_TIMEVAL_TO_TIME (current);
|
||||
ntpns = g_get_real_time () * GST_USECOND;
|
||||
|
||||
/* add constant to convert from 1970 based time to 1900 based time */
|
||||
if (bin->ntp_time_source == GST_RTP_NTP_TIME_SOURCE_NTP)
|
||||
|
|
|
@ -1064,11 +1064,8 @@ get_current_times (GstRtpSession * rtpsession, GstClockTime * running_time,
|
|||
switch (rtpsession->priv->ntp_time_source) {
|
||||
case GST_RTP_NTP_TIME_SOURCE_NTP:
|
||||
case GST_RTP_NTP_TIME_SOURCE_UNIX:{
|
||||
GTimeVal current;
|
||||
|
||||
/* get current NTP time */
|
||||
g_get_current_time (¤t);
|
||||
ntpns = GST_TIMEVAL_TO_TIME (current);
|
||||
ntpns = g_get_real_time () * GST_USECOND;
|
||||
|
||||
/* add constant to convert from 1970 based time to 1900 based time */
|
||||
if (rtpsession->priv->ntp_time_source == GST_RTP_NTP_TIME_SOURCE_NTP)
|
||||
|
|
|
@ -211,8 +211,9 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
|
|||
*
|
||||
* Get the statistics of the client with destination @host and @port.
|
||||
*
|
||||
* Returns: a GstStructure: bytes_sent, packets_sent,
|
||||
* connect_time (in epoch seconds), disconnect_time (in epoch seconds)
|
||||
* Returns: a GstStructure: bytes_sent, packets_sent, connect_time
|
||||
* (in epoch nanoseconds), disconnect_time (in epoch
|
||||
* nanoseconds)
|
||||
*/
|
||||
gst_multiudpsink_signals[SIGNAL_GET_STATS] =
|
||||
g_signal_new ("get-stats", G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -1525,7 +1526,6 @@ gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host,
|
|||
GSocketFamily family;
|
||||
GstUDPClient *client;
|
||||
GstUDPClient udpclient;
|
||||
GTimeVal now;
|
||||
GList *find;
|
||||
|
||||
udpclient.host = (gchar *) host;
|
||||
|
@ -1560,8 +1560,7 @@ gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host,
|
|||
|
||||
family = g_socket_address_get_family (client->addr);
|
||||
|
||||
g_get_current_time (&now);
|
||||
client->connect_time = GST_TIMEVAL_TO_TIME (now);
|
||||
client->connect_time = g_get_real_time () * GST_USECOND;
|
||||
|
||||
if (sink->used_socket)
|
||||
gst_multiudpsink_configure_client (sink, client);
|
||||
|
@ -1619,7 +1618,6 @@ gst_multiudpsink_remove (GstMultiUDPSink * sink, const gchar * host, gint port)
|
|||
GList *find;
|
||||
GstUDPClient udpclient;
|
||||
GstUDPClient *client;
|
||||
GTimeVal now;
|
||||
|
||||
udpclient.host = (gchar *) host;
|
||||
udpclient.port = port;
|
||||
|
@ -1656,8 +1654,7 @@ gst_multiudpsink_remove (GstMultiUDPSink * sink, const gchar * host, gint port)
|
|||
|
||||
GST_DEBUG_OBJECT (sink, "remove client with host %s, port %d", host, port);
|
||||
|
||||
g_get_current_time (&now);
|
||||
client->disconnect_time = GST_TIMEVAL_TO_TIME (now);
|
||||
client->disconnect_time = g_get_real_time () * GST_USECOND;
|
||||
|
||||
if (socket && sink->auto_multicast
|
||||
&& g_inet_address_get_is_multicast (addr)) {
|
||||
|
|
|
@ -879,11 +879,8 @@ retry:
|
|||
gstnow = GST_TIMESPEC_TO_TIME (now);
|
||||
|
||||
if (timestamp > gstnow || (gstnow - timestamp) > (10 * GST_SECOND)) {
|
||||
GTimeVal now;
|
||||
|
||||
/* very large diff, fall back to system time */
|
||||
g_get_current_time (&now);
|
||||
gstnow = GST_TIMEVAL_TO_TIME (now);
|
||||
gstnow = g_get_real_time () * GST_USECOND;
|
||||
}
|
||||
|
||||
/* Detect buggy drivers here, and stop using their timestamp. Failing any
|
||||
|
|
Loading…
Reference in a new issue