2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * state.c: Tests alsasink 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.
26 set_state (GstState state)
28 GstState old_state = gst_element_get_state (pipeline);
30 g_print ("Setting state from %s to %s...",
31 gst_element_state_get_name (old_state),
32 gst_element_state_get_name (state));
34 if (!gst_element_set_state (pipeline, state)) {
39 if (state == GST_STATE_PLAYING) {
42 g_print (" DONE - iterating a bit...");
43 for (i = 0; i < 400; i++) {
44 if (!gst_bin_iterate (GST_BIN (pipeline))) {
45 g_print (" ERROR in iteration %d\n", i);
54 create_pipeline (void)
60 pipeline = gst_pipeline_new ("pipeline");
62 alsasink = gst_element_factory_make ("alsasink", "alsasink");
64 gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
65 gst_element_link (src, alsasink);
67 /* prepare our sinesrc */
68 sinesrc = (SineSrc *) src;
69 sinesrc->newcaps = TRUE;
70 sinesrc->type = SINE_SRC_INT;
72 sinesrc->endianness = G_BYTE_ORDER;
78 main (gint argc, gchar * argv[])
80 gst_init (&argc, &argv);
83 "This test will check if state changes work on the alsasink.\n"
84 "You will hear some short sine tones on your default ALSA soundcard,\n"
85 "but they are not important in this test.\n" "\n");
88 /* simulate some state changes here */
89 set_state (GST_STATE_READY);
90 set_state (GST_STATE_NULL);
91 set_state (GST_STATE_READY);
92 set_state (GST_STATE_NULL);
93 set_state (GST_STATE_PAUSED);
94 set_state (GST_STATE_NULL);
95 set_state (GST_STATE_PLAYING);
96 set_state (GST_STATE_PAUSED);
97 set_state (GST_STATE_PLAYING);
98 set_state (GST_STATE_READY);
99 set_state (GST_STATE_PLAYING);
100 set_state (GST_STATE_NULL);
101 set_state (GST_STATE_PLAYING);
103 g_print ("The alsa plugin mastered another test.\n");
105 gst_object_unref (pipeline);