testsuite/alsa/: add test for alsasrc changing state
authorZaheer Abbas Merali <zaheerabbas@merali.org>
Tue, 27 Jul 2004 19:50:56 +0000 (19:50 +0000)
committerZaheer Abbas Merali <zaheerabbas@merali.org>
Tue, 27 Jul 2004 19:50:56 +0000 (19:50 +0000)
Original commit message from CVS:
2004-07-27  Zaheer Abbas Merali  <zaheerabbas at merali dot org>

* testsuite/alsa/Makefile.am:
* testsuite/alsa/srcstate.c:
add test for alsasrc changing state

ChangeLog
tests/old/testsuite/alsa/Makefile.am
tests/old/testsuite/alsa/srcstate.c [new file with mode: 0644]
testsuite/alsa/Makefile.am
testsuite/alsa/srcstate.c [new file with mode: 0644]

index a05e8a5..71e9532 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2004-07-27  Zaheer Abbas Merali  <zaheerabbas at merali dot org>
 
+       * testsuite/alsa/Makefile.am:
+       * testsuite/alsa/srcstate.c:
+       add test for alsasrc changing state
+
+2004-07-27  Zaheer Abbas Merali  <zaheerabbas at merali dot org>
+
        * gst/silence/gstsilence.c: (gst_silence_init), (gst_silence_link),
        (gst_silence_get):
        * gst/silence/gstsilence.h:
index 75d82e4..6557bc5 100644 (file)
@@ -1,9 +1,10 @@
-testprogs = formats state
+testprogs = formats state srcstate
 
 noinst_PROGRAMS = $(testprogs)
 
 formats_SOURCES = formats.c sinesrc.c sinesrc.h
 state_SOURCES = state.c sinesrc.c sinesrc.h
+srcstate_SOURCES =srcstate.c
 
 # we have nothing but apps here, we can do this safely
 LIBS = $(GST_LIBS)
diff --git a/tests/old/testsuite/alsa/srcstate.c b/tests/old/testsuite/alsa/srcstate.c
new file mode 100644 (file)
index 0000000..2d02348
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * srcstate.c: Tests alsasrc for state changes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <gst/gst.h>
+
+GstElement *pipeline;
+
+static void
+set_state (GstElementState state)
+{
+  GstElementState old_state = gst_element_get_state (pipeline);
+
+  g_print ("Setting state from %s to %s...",
+      gst_element_state_get_name (old_state),
+      gst_element_state_get_name (state));
+
+  if (!gst_element_set_state (pipeline, state)) {
+    g_print (" ERROR\n");
+    exit (-1);
+  }
+
+  if (state == GST_STATE_PLAYING) {
+    gint i;
+
+    g_print (" DONE - iterating a bit...");
+    for (i = 0; i < 5; i++) {
+      if (!gst_bin_iterate (GST_BIN (pipeline))) {
+        g_print (" ERROR in iteration %d\n", i);
+        exit (-2);
+      }
+    }
+  }
+  g_print (" DONE\n");
+}
+
+static void
+create_pipeline (void)
+{
+  GstElement *alsasrc;
+  GstElement *fakesink;
+
+  pipeline = gst_pipeline_new ("pipeline");
+  alsasrc = gst_element_factory_make ("alsasrc", "alsasrc");
+  fakesink = gst_element_factory_make ("fakesink", "fakesink");
+
+  gst_bin_add_many (GST_BIN (pipeline), alsasrc, fakesink, NULL);
+  gst_element_link (alsasrc, fakesink);
+
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+  gst_init (&argc, &argv);
+
+  g_print ("\n" "This test will check if state changes work on the alsasrc.\n");
+  create_pipeline ();
+
+  /* simulate some state changes here */
+  set_state (GST_STATE_READY);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_READY);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_PAUSED);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_PLAYING);
+  set_state (GST_STATE_PAUSED);
+  set_state (GST_STATE_PLAYING);
+  set_state (GST_STATE_READY);
+  set_state (GST_STATE_PLAYING);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_PLAYING);
+
+  g_print ("The alsa plugin mastered another test.\n");
+
+  gst_object_unref (GST_OBJECT (pipeline));
+
+  return 0;
+}
index 75d82e4..6557bc5 100644 (file)
@@ -1,9 +1,10 @@
-testprogs = formats state
+testprogs = formats state srcstate
 
 noinst_PROGRAMS = $(testprogs)
 
 formats_SOURCES = formats.c sinesrc.c sinesrc.h
 state_SOURCES = state.c sinesrc.c sinesrc.h
+srcstate_SOURCES =srcstate.c
 
 # we have nothing but apps here, we can do this safely
 LIBS = $(GST_LIBS)
diff --git a/testsuite/alsa/srcstate.c b/testsuite/alsa/srcstate.c
new file mode 100644 (file)
index 0000000..2d02348
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * srcstate.c: Tests alsasrc for state changes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <gst/gst.h>
+
+GstElement *pipeline;
+
+static void
+set_state (GstElementState state)
+{
+  GstElementState old_state = gst_element_get_state (pipeline);
+
+  g_print ("Setting state from %s to %s...",
+      gst_element_state_get_name (old_state),
+      gst_element_state_get_name (state));
+
+  if (!gst_element_set_state (pipeline, state)) {
+    g_print (" ERROR\n");
+    exit (-1);
+  }
+
+  if (state == GST_STATE_PLAYING) {
+    gint i;
+
+    g_print (" DONE - iterating a bit...");
+    for (i = 0; i < 5; i++) {
+      if (!gst_bin_iterate (GST_BIN (pipeline))) {
+        g_print (" ERROR in iteration %d\n", i);
+        exit (-2);
+      }
+    }
+  }
+  g_print (" DONE\n");
+}
+
+static void
+create_pipeline (void)
+{
+  GstElement *alsasrc;
+  GstElement *fakesink;
+
+  pipeline = gst_pipeline_new ("pipeline");
+  alsasrc = gst_element_factory_make ("alsasrc", "alsasrc");
+  fakesink = gst_element_factory_make ("fakesink", "fakesink");
+
+  gst_bin_add_many (GST_BIN (pipeline), alsasrc, fakesink, NULL);
+  gst_element_link (alsasrc, fakesink);
+
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+  gst_init (&argc, &argv);
+
+  g_print ("\n" "This test will check if state changes work on the alsasrc.\n");
+  create_pipeline ();
+
+  /* simulate some state changes here */
+  set_state (GST_STATE_READY);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_READY);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_PAUSED);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_PLAYING);
+  set_state (GST_STATE_PAUSED);
+  set_state (GST_STATE_PLAYING);
+  set_state (GST_STATE_READY);
+  set_state (GST_STATE_PLAYING);
+  set_state (GST_STATE_NULL);
+  set_state (GST_STATE_PLAYING);
+
+  g_print ("The alsa plugin mastered another test.\n");
+
+  gst_object_unref (GST_OBJECT (pipeline));
+
+  return 0;
+}