i've added a testcase where the scheduler fails. i don't know enough about the schedu...
authorAndy Wingo <wingo@pobox.com>
Sun, 25 Nov 2001 06:30:34 +0000 (06:30 +0000)
committerAndy Wingo <wingo@pobox.com>
Sun, 25 Nov 2001 06:30:34 +0000 (06:30 +0000)
Original commit message from CVS:
i've added a testcase where the scheduler fails. i don't know enough about
the scheduler to fix it, though. the sequence goes:
- make a pipeline, iterate it once
- re-use one of the elements in a new pipeline, see if it works

tests/sched/Makefile.am
tests/sched/dynamic-pipeline.c [new file with mode: 0644]

index 2894b4c..2bcb8ce 100644 (file)
@@ -1,9 +1,11 @@
 if GST_DISABLE_LOADSAVE
 noinst_PROGRAMS =
 else
-noinst_PROGRAMS = runxml
+noinst_PROGRAMS = runxml dynamic-pipeline
 endif
 
+dynamic_pipeline_SOURCES = dynamic-pipeline.c
+
 # nothing but apps here, this is safe
 LIBS += $(GST_LIBS)
 CFLAGS += $(GST_CFLAGS)
diff --git a/tests/sched/dynamic-pipeline.c b/tests/sched/dynamic-pipeline.c
new file mode 100644 (file)
index 0000000..6251bd9
--- /dev/null
@@ -0,0 +1,61 @@
+#include <gst/gst.h>
+
+gboolean idle_func (gpointer data);
+
+gboolean 
+idle_func (gpointer data)
+{
+  return gst_bin_iterate ((GstBin*) (data));
+}
+
+int main (int argc, char *argv[]) 
+{
+    GstElement *osssink, *pipe1, *pipe2, *bin, *filesrc, *mad, *fakesink;
+    
+    gst_init(&argc, &argv);
+    
+    if (argc!=2) {
+        g_print("usage: %s file.mp3\n", argv[0]);
+        exit(-1);
+    }
+    
+    filesrc = gst_elementfactory_make("filesrc", "filesrc");
+    mad = gst_elementfactory_make("mad", "mad");
+    bin = gst_bin_new("bin");
+    pipe1 = gst_pipeline_new("pipe1");
+    pipe2 = gst_pipeline_new("pipe2");
+    osssink = gst_elementfactory_make("osssink", "osssink");
+    fakesink = gst_elementfactory_make("fakesink", "fakesink");
+    
+    g_object_set(G_OBJECT(filesrc), "location", argv[1], NULL);
+    
+    gst_bin_add (GST_BIN(pipe1), filesrc);
+    gst_bin_add (GST_BIN(pipe1), fakesink);
+    gst_element_connect(filesrc, "src", fakesink, "sink");
+    
+    gst_element_set_state(pipe1, GST_STATE_PLAYING);
+    gst_bin_iterate(GST_BIN(pipe1));
+    gst_element_set_state(pipe1, GST_STATE_READY);
+    
+    gst_element_disconnect(filesrc, "src", fakesink, "sink");
+    gst_object_ref(GST_OBJECT(filesrc));
+    gst_bin_remove(GST_BIN(pipe1), filesrc);
+    gst_bin_remove(GST_BIN(pipe1), fakesink);
+    
+    gst_bin_add (GST_BIN(pipe2), filesrc);
+    gst_bin_add (GST_BIN(pipe2), mad);
+    gst_element_connect(filesrc, "src", mad, "sink");
+    gst_bin_add (GST_BIN(pipe2), osssink);
+    gst_element_connect(mad, "src", osssink, "sink");
+    
+    xmlDocDump(stdout, gst_xml_write(pipe2));
+    
+    gst_element_set_state(pipe2, GST_STATE_PLAYING);
+    g_idle_add(idle_func, pipe2);
+    g_main_loop_run(g_main_loop_new(NULL, FALSE));
+    gst_element_set_state(pipe2, GST_STATE_NULL);
+    
+    return 0;
+}
+
+