4 * this tests if we can make a GstThread, with enough cothreads to stress it
7 gboolean running = FALSE;
8 gboolean can_quit = FALSE;
11 construct_pipeline (GstElement * pipeline, gint identities)
13 GstElement *src, *sink;
14 GstElement *identity = NULL;
19 src = gst_element_factory_make ("fakesrc", NULL);
20 sink = gst_element_factory_make ("fakesink", NULL);
23 gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
26 for (i = 0; i < identities; ++i) {
27 identity = gst_element_factory_make ("identity", NULL);
29 gst_bin_add (GST_BIN (pipeline), identity);
30 gst_element_link (from, identity);
33 gst_element_link (identity, sink);
35 g_object_set (G_OBJECT (src), "num_buffers", 1, "sizetype", 3, NULL);
39 state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
41 GstElementState state = gst_element_get_state (el);
43 g_print ("element %s has changed state to %s\n",
44 GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
45 if (state == GST_STATE_PLAYING)
47 /* if we move from PLAYING to PAUSED, we're done */
48 if (state == GST_STATE_PAUSED && running) {
51 g_print ("quitting main loop\n");
57 main (gint argc, gchar * argv[])
64 gst_init (&argc, &argv);
66 for (i = 90; i < runs; ++i) {
67 thread = gst_thread_new ("main_thread");
70 /* connect state change signal */
71 id = g_signal_connect (G_OBJECT (thread), "state_change",
72 G_CALLBACK (state_changed), NULL);
73 construct_pipeline (thread, i / 10 + 1);
75 g_print ("Setting thread to play with %d identities\n", i / 10 + 1);
76 if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
77 g_error ("Failed setting thread to play\n");
79 g_print ("Going into the main GStreamer loop\n");
80 can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */
84 g_print ("Coming out of the main GStreamer loop\n");
85 g_signal_handler_disconnect (G_OBJECT (thread), id);
86 gst_element_set_state (thread, GST_STATE_NULL);
87 g_print ("Unreffing thread\n");
88 g_object_unref (G_OBJECT (thread));