2003-10-03 15:21:49 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* queue test code
|
|
|
|
* starts a fakesrc num_buffers=50 ! { queue ! fakesink } thread
|
|
|
|
* by first setting the output thread to play, then the whole pipeline
|
|
|
|
*/
|
|
|
|
|
2004-09-06 15:57:11 +00:00
|
|
|
static volatile gint handoff_count = 0;
|
2003-10-03 15:21:49 +00:00
|
|
|
|
|
|
|
/* handoff callback */
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
handoff (GstElement * element, gpointer data)
|
2003-10-03 15:21:49 +00:00
|
|
|
{
|
|
|
|
++handoff_count;
|
|
|
|
g_print ("handoff (%d) ", handoff_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
construct_pipeline (GstElement * pipeline, GstElement * thread)
|
2003-10-03 15:21:49 +00:00
|
|
|
{
|
|
|
|
GstElement *src, *sink, *queue;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
src = gst_element_factory_make ("fakesrc", NULL);
|
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
queue = gst_element_factory_make ("queue", NULL);
|
2003-10-03 15:21:49 +00:00
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (thread), queue, sink, NULL);
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL);
|
|
|
|
|
|
|
|
gst_element_link_many (src, queue, sink, NULL);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "num_buffers", 50, NULL);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
|
|
|
|
g_signal_connect (G_OBJECT (sink), "handoff", G_CALLBACK (handoff), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline)
|
2003-10-03 15:21:49 +00:00
|
|
|
{
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
main (gint argc, gchar * argv[])
|
2003-10-03 15:21:49 +00:00
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *thread = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-03 15:21:49 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
pipeline = gst_thread_new ("main_pipeline");
|
|
|
|
thread = gst_element_factory_make ("thread", NULL);
|
|
|
|
construct_pipeline (pipeline, thread);
|
|
|
|
|
|
|
|
g_print ("First run: to show the pipeline works\n");
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
g_print ("SLEEPING 1 sec\n");
|
|
|
|
sleep (1);
|
|
|
|
|
|
|
|
g_print ("Pipeline done. Resetting to NULL.\n");
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (handoff_count == 0) {
|
2003-10-03 15:21:49 +00:00
|
|
|
g_print ("ERROR: no buffers have passed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
handoff_count = 0;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print
|
|
|
|
("Second run: setting consumer thread to playing, then complete pipeline\n");
|
2003-10-03 15:21:49 +00:00
|
|
|
gst_element_set_state (thread, GST_STATE_PLAYING);
|
|
|
|
g_print ("SLEEPING 1 sec\n");
|
|
|
|
sleep (1);
|
gst/gstbin.c: make state changes work correctly and reentrant (so removing elements from bins during state changes of...
Original commit message from CVS:
* gst/gstbin.c: (gst_bin_get_type), (gst_bin_class_init),
(gst_bin_fix_state), (gst_bin_add_func), (gst_bin_remove_func),
(gst_bin_child_state_change_func), (set_kid_state_func),
(gst_bin_set_state), (gst_bin_change_state_norecurse):
make state changes work correctly and reentrant (so removing
elements from bins during state changes of bins doesn't cause
segfaults or even wrong states)
add debugging category and debugging output to print children states
* gst/gstbin.c: (gst_bin_dispose):
add some assertion checks
* gst/gstbin.h:
* gst/gstbin.c: (gst_bin_sync_children_state):
deprecate this function - it just does gst_bin_set_state (bin,
GST_STATE (bin))
* testsuite/threads/queue.c: (main):
don't use gst_bin_sync_children_state anymore
* testsuite/states/Makefile.am:
* testsuite/states/bin.c:
test that the state changes of bins work as expected
* gst/gstthread.c: (gst_thread_class_init), (gst_thread_set_state):
some adjustments to change states correctly, too
* gst/gstthread.c: (gst_thread_change_state):
don't enable/disable "threadsafe" properties, they're unused and
cause random segfaults
* testsuite/threads/Makefile.am:
the queue check randomly passes now, ignore it
2004-07-21 21:28:58 +00:00
|
|
|
gst_element_set_state (pipeline, gst_element_get_state (pipeline));
|
2003-10-03 15:21:49 +00:00
|
|
|
g_print ("SLEEPING 2 sec\n");
|
|
|
|
sleep (2);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (handoff_count == 0) {
|
2003-10-03 15:21:49 +00:00
|
|
|
g_print ("ERROR: no buffers have passed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-03 15:21:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|