mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
core: 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
e17bde51b3
commit
6babf1f086
3 changed files with 29 additions and 44 deletions
|
@ -503,7 +503,7 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
|
|||
GstMessageType types)
|
||||
{
|
||||
GstMessage *message;
|
||||
GTimeVal now, then;
|
||||
gint64 now, then;
|
||||
gboolean first_round = TRUE;
|
||||
GstClockTime elapsed = 0;
|
||||
|
||||
|
@ -563,12 +563,12 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
|
|||
|
||||
else if (timeout != GST_CLOCK_TIME_NONE) {
|
||||
if (first_round) {
|
||||
g_get_current_time (&then);
|
||||
then = g_get_monotonic_time ();
|
||||
first_round = FALSE;
|
||||
} else {
|
||||
g_get_current_time (&now);
|
||||
now = g_get_monotonic_time ();
|
||||
|
||||
elapsed = GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (then);
|
||||
elapsed = (now - then) * GST_USECOND;
|
||||
|
||||
if (elapsed > timeout)
|
||||
break;
|
||||
|
|
|
@ -178,13 +178,12 @@ GST_END_TEST;
|
|||
|
||||
GST_START_TEST (test_GstDateTime_get_microsecond)
|
||||
{
|
||||
GTimeVal tv;
|
||||
gint64 now_us;
|
||||
GstDateTime *dt;
|
||||
|
||||
g_get_current_time (&tv);
|
||||
dt = gst_date_time_new (0, 2010, 7, 15, 11, 12,
|
||||
13 + (tv.tv_usec / 1000000.0));
|
||||
assert_almost_equals_int (tv.tv_usec, gst_date_time_get_microsecond (dt));
|
||||
now_us = g_get_real_time () % GST_USECOND;
|
||||
dt = gst_date_time_new (0, 2010, 7, 15, 11, 12, 13 + (now_us / 1000000.0));
|
||||
assert_almost_equals_int (now_us, gst_date_time_get_microsecond (dt));
|
||||
gst_date_time_unref (dt);
|
||||
}
|
||||
|
||||
|
|
|
@ -433,9 +433,10 @@ GST_START_TEST (create_events)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static GTimeVal sent_event_time;
|
||||
static GstEvent *got_event_before_q, *got_event_after_q;
|
||||
static GTimeVal got_event_time;
|
||||
/* both time are in microseconds */
|
||||
static gint64 sent_event_time;
|
||||
static gint64 got_event_time;
|
||||
|
||||
static GstPadProbeReturn
|
||||
event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||
|
@ -455,7 +456,7 @@ event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
|||
if (got_event_before_q != NULL)
|
||||
break;
|
||||
gst_event_ref ((GstEvent *) data);
|
||||
g_get_current_time (&got_event_time);
|
||||
got_event_time = g_get_real_time ();
|
||||
got_event_before_q = GST_EVENT (data);
|
||||
break;
|
||||
default:
|
||||
|
@ -470,7 +471,7 @@ event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
|||
if (got_event_after_q != NULL)
|
||||
break;
|
||||
gst_event_ref ((GstEvent *) data);
|
||||
g_get_current_time (&got_event_time);
|
||||
got_event_time = g_get_real_time ();
|
||||
got_event_after_q = GST_EVENT (data);
|
||||
break;
|
||||
default:
|
||||
|
@ -559,9 +560,8 @@ static void test_event
|
|||
|
||||
event = gst_event_new_custom (type,
|
||||
gst_structure_new_empty ("application/x-custom"));
|
||||
g_get_current_time (&sent_event_time);
|
||||
got_event_time.tv_sec = 0;
|
||||
got_event_time.tv_usec = 0;
|
||||
sent_event_time = g_get_real_time ();
|
||||
got_event_time = 0;
|
||||
|
||||
signal_data_init (&data);
|
||||
|
||||
|
@ -617,13 +617,6 @@ static void test_event
|
|||
signal_data_cleanup (&data);
|
||||
}
|
||||
|
||||
static gint64
|
||||
timediff (GTimeVal * end, GTimeVal * start)
|
||||
{
|
||||
return (end->tv_sec - start->tv_sec) * G_USEC_PER_SEC +
|
||||
(end->tv_usec - start->tv_usec);
|
||||
}
|
||||
|
||||
GST_START_TEST (send_custom_events)
|
||||
{
|
||||
/* Run some tests on custom events. Checking for serialisation and whatnot.
|
||||
|
@ -660,49 +653,42 @@ GST_START_TEST (send_custom_events)
|
|||
|
||||
/* Upstream events */
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_UPSTREAM, sinkpad, TRUE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_UP took too long to reach source: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_BOTH, sinkpad, TRUE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_BOTH took too long to reach source: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_BOTH_OOB, sinkpad, TRUE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_BOTH_OOB took too long to reach source: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
/* Out of band downstream events */
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM_OOB, srcpad, FALSE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_DS_OOB took too long to reach source: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_BOTH_OOB, srcpad, FALSE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) < G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_BOTH_OOB took too long to reach source: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
/* In-band downstream events are expected to take at least 1 second
|
||||
* to traverse the queue */
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM, srcpad, FALSE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) >= G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) >= G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_DS arrived too quickly for an in-band event: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
test_event (pipeline, GST_EVENT_CUSTOM_BOTH, srcpad, FALSE, srcpad);
|
||||
fail_unless (timediff (&got_event_time,
|
||||
&sent_event_time) >= G_USEC_PER_SEC / 2,
|
||||
fail_unless ((got_event_time - sent_event_time) >= G_USEC_PER_SEC / 2,
|
||||
"GST_EVENT_CUSTOM_BOTH arrived too quickly for an in-band event: %"
|
||||
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||
G_GINT64_FORMAT " us", got_event_time - sent_event_time);
|
||||
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
|
||||
|
|
Loading…
Reference in a new issue