*.c: Don't cast to GST_OBJECT when reffing or unreffing. Large source-munging commit!!!
[platform/upstream/gstreamer.git] / testsuite / cleanup / cleanup1.c
1 #include <gst/gst.h>
2
3 static GstElement *
4 create_pipeline (void)
5 {
6   GstElement *fakesrc, *fakesink;
7   GstElement *pipeline;
8
9
10   pipeline = gst_pipeline_new ("main_pipeline");
11
12   fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
13   fakesink = gst_element_factory_make ("fakesink", "fakesink");
14
15   gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
16
17   gst_element_link (fakesrc, fakesink);
18
19   g_object_set (G_OBJECT (fakesrc), "num_buffers", 5, NULL);
20
21   return pipeline;
22 }
23
24 gint
25 main (gint argc, gchar * argv[])
26 {
27   GstElement *pipeline;
28   gint i = 1000;
29   gint step = 100;
30
31   free (malloc (8));            /* -lefence */
32
33   gst_init (&argc, &argv);
34
35   g_mem_chunk_info ();
36   while (i--) {
37     if (i % step == 0)
38       fprintf (stderr, "%10d\r", i);
39     pipeline = create_pipeline ();
40
41     gst_element_set_state (pipeline, GST_STATE_PLAYING);
42
43     while (gst_bin_iterate (GST_BIN (pipeline)));
44
45     gst_element_set_state (pipeline, GST_STATE_NULL);
46
47     gst_element_set_state (pipeline, GST_STATE_PLAYING);
48
49     while (gst_bin_iterate (GST_BIN (pipeline)));
50
51     gst_element_set_state (pipeline, GST_STATE_NULL);
52
53     gst_object_unref (pipeline);
54
55   }
56   fprintf (stderr, "\n");
57   g_mem_chunk_info ();
58
59   return 0;
60 }