cdd102a005e512a6005ca1430c43999264b7f224
[platform/upstream/gstreamer.git] / tests / old / testsuite / cleanup / cleanup3.c
1 #include <gst/gst.h>
2
3 static GstElement *
4 create_pipeline (void)
5 {
6   GstElement *fakesrc, *fakesink;
7   GstElement *pipeline;
8   GstElement *thread, *queue;
9
10   pipeline = gst_pipeline_new ("main_pipeline");
11
12   fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
13   thread = gst_thread_new ("thread");
14   fakesink = gst_element_factory_make ("fakesink", "fakesink");
15   queue = gst_element_factory_make ("queue", "queue");
16   gst_bin_add (GST_BIN (thread), fakesink);
17   gst_bin_add (GST_BIN (thread), queue);
18   gst_element_link (queue, fakesink); 
19   gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), "sink");
20
21   gst_element_link (fakesrc, thread);
22
23   gst_bin_add (GST_BIN (pipeline), fakesrc);
24   gst_bin_add (GST_BIN (pipeline), thread);
25
26   g_object_set (G_OBJECT (fakesrc), "num_buffers", 5, NULL);
27
28   return pipeline;
29 }
30
31 gint
32 main (gint argc, gchar *argv[])
33 {
34   GstElement *pipeline;
35   gint i = 10000;
36   gint step = 100;
37
38   free (malloc(8)); /* -lefence */
39
40   gst_init (&argc, &argv);
41
42
43   g_mem_chunk_info ();
44   while (i--) {
45     if (i % step == 0)
46       fprintf (stderr, "%10d\r", i);
47     pipeline = create_pipeline ();
48           
49     gst_element_set_state (pipeline, GST_STATE_PLAYING);
50
51     while (gst_bin_iterate (GST_BIN (pipeline)));
52
53     gst_element_set_state (pipeline, GST_STATE_NULL);
54
55     gst_element_set_state (pipeline, GST_STATE_PLAYING);
56
57     while (gst_bin_iterate (GST_BIN (pipeline)));
58
59     gst_element_set_state (pipeline, GST_STATE_NULL);
60
61     gst_object_unref (GST_OBJECT (pipeline));
62   }
63   fprintf (stderr, "\n");
64   g_mem_chunk_info ();
65
66   return 0;
67 }