gst-indent run on core
[platform/upstream/gstreamer.git] / testsuite / states / locked.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <gst/gst.h>
21
22 gint
23 main (gint argc, gchar * argv[])
24 {
25   GstElement *pipeline;
26   GstElement *fakesrc1, *fakesink1;
27   GstElement *fakesrc2, *fakesink2;
28
29   gst_init (&argc, &argv);
30
31   pipeline = gst_pipeline_new ("pipeline");
32
33   fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
34   g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
35   fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
36
37   gst_bin_add_many (GST_BIN (pipeline), fakesrc1, fakesink1, NULL);
38   gst_element_link_pads (fakesrc1, "src", fakesink1, "sink");
39
40   fakesrc2 = gst_element_factory_make ("fakesrc", "fakesrc2");
41   g_object_set (G_OBJECT (fakesrc2), "num_buffers", 5, NULL);
42   fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
43
44   gst_bin_add_many (GST_BIN (pipeline), fakesrc2, fakesink2, NULL);
45   gst_element_link_pads (fakesrc2, "src", fakesink2, "sink");
46
47   g_signal_connect (G_OBJECT (pipeline), "deep_notify",
48       G_CALLBACK (gst_element_default_deep_notify), NULL);
49
50   GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
51   GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
52
53   gst_element_set_state (pipeline, GST_STATE_PLAYING);
54   while (gst_bin_iterate (GST_BIN (pipeline)));
55   gst_element_set_state (pipeline, GST_STATE_READY);
56
57   g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
58
59   GST_FLAG_UNSET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
60   GST_FLAG_UNSET (fakesink2, GST_ELEMENT_LOCKED_STATE);
61
62   gst_element_set_state (pipeline, GST_STATE_PLAYING);
63   while (gst_bin_iterate (GST_BIN (pipeline)));
64   gst_element_set_state (pipeline, GST_STATE_NULL);
65
66   gst_object_unref (GST_OBJECT (pipeline));
67
68   return 0;
69 }