Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / tests / old / testsuite / alsa / srcstate.c
1 /*
2  * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
3  *
4  * srcstate.c: Tests alsasrc for state changes
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 #include <gst/gst.h>
21
22 GstElement *pipeline;
23
24 static void
25 set_state (GstState state)
26 {
27   GstState old_state = gst_element_get_state (pipeline);
28
29   g_print ("Setting state from %s to %s...",
30       gst_element_state_get_name (old_state),
31       gst_element_state_get_name (state));
32
33   if (!gst_element_set_state (pipeline, state)) {
34     g_print (" ERROR\n");
35     exit (-1);
36   }
37
38   if (state == GST_STATE_PLAYING) {
39     gint i;
40
41     g_print (" DONE - iterating a bit...");
42     for (i = 0; i < 5; i++) {
43       if (!gst_bin_iterate (GST_BIN (pipeline))) {
44         g_print (" ERROR in iteration %d\n", i);
45         exit (-2);
46       }
47     }
48   }
49   g_print (" DONE\n");
50 }
51
52 static void
53 create_pipeline (void)
54 {
55   GstElement *alsasrc;
56   GstElement *fakesink;
57
58   pipeline = gst_pipeline_new ("pipeline");
59   alsasrc = gst_element_factory_make ("alsasrc", "alsasrc");
60   fakesink = gst_element_factory_make ("fakesink", "fakesink");
61
62   gst_bin_add_many (GST_BIN (pipeline), alsasrc, fakesink, NULL);
63   gst_element_link (alsasrc, fakesink);
64
65 }
66
67 gint
68 main (gint argc, gchar * argv[])
69 {
70   gst_init (&argc, &argv);
71
72   g_print ("\n" "This test will check if state changes work on the alsasrc.\n");
73   create_pipeline ();
74
75   /* simulate some state changes here */
76   set_state (GST_STATE_READY);
77   set_state (GST_STATE_NULL);
78   set_state (GST_STATE_READY);
79   set_state (GST_STATE_NULL);
80   set_state (GST_STATE_PAUSED);
81   set_state (GST_STATE_NULL);
82   set_state (GST_STATE_PLAYING);
83   set_state (GST_STATE_PAUSED);
84   set_state (GST_STATE_PLAYING);
85   set_state (GST_STATE_READY);
86   set_state (GST_STATE_PLAYING);
87   set_state (GST_STATE_NULL);
88   set_state (GST_STATE_PLAYING);
89
90   g_print ("The alsa plugin mastered another test.\n");
91
92   gst_object_unref (pipeline);
93
94   return 0;
95 }