From aadf0570fa48b5e221ecb07c3f12fa34d7afea4d Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Mon, 3 Jun 2002 18:37:36 +0000 Subject: [PATCH] threadstate4 fails randomly on state change. it is { { fakesrc } ! queue ! fakesink } Original commit message from CVS: threadstate4 fails randomly on state change. it is { { fakesrc } ! queue ! fakesink } --- tests/threadstate/Makefile.am | 2 +- tests/threadstate/threadstate3.c | 10 +++---- tests/threadstate/threadstate4.c | 48 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 tests/threadstate/threadstate4.c diff --git a/tests/threadstate/Makefile.am b/tests/threadstate/Makefile.am index c81cc277a5..028acc5b20 100644 --- a/tests/threadstate/Makefile.am +++ b/tests/threadstate/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = threadstate1 threadstate2 threadstate3 +noinst_PROGRAMS = threadstate1 threadstate2 threadstate3 threadstate4 LDADD = $(GST_LIBS) AM_CFLAGS = $(GST_CFLAGS) diff --git a/tests/threadstate/threadstate3.c b/tests/threadstate/threadstate3.c index 94628d5805..a88439e539 100644 --- a/tests/threadstate/threadstate3.c +++ b/tests/threadstate/threadstate3.c @@ -3,7 +3,7 @@ int main(int argc,char *argv[]) { GstElement *fakesrc, *fakesink; - GstElement *thread, *pipeline; + GstElement *thread, *thread2; gint x; gst_init(&argc,&argv); @@ -11,10 +11,10 @@ int main(int argc,char *argv[]) thread = gst_thread_new("thread"); g_assert(thread != NULL); - pipeline = gst_pipeline_new("pipeline"); - g_assert(pipeline != NULL); + thread2 = gst_thread_new("thread2"); + g_assert(thread2 != NULL); - gst_bin_add(GST_BIN(thread), GST_ELEMENT(pipeline)); + gst_bin_add(GST_BIN(thread), GST_ELEMENT(thread2)); fakesrc = gst_element_factory_make("fakesrc", "fake_source"); g_assert(fakesrc != NULL); @@ -22,7 +22,7 @@ int main(int argc,char *argv[]) fakesink = gst_element_factory_make("fakesink", "fake_sink"); g_assert(fakesink != NULL); - gst_bin_add_many (GST_BIN(pipeline), fakesrc, fakesink, NULL); + gst_bin_add_many (GST_BIN(thread2), fakesrc, fakesink, NULL); gst_element_connect (fakesrc, fakesink); for (x = 0 ; x < 10 ; x++){ diff --git a/tests/threadstate/threadstate4.c b/tests/threadstate/threadstate4.c new file mode 100644 index 0000000000..170aa70f92 --- /dev/null +++ b/tests/threadstate/threadstate4.c @@ -0,0 +1,48 @@ +#include + +int main(int argc,char *argv[]) +{ + GstElement *fakesrc, *fakesink; + GstElement *thread, *thread2; + GstElement *queue; + gint x; + + gst_init(&argc,&argv); + + thread = gst_thread_new("thread"); + g_assert(thread != NULL); + + thread2 = gst_thread_new("thread"); + g_assert(thread2 != NULL); + + queue = gst_element_factory_make("queue", "the_queue"); + g_assert(queue != NULL); + + + fakesrc = gst_element_factory_make("fakesrc", "fake_source"); + g_assert(fakesrc != NULL); + + fakesink = gst_element_factory_make("fakesink", "fake_sink"); + g_assert(fakesink != NULL); + + gst_bin_add_many (GST_BIN(thread), thread2, queue, fakesink, NULL); + + gst_bin_add(GST_BIN(thread2), fakesrc); + gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"), "src"); + gst_element_connect_many (thread2, queue, fakesink, NULL); + + for (x = 0 ; x < 10 ; x++){ + g_print("playing %d\n", x); + gst_element_set_state(thread, GST_STATE_PLAYING); + sleep(1); + + g_print("nulling %d\n", x); + gst_element_set_state(thread, GST_STATE_NULL); + sleep(1); + } + + gst_main(); + + exit(0); +} +