From f330cdb86c4a2771e9db253525887f96b503b779 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 2 Nov 2002 14:00:16 +0000 Subject: [PATCH] Added clock test program Original commit message from CVS: Added clock test program --- tests/old/testsuite/clock/Makefile.am | 2 +- tests/old/testsuite/clock/clock2.c | 54 +++++++++++++++++++++++++++ testsuite/clock/Makefile.am | 2 +- testsuite/clock/clock2.c | 54 +++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 tests/old/testsuite/clock/clock2.c create mode 100644 testsuite/clock/clock2.c diff --git a/tests/old/testsuite/clock/Makefile.am b/tests/old/testsuite/clock/Makefile.am index a96fb65c08..02b252f25c 100644 --- a/tests/old/testsuite/clock/Makefile.am +++ b/tests/old/testsuite/clock/Makefile.am @@ -1,7 +1,7 @@ GST_PLUGIN_PATH=$(shell cd $(top_builddir) && pwd) TESTS_ENVIRONMENT = GST_PLUGIN_PATH=$(GST_PLUGIN_PATH) GST_REGISTRY=$(GST_PLUGIN_PATH)/testsuite/test-registry.xml -testprogs = clock1 +testprogs = clock1 clock2 TESTS = $(testprogs) diff --git a/tests/old/testsuite/clock/clock2.c b/tests/old/testsuite/clock/clock2.c new file mode 100644 index 0000000000..6e07b486c3 --- /dev/null +++ b/tests/old/testsuite/clock/clock2.c @@ -0,0 +1,54 @@ +/* + * testsuite program to test clock behaviour + * + * creates a fakesrc ! identity ! fakesink pipeline + * registers a callback on fakesrc and one on fakesink + * also register a normal GLib timeout which should not be reached + */ + +#include +void +gst_clock_debug (GstClock *clock) +{ + g_print ("Clock info: speed %f, active %s, time %d\n", + gst_clock_get_speed (clock), + gst_clock_is_active (clock) ? "yes" : "no", + (gint) gst_clock_get_time (clock) + ); +} + +int +main (int argc, char *argv[]) +{ + GstClock *clock = NULL; + GstClockID id; + + gst_init (&argc, &argv); + + clock = gst_system_clock_obtain (); + g_assert (clock != NULL); + + gst_clock_debug (clock); + sleep (1); + gst_clock_debug (clock); + gst_clock_set_active (clock, TRUE); + gst_clock_debug (clock); + sleep (1); + gst_clock_debug (clock); + + id = gst_clock_new_single_shot_id (clock, GST_SECOND * 2); + gst_clock_id_wait (id, NULL); + gst_clock_debug (clock); + + id = gst_clock_new_single_shot_id (clock, GST_SECOND * 2); + gst_clock_id_wait (id, NULL); + gst_clock_debug (clock); + + gst_clock_set_active (clock, FALSE); + gst_clock_debug (clock); + sleep (1); + gst_clock_debug (clock); + + /* success */ + return 0; +} diff --git a/testsuite/clock/Makefile.am b/testsuite/clock/Makefile.am index a96fb65c08..02b252f25c 100644 --- a/testsuite/clock/Makefile.am +++ b/testsuite/clock/Makefile.am @@ -1,7 +1,7 @@ GST_PLUGIN_PATH=$(shell cd $(top_builddir) && pwd) TESTS_ENVIRONMENT = GST_PLUGIN_PATH=$(GST_PLUGIN_PATH) GST_REGISTRY=$(GST_PLUGIN_PATH)/testsuite/test-registry.xml -testprogs = clock1 +testprogs = clock1 clock2 TESTS = $(testprogs) diff --git a/testsuite/clock/clock2.c b/testsuite/clock/clock2.c new file mode 100644 index 0000000000..6e07b486c3 --- /dev/null +++ b/testsuite/clock/clock2.c @@ -0,0 +1,54 @@ +/* + * testsuite program to test clock behaviour + * + * creates a fakesrc ! identity ! fakesink pipeline + * registers a callback on fakesrc and one on fakesink + * also register a normal GLib timeout which should not be reached + */ + +#include +void +gst_clock_debug (GstClock *clock) +{ + g_print ("Clock info: speed %f, active %s, time %d\n", + gst_clock_get_speed (clock), + gst_clock_is_active (clock) ? "yes" : "no", + (gint) gst_clock_get_time (clock) + ); +} + +int +main (int argc, char *argv[]) +{ + GstClock *clock = NULL; + GstClockID id; + + gst_init (&argc, &argv); + + clock = gst_system_clock_obtain (); + g_assert (clock != NULL); + + gst_clock_debug (clock); + sleep (1); + gst_clock_debug (clock); + gst_clock_set_active (clock, TRUE); + gst_clock_debug (clock); + sleep (1); + gst_clock_debug (clock); + + id = gst_clock_new_single_shot_id (clock, GST_SECOND * 2); + gst_clock_id_wait (id, NULL); + gst_clock_debug (clock); + + id = gst_clock_new_single_shot_id (clock, GST_SECOND * 2); + gst_clock_id_wait (id, NULL); + gst_clock_debug (clock); + + gst_clock_set_active (clock, FALSE); + gst_clock_debug (clock); + sleep (1); + gst_clock_debug (clock); + + /* success */ + return 0; +}