gstreamer/tests/old/testsuite/threads/threadi.c
Ronald S. Bultje d8d03b6b98 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

111 lines
2.6 KiB
C

/*
* Test two ways of going non-lineairly to PLAYING. Both tests have a thread
* containing a fakesrc/sink and a containing thread.
*
* Test 1 tests by adding fakesrc, putting thread to PLAYING, adding
* fakesink, syncing state and see if it iterates.
*
* Test2 tests by adding fakesrc/fakesink, setting fakesrc to PLAYING
* (which should increment the container state) and then synchronizing
* state. This reflects bug #123775.
*/
#include <gst/gst.h>
static GstElement *pipeline, *fakesrc, *fakesink;
gboolean bug = FALSE;
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;
}
static void
cb_eos (gpointer data)
{
g_print ("Received EOS\n");
g_idle_add ((GSourceFunc) cb_quit, NULL);
}
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 (bug) {
g_print ("Setting state\n");
gst_element_set_state (fakesrc, GST_STATE_PLAYING);
g_print ("Done\n");
} else {
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gst_bin_add (GST_BIN (pipeline), fakesink);
}
g_print ("Syncing state\n");
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 n, id;
gst_init (&argc, &argv);
for (n = 0; n < 2; n++) {
pipeline = gst_thread_new ("p");
g_signal_connect (pipeline, "state-change", G_CALLBACK (cb_state), NULL);
fakesrc = gst_element_factory_make ("fakesrc", "src");
g_object_set (G_OBJECT (fakesrc), "num-buffers", 1, NULL);
fakesink = gst_element_factory_make ("fakesink", "sink");
if (bug) {
gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
} else {
gst_bin_add (GST_BIN (pipeline), fakesrc);
}
gst_element_link (fakesrc, fakesink);
g_signal_connect (pipeline, "eos", G_CALLBACK (cb_eos), NULL);
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 reproduce-bug-123775=%s\n", bug ? "true" : "false");
bug = !bug;
}
return 0;
}