#include <gst/check/gstcheck.h>
#include <gst/gst.h>
+#include <gst/check/gsttestclock.h>
#define WAIT_TIME (300 * GST_MSECOND)
GstElement *pipeline, *fakesrc, *queue, *fakesink;
GstState state;
GstClock *clock;
- GstClockID id;
gint64 position;
GstQuery *q;
gboolean live;
GstBus *bus;
GstMessage *msg;
+ clock = gst_test_clock_new ();
pipeline = gst_element_factory_make ("pipeline", "pipeline");
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
queue = gst_element_factory_make ("queue", "queue");
fakesink = gst_element_factory_make ("fakesink", "fakesink");
+ gst_pipeline_use_clock (GST_PIPELINE (pipeline), clock);
+
/* no more than 100 buffers per second */
g_object_set (fakesrc, "do-timestamp", TRUE, "format", GST_FORMAT_TIME,
"sizetype", 2, "sizemax", 4096, "datarate", 4096 * 100, "is-live", TRUE,
fail_unless (max >= min);
gst_query_unref (q);
- /* Wait for 50 msecs */
- clock = gst_pipeline_get_clock (GST_PIPELINE (pipeline));
- fail_unless (clock != NULL);
- id = gst_clock_new_single_shot_id (clock,
- gst_element_get_base_time (pipeline) + 50 * GST_MSECOND);
- gst_clock_id_wait (id, NULL);
- gst_clock_id_unref (id);
- gst_object_unref (clock);
+ /* Wait for time to reach 50 msecs */
+ for (;;) {
+ gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (clock), NULL);
+ if (gst_test_clock_get_next_entry_time (GST_TEST_CLOCK (clock)) >
+ 50 * GST_MSECOND)
+ break;
+ gst_test_clock_crank (GST_TEST_CLOCK (clock));
+ }
/* We waited 50ms, but the position should be now < 40ms */
fail_unless (gst_element_query_position (fakesink, GST_FORMAT_TIME,
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
+ gst_object_unref (clock);
}
GST_END_TEST;