2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * srcstate.c: Tests alsasrc for state changes
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.
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.
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.
25 set_state (GstState state)
27 GstState old_state = gst_element_get_state (pipeline);
29 g_print ("Setting state from %s to %s...",
30 gst_element_state_get_name (old_state),
31 gst_element_state_get_name (state));
33 if (!gst_element_set_state (pipeline, state)) {
38 if (state == GST_STATE_PLAYING) {
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);
53 create_pipeline (void)
58 pipeline = gst_pipeline_new ("pipeline");
59 alsasrc = gst_element_factory_make ("alsasrc", "alsasrc");
60 fakesink = gst_element_factory_make ("fakesink", "fakesink");
62 gst_bin_add_many (GST_BIN (pipeline), alsasrc, fakesink, NULL);
63 gst_element_link (alsasrc, fakesink);
68 main (gint argc, gchar * argv[])
70 gst_init (&argc, &argv);
72 g_print ("\n" "This test will check if state changes work on the alsasrc.\n");
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);
90 g_print ("The alsa plugin mastered another test.\n");
92 gst_object_unref (pipeline);