mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
tests: Use GstTestClock for processing-deadline test
Use the test clock instead of using a real one to make it easier to run in valgrind. https://bugzilla.gnome.org/show_bug.cgi?id=797291
This commit is contained in:
parent
5947ff970e
commit
5658ae9986
1 changed files with 13 additions and 9 deletions
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <gst/check/gsttestclock.h>
|
||||||
|
|
||||||
#define WAIT_TIME (300 * GST_MSECOND)
|
#define WAIT_TIME (300 * GST_MSECOND)
|
||||||
|
|
||||||
|
@ -668,7 +669,6 @@ GST_START_TEST (test_pipeline_processing_deadline)
|
||||||
GstElement *pipeline, *fakesrc, *queue, *fakesink;
|
GstElement *pipeline, *fakesrc, *queue, *fakesink;
|
||||||
GstState state;
|
GstState state;
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
GstClockID id;
|
|
||||||
gint64 position;
|
gint64 position;
|
||||||
GstQuery *q;
|
GstQuery *q;
|
||||||
gboolean live;
|
gboolean live;
|
||||||
|
@ -676,11 +676,14 @@ GST_START_TEST (test_pipeline_processing_deadline)
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstMessage *msg;
|
GstMessage *msg;
|
||||||
|
|
||||||
|
clock = gst_test_clock_new ();
|
||||||
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
||||||
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
|
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
|
||||||
queue = gst_element_factory_make ("queue", "queue");
|
queue = gst_element_factory_make ("queue", "queue");
|
||||||
fakesink = gst_element_factory_make ("fakesink", "fakesink");
|
fakesink = gst_element_factory_make ("fakesink", "fakesink");
|
||||||
|
|
||||||
|
gst_pipeline_use_clock (GST_PIPELINE (pipeline), clock);
|
||||||
|
|
||||||
/* no more than 100 buffers per second */
|
/* no more than 100 buffers per second */
|
||||||
g_object_set (fakesrc, "do-timestamp", TRUE, "format", GST_FORMAT_TIME,
|
g_object_set (fakesrc, "do-timestamp", TRUE, "format", GST_FORMAT_TIME,
|
||||||
"sizetype", 2, "sizemax", 4096, "datarate", 4096 * 100, "is-live", TRUE,
|
"sizetype", 2, "sizemax", 4096, "datarate", 4096 * 100, "is-live", TRUE,
|
||||||
|
@ -706,14 +709,14 @@ GST_START_TEST (test_pipeline_processing_deadline)
|
||||||
fail_unless (max >= min);
|
fail_unless (max >= min);
|
||||||
gst_query_unref (q);
|
gst_query_unref (q);
|
||||||
|
|
||||||
/* Wait for 50 msecs */
|
/* Wait for time to reach 50 msecs */
|
||||||
clock = gst_pipeline_get_clock (GST_PIPELINE (pipeline));
|
for (;;) {
|
||||||
fail_unless (clock != NULL);
|
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (clock), NULL);
|
||||||
id = gst_clock_new_single_shot_id (clock,
|
if (gst_test_clock_get_next_entry_time (GST_TEST_CLOCK (clock)) >
|
||||||
gst_element_get_base_time (pipeline) + 50 * GST_MSECOND);
|
50 * GST_MSECOND)
|
||||||
gst_clock_id_wait (id, NULL);
|
break;
|
||||||
gst_clock_id_unref (id);
|
gst_test_clock_crank (GST_TEST_CLOCK (clock));
|
||||||
gst_object_unref (clock);
|
}
|
||||||
|
|
||||||
/* We waited 50ms, but the position should be now < 40ms */
|
/* We waited 50ms, but the position should be now < 40ms */
|
||||||
fail_unless (gst_element_query_position (fakesink, GST_FORMAT_TIME,
|
fail_unless (gst_element_query_position (fakesink, GST_FORMAT_TIME,
|
||||||
|
@ -752,6 +755,7 @@ GST_START_TEST (test_pipeline_processing_deadline)
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
|
gst_object_unref (clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue