From: Wim Taymans Date: Mon, 10 Mar 2003 20:38:22 +0000 (+0000) Subject: Added scheduler refcount test X-Git-Tag: BRANCH-ERROR-ROOT~374 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5d8691718734aa605019a9089d36d5bad45d7c5;p=platform%2Fupstream%2Fgstreamer.git Added scheduler refcount test Original commit message from CVS: Added scheduler refcount test --- diff --git a/tests/old/testsuite/refcounting/Makefile.am b/tests/old/testsuite/refcounting/Makefile.am index 7df3fc4..0413c20 100644 --- a/tests/old/testsuite/refcounting/Makefile.am +++ b/tests/old/testsuite/refcounting/Makefile.am @@ -3,7 +3,7 @@ tests_failing = element bin element_pad pad else tests_failing = endif -tests_working = mainloop +tests_working = mainloop sched element_SOURCES = element.c mem.c pad_SOURCES = pad.c mem.c diff --git a/tests/old/testsuite/refcounting/sched.c b/tests/old/testsuite/refcounting/sched.c new file mode 100644 index 0000000..a9e8629 --- /dev/null +++ b/tests/old/testsuite/refcounting/sched.c @@ -0,0 +1,61 @@ +#include + +gint i = 0; +GstElement *pipeline; +GstPadChainFunction oss_chain; + +static void +create_pipeline (void) +{ + GstElement *src; + GstElement *sink; + GstElement *id; + + pipeline = gst_pipeline_new ("pipeline"); + src = gst_element_factory_make ("sinesrc", "src"); + /** + * You need a sink with a loop-based element in here, if you want to kill opt, too. + * Osssink (chain-based) only breaks the basic scheduler. + */ + sink = gst_element_factory_make ("alsasink", "sink"); + + gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); + gst_element_link (src, sink); + + /** + * now make the bug appear + * I believe it has something to do with 2 chains being created in the scheduler + * but I haven't looked at it yet + * If you comment out the next 4 lines, everything works fine. + * And no, it's not because of identity, you may use any other element. + */ + gst_element_unlink (src, sink); + id = gst_element_factory_make ("identity", "id"); + gst_bin_add (GST_BIN (pipeline), id); + gst_element_link_many (src, id, sink, NULL); + + /* This pipeline will not be removed properly once we unref it */ + gst_element_set_state (pipeline, GST_STATE_PLAYING); +} + +gint +main (gint argc, gchar *argv[]) +{ + gst_init (&argc, &argv); + create_pipeline(); + + while (i < 300) { + /** + * only inc i when it works, so the program hangs when _iterate returns false, + * which it does after the first pipeline isn't unref'd properly and the next + * osssink refuses to work. + */ + if (gst_bin_iterate (GST_BIN (pipeline))) + i++; + if (i % 50 == 0) { + gst_object_unref (GST_OBJECT (pipeline)); + create_pipeline (); + } + } + return 0; +} diff --git a/testsuite/refcounting/Makefile.am b/testsuite/refcounting/Makefile.am index 7df3fc4..0413c20 100644 --- a/testsuite/refcounting/Makefile.am +++ b/testsuite/refcounting/Makefile.am @@ -3,7 +3,7 @@ tests_failing = element bin element_pad pad else tests_failing = endif -tests_working = mainloop +tests_working = mainloop sched element_SOURCES = element.c mem.c pad_SOURCES = pad.c mem.c diff --git a/testsuite/refcounting/sched.c b/testsuite/refcounting/sched.c new file mode 100644 index 0000000..a9e8629 --- /dev/null +++ b/testsuite/refcounting/sched.c @@ -0,0 +1,61 @@ +#include + +gint i = 0; +GstElement *pipeline; +GstPadChainFunction oss_chain; + +static void +create_pipeline (void) +{ + GstElement *src; + GstElement *sink; + GstElement *id; + + pipeline = gst_pipeline_new ("pipeline"); + src = gst_element_factory_make ("sinesrc", "src"); + /** + * You need a sink with a loop-based element in here, if you want to kill opt, too. + * Osssink (chain-based) only breaks the basic scheduler. + */ + sink = gst_element_factory_make ("alsasink", "sink"); + + gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); + gst_element_link (src, sink); + + /** + * now make the bug appear + * I believe it has something to do with 2 chains being created in the scheduler + * but I haven't looked at it yet + * If you comment out the next 4 lines, everything works fine. + * And no, it's not because of identity, you may use any other element. + */ + gst_element_unlink (src, sink); + id = gst_element_factory_make ("identity", "id"); + gst_bin_add (GST_BIN (pipeline), id); + gst_element_link_many (src, id, sink, NULL); + + /* This pipeline will not be removed properly once we unref it */ + gst_element_set_state (pipeline, GST_STATE_PLAYING); +} + +gint +main (gint argc, gchar *argv[]) +{ + gst_init (&argc, &argv); + create_pipeline(); + + while (i < 300) { + /** + * only inc i when it works, so the program hangs when _iterate returns false, + * which it does after the first pipeline isn't unref'd properly and the next + * osssink refuses to work. + */ + if (gst_bin_iterate (GST_BIN (pipeline))) + i++; + if (i % 50 == 0) { + gst_object_unref (GST_OBJECT (pipeline)); + create_pipeline (); + } + } + return 0; +}