gstreamer/tests/old/testsuite/threads/threadi.c

140 lines
3.5 KiB
C
Raw Normal View History

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
/*
* Test three ways of going non-lineairly to PLAYING. Both tests have a
* thread containing a fakesrc/sink.
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
*
* Test1 tests by adding fakesrc/fakesink, setting fakesrc to PLAYING
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
* (which should increment the container state) and then synchronizing
* state and see if the bin iterates. This reflects bug #123775.
*
* Test2 does the same, but emits EOS directly. This will (in case of
* race conditions) sometimes lead to a state-change before the previous
* one succeeded. This bug is not fixed yet (999998).
*
* Test3 tests by adding fakesrc, putting thread to PLAYING, adding
* fakesink, syncing state and see if it iterates. The group is sometimes
* activated before fakesink is added to the bin, which is a bug in opt
* and a race in core that is not fixed yet (999999).
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
*/
#include <gst/gst.h>
static GstElement *pipeline, *fakesrc, *fakesink;
static gboolean
cb_timeout (gpointer data)
{
g_assert_not_reached ();
return FALSE;
}
static gboolean
cb_quit (gpointer data)
{
gst_main_quit ();
g_print ("Quit mainloop\n");
/* once */
return FALSE;
}
#if TESTNUM != 123775
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
static void
cb_eos (gpointer data)
{
g_print ("Received EOS\n");
g_idle_add ((GSourceFunc) cb_quit, NULL);
}
#else
static void
cb_data (gpointer data)
{
static gboolean first = TRUE;
g_print ("Received data\n");
if (first) {
first = FALSE;
g_idle_add ((GSourceFunc) cb_quit, NULL);
}
}
#endif
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
static void
cb_state (GstElement * element, GstElementState old_state,
GstElementState new_state, gpointer data)
{
g_print ("Changed state from %d to %d\n", old_state, new_state);
}
static gboolean
cb_play (gpointer data)
{
GstElementStateReturn res;
#if TESTNUM != 999999
g_print ("Setting state on fakesrc\n");
gst_element_set_state (fakesrc, GST_STATE_PLAYING);
g_print ("Done\n");
#else
g_print ("Setting state on pipeline w/o fakesink\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Adding fakesink\n");
gst_bin_add (GST_BIN (pipeline), fakesink);
g_print ("Done\n");
#endif
g_print ("Syncing state in pipeline\n");
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
res = gst_bin_sync_children_state (GST_BIN (data));
g_assert (res == GST_STATE_SUCCESS);
g_print ("Set to playing correctly: %d\n", GST_STATE (pipeline));
/* once */
return FALSE;
}
gint
main (gint argc, gchar * argv[])
{
gint id;
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
gst_init (&argc, &argv);
g_print ("Will do a test to see if bug %d is fixed\n", TESTNUM);
pipeline = gst_thread_new ("p");
g_signal_connect (pipeline, "state-change", G_CALLBACK (cb_state), NULL);
fakesrc = gst_element_factory_make ("fakesrc", "src");
fakesink = gst_element_factory_make ("fakesink", "sink");
#if TESTNUM != 123775
g_object_set (G_OBJECT (fakesrc), "num-buffers", 0, NULL);
g_signal_connect (pipeline, "eos", G_CALLBACK (cb_eos), NULL);
#else
g_object_set (G_OBJECT (fakesink), "signal-handoffs", TRUE, NULL);
g_signal_connect (fakesink, "handoff", G_CALLBACK (cb_data), NULL);
#endif
#if TESTNUM != 999999
gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
#else
gst_bin_add (GST_BIN (pipeline), fakesrc);
#endif
gst_element_link (fakesrc, fakesink);
g_idle_add ((GSourceFunc) cb_play, pipeline);
/* give 5 seconds */
id = g_timeout_add (5000, (GSourceFunc) cb_timeout, NULL);
g_print ("Enter mainloop\n");
gst_main ();
g_source_remove (id);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
g_print ("Done with test to show bug %d, fixed correctly\n", TESTNUM);
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
return 0;
}