1 /* This app demonstrates the creation and use of a jack client in conjunction
2 * with the jack plugins. This way, an application can control the jack client
11 quit_cb (gpointer data)
18 main (int argc, char **argv)
20 jack_client_t *src_client, *sink_client;
22 GstElement *pipeline, *src, *sink;
23 GstStateChangeReturn ret;
25 gst_init (&argc, &argv);
27 /* create jack clients */
28 src_client = jack_client_open ("src_client", JackNoStartServer, &status);
29 if (src_client == NULL) {
30 if (status & JackServerFailed)
31 g_print ("JACK server not running\n");
33 g_print ("jack_client_open() failed, status = 0x%2.0x\n", status);
37 sink_client = jack_client_open ("sink_client", JackNoStartServer, &status);
38 if (sink_client == NULL) {
39 if (status & JackServerFailed)
40 g_print ("JACK server not running\n");
42 g_print ("jack_client_open() failed, status = 0x%2.0x\n", status);
46 /* create gst elements */
47 pipeline = gst_pipeline_new ("my_pipeline");
49 src = gst_element_factory_make ("jackaudiosrc", NULL);
50 sink = gst_element_factory_make ("jackaudiosink", NULL);
52 g_object_set (src, "client", src_client, NULL);
53 g_object_set (sink, "client", sink_client, NULL);
55 gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
57 /* link everything together */
58 if (!gst_element_link (src, sink)) {
59 g_print ("Failed to link elements!\n");
64 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
65 if (ret == GST_STATE_CHANGE_FAILURE) {
66 g_print ("Failed to start up pipeline!\n");
70 /* quit after 5 seconds */
71 g_timeout_add (5000, (GSourceFunc) quit_cb, NULL);
75 gst_element_set_state (pipeline, GST_STATE_NULL);
76 gst_object_unref (pipeline);