summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Matthews <le.businessman@gmail.com>2010-09-06 17:17:54 -0400
committerStefan Kost <ensonic@users.sf.net>2010-09-07 00:33:49 +0300
commit62634b48ed7bd37880b5ff02dcfc016708ef55ed (patch)
tree3dc80eac21f3be6a3e63c44a76a1d2dd17d662ac
parent716fffb0987b9a0fc55ee3341530f48a8a583fbd (diff)
examples: add test to demonstrate jack_client_t usage
-rw-r--r--configure.ac1
-rw-r--r--tests/examples/Makefile.am7
-rw-r--r--tests/examples/jack/Makefile.am6
-rw-r--r--tests/examples/jack/jack_client.c79
4 files changed, 92 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 363c8eee6..044a82841 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1770,6 +1770,7 @@ tests/examples/directfb/Makefile
tests/examples/mxf/Makefile
tests/examples/scaletempo/Makefile
tests/examples/switch/Makefile
+tests/examples/jack/Makefile
tests/icles/Makefile
ext/alsaspdif/Makefile
ext/amrwbenc/Makefile
diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am
index 562b36118..0a9739778 100644
--- a/tests/examples/Makefile.am
+++ b/tests/examples/Makefile.am
@@ -1,4 +1,9 @@
if HAVE_GTK
+if USE_JACK
+JACK_EXAMPLES=jack
+else
+JACK_EXAMPLES=
+endif
GTK_EXAMPLES=camerabin mxf scaletempo
else
GTK_EXAMPLES=
@@ -10,5 +15,5 @@ else
DIRECTFB_DIR=
endif
-SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) switch
+SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) $(JACK_EXAMPLES) switch
DIST_SUBDIRS= camerabin directfb mxf scaletempo switch
diff --git a/tests/examples/jack/Makefile.am b/tests/examples/jack/Makefile.am
new file mode 100644
index 000000000..4adfd1314
--- /dev/null
+++ b/tests/examples/jack/Makefile.am
@@ -0,0 +1,6 @@
+noinst_PROGRAMS = jack_client
+
+jack_client_SOURCES = jack_client.c
+jack_client_CFLAGS = $(GST_CFLAGS) $(GTK_CFLAGS) $(JACK_CFLAGS)
+jack_client_LDFLAGS = $(GST_LIBS) $(GTK_LIBS) $(JACK_LIBS)
+
diff --git a/tests/examples/jack/jack_client.c b/tests/examples/jack/jack_client.c
new file mode 100644
index 000000000..99599ab5c
--- /dev/null
+++ b/tests/examples/jack/jack_client.c
@@ -0,0 +1,79 @@
+/* This app demonstrates the creation and use of a jack client in conjunction
+ * with the jack plugins. This way, an application can control the jack client
+ * directly.
+ */
+
+#include <gst/gst.h>
+#include <gtk/gtk.h>
+#include <jack/jack.h>
+
+static gboolean
+quit_cb (gpointer data)
+{
+ gtk_main_quit ();
+ return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+ jack_client_t *src_client, *sink_client;
+ jack_status_t status;
+ GstElement *pipeline, *src, *sink;
+ GstStateChangeReturn ret;
+
+ gst_init (&argc, &argv);
+
+ /* create jack clients */
+ src_client = jack_client_open ("src_client", JackNoStartServer, &status);
+ if (src_client == NULL) {
+ if (status & JackServerFailed)
+ g_print ("JACK server not running\n");
+ else
+ g_print ("jack_client_open() failed, status = 0x%2.0x\n", status);
+ return 1;
+ }
+
+ sink_client = jack_client_open ("sink_client", JackNoStartServer, &status);
+ if (sink_client == NULL) {
+ if (status & JackServerFailed)
+ g_print ("JACK server not running\n");
+ else
+ g_print ("jack_client_open() failed, status = 0x%2.0x\n", status);
+ return 1;
+ }
+
+ /* create gst elements */
+ pipeline = gst_pipeline_new ("my_pipeline");
+
+ src = gst_element_factory_make ("jackaudiosrc", NULL);
+ sink = gst_element_factory_make ("jackaudiosink", NULL);
+
+ g_object_set (src, "client", src_client, NULL);
+ g_object_set (sink, "client", sink_client, NULL);
+
+ gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+
+ /* link everything together */
+ if (!gst_element_link (src, sink)) {
+ g_print ("Failed to link elements!\n");
+ return 1;
+ }
+
+ /* run */
+ ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ g_print ("Failed to start up pipeline!\n");
+ return 1;
+ }
+
+ /* quit after 5 seconds */
+ g_timeout_add (5000, (GSourceFunc) quit_cb, NULL);
+ gtk_main ();
+
+ /* clean up */
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (pipeline);
+
+ return 0;
+}