2001-12-05 18:39:20 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2002-09-12 11:56:08 +00:00
|
|
|
/*
|
|
|
|
* FIXME:
|
|
|
|
* these tests should have a maximum run length, so that they get killed
|
|
|
|
* if they lock up, which they're bound to do.
|
|
|
|
*/
|
|
|
|
|
2001-12-05 18:39:20 +00:00
|
|
|
void
|
|
|
|
usage (void)
|
|
|
|
{
|
2002-09-12 11:56:08 +00:00
|
|
|
g_print ("compile this test with TESTNUM defined.\n"
|
2004-03-13 15:27:01 +00:00
|
|
|
" available TESTNUMs: \n"
|
|
|
|
" 1: stress test state change \n"
|
|
|
|
" 2: iterate once \n"
|
|
|
|
" 3: iterate twice \n"
|
|
|
|
" 4: state change while running \n"
|
|
|
|
" 5: state change in thread context\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
construct_pipeline (GstElement * pipeline)
|
2001-12-05 18:39:20 +00:00
|
|
|
{
|
2002-05-25 17:45:51 +00:00
|
|
|
GstElement *src, *sink, *queue, *identity, *thread;
|
2001-12-05 18:39:20 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
src = gst_element_factory_make ("fakesrc", NULL);
|
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
2002-05-25 17:45:51 +00:00
|
|
|
identity = gst_element_factory_make ("identity", NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
queue = gst_element_factory_make ("queue", NULL);
|
|
|
|
thread = gst_element_factory_make ("thread", NULL);
|
2001-12-05 18:39:20 +00:00
|
|
|
|
2003-01-10 04:54:20 +00:00
|
|
|
gst_element_link_many (src, queue, identity, sink, NULL);
|
2001-12-05 18:39:20 +00:00
|
|
|
|
2002-05-25 17:45:51 +00:00
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, queue, thread, NULL);
|
|
|
|
gst_bin_add_many (GST_BIN (thread), identity, sink, NULL);
|
2001-12-05 18:39:20 +00:00
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "num_buffers", 5, NULL);
|
2004-09-06 15:57:11 +00:00
|
|
|
//g_object_set (sink, "signal-handoffs", TRUE, NULL);
|
2001-12-05 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-09-06 15:57:11 +00:00
|
|
|
change_state (GstElement * element, GstBuffer * buf, GstPad * pad,
|
|
|
|
GstElement * pipeline)
|
2001-12-05 18:39:20 +00:00
|
|
|
{
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
|
|
|
|
2002-09-12 11:56:08 +00:00
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
main (gint argc, gchar * argv[])
|
2001-12-05 18:39:20 +00:00
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
2002-09-12 11:56:08 +00:00
|
|
|
#ifndef TESTNUM
|
|
|
|
usage ();
|
|
|
|
return -1;
|
|
|
|
#endif
|
2001-12-05 18:39:20 +00:00
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("main_pipeline");
|
|
|
|
construct_pipeline (pipeline);
|
|
|
|
|
2002-09-12 11:56:08 +00:00
|
|
|
if (TESTNUM == 1) {
|
|
|
|
g_print ("thread test 1: stress test state changes...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("NULL\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("READY\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("NULL\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("PAUSED\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("READY\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("PAUSED\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("PLAYING\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2002-05-25 17:45:51 +00:00
|
|
|
/* element likely hits EOS and does a state transition to PAUSED */
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("READY\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
2001-12-18 19:45:31 +00:00
|
|
|
g_print ("NULL\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
|
|
|
|
2002-09-12 11:56:08 +00:00
|
|
|
if (TESTNUM == 2 || TESTNUM == 3) {
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
g_print ("running ...\n");
|
|
|
|
while (gst_bin_iterate (GST_BIN (pipeline)));
|
2004-09-06 15:57:11 +00:00
|
|
|
g_print ("done ...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
2002-09-12 11:56:08 +00:00
|
|
|
if (TESTNUM == 3) {
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2002-11-13 17:06:23 +00:00
|
|
|
g_print ("running ...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
while (gst_bin_iterate (GST_BIN (pipeline)));
|
docs/pwg/advanced-types.xml: Fix description for buffer-frames=0.
Original commit message from CVS:
* docs/pwg/advanced-types.xml:
Fix description for buffer-frames=0.
* docs/gst/tmpl/gstbin.sgml:
* gst/gstbin.c: (gst_bin_child_state_change_func),
(gst_bin_change_state), (gst_bin_change_state_norecurse):
* gst/gstbin.h:
* testsuite/threads/Makefile.am:
* testsuite/threads/threadi.c: (cb_timeout), (cb_quit), (cb_eos),
(cb_state), (cb_play), (main):
Fix non-recursive state changes to *really* change the state
of the object, and not just call parent_class->state_change.
Fix a lot of lockups caused by this. Fixes #132775. Add test
for the problem. Also enable test to show #142588 (fixed).
* gst/gstthread.c: (gst_thread_change_state),
(gst_thread_child_state_change):
Don't exit the thread if we go to NULL and are inside thread
context. Instead, return control to the main thread context
and exit from there.
* gst/gstelement.c: (gst_element_disable_threadsafe_properties):
Don't unset virtual functions, since those may still be used.
That's not necessarily correct, but suffices for now.
* configure.ac:
* testsuite/Makefile.am:
* testsuite/pad/Makefile.am:
* testsuite/pad/chainnopull.c: (gst_test_sink_class_init),
(gst_test_sink_base_init), (gst_test_sink_chain),
(gst_test_sink_init), (main):
* testsuite/pad/getnopush.c: (gst_test_src_class_init),
(gst_test_src_base_init), (gst_test_src_get), (gst_test_src_init),
(main):
* testsuite/pad/link.c: (gst_test_element_class_init),
(gst_test_element_base_init), (gst_test_src_get),
(gst_test_src_loop), (gst_test_src_init), (gst_test_filter_chain),
(gst_test_filter_loop), (gst_test_filter_init),
(gst_test_sink_chain), (gst_test_sink_loop), (gst_test_sink_init),
(cb_error), (main):
Add tests to show #150546. Pass, but should fail (currently
disabled from the testsuite).
* gst/gstscheduler.c: (gst_scheduler_dispose):
Dereference child schedulers on dispose (#94464).
* testsuite/bytestream/filepadsink.c: (gst_fp_sink_init):
Fix typo.
* testsuite/threads/thread.c: (main):
Add more debug.
2005-01-31 15:51:19 +00:00
|
|
|
g_print ("done ...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
2002-09-12 11:56:08 +00:00
|
|
|
if (TESTNUM == 4) {
|
2001-12-05 18:39:20 +00:00
|
|
|
gint run;
|
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2002-11-13 17:06:23 +00:00
|
|
|
g_print ("running ...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
for (run = 0; run < 3; run++) {
|
|
|
|
gst_bin_iterate (GST_BIN (pipeline));
|
|
|
|
}
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
2002-09-12 11:56:08 +00:00
|
|
|
if (TESTNUM == 5) {
|
2003-10-15 01:25:41 +00:00
|
|
|
/* I don't think this test is supposed to work */
|
2001-12-05 18:39:20 +00:00
|
|
|
GstElement *sink;
|
|
|
|
|
|
|
|
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
|
2002-11-13 17:06:23 +00:00
|
|
|
g_assert (sink);
|
2001-12-05 18:39:20 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (G_OBJECT (sink), "handoff",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_CALLBACK (change_state), pipeline);
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2002-11-13 17:06:23 +00:00
|
|
|
g_print ("running ...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
while (gst_bin_iterate (GST_BIN (pipeline)));
|
2004-09-06 15:57:11 +00:00
|
|
|
g_print ("stopping ...\n");
|
2001-12-05 18:39:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-12-05 18:39:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|