2 Copyright (C) 2002 Jeremy Hall
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <jack/jack.h>
29 jack_port_t
*input_port
;
30 jack_port_t
*output_port
;
31 int connecting
, disconnecting
;
36 main (int argc
, char *argv
[])
38 jack_client_t
* client
= NULL
;
39 char *my_name
= strrchr(argv
[0], '/');
40 connecting
= disconnecting
= FALSE
;
47 printf("name %s\n", my_name
);
49 if (strstr(my_name
, "jack_disconnect")) {
52 if (strstr(my_name
, "jack_connect")) {
55 fprintf(stderr
, "ERROR! client should be called jack_connect or jack_disconnect. client is called %s\n", my_name
);
60 fprintf (stderr
, "usage: %s <src_port> <dst_port>\n", my_name
);
61 fprintf(stderr
, "The source port must be an output port of the source client.\n");
62 fprintf (stderr
, "The destination port must be an input port of the destination client.\n");
66 /* try to become a client of the JACK server */
68 if ((client
= jack_client_open (my_name
, JackNullOption
, NULL
)) == 0) {
69 fprintf (stderr
, "jack server not running?\n");
73 /* display the current sample rate. once the client is activated
74 (see below), you should rely on your own sample rate
75 callback (see above) for this value.
78 /* find the two ports */
80 if ((input_port
= jack_port_by_name(client
, argv
[1])) == 0) {
81 fprintf (stderr
, "ERROR %s not a valid port\n", argv
[1]);
84 if ((output_port
= jack_port_by_name(client
, argv
[2])) == 0) {
85 fprintf (stderr
, "ERROR %s not a valid port\n", argv
[2]);
89 /* tell the JACK server that we are ready to roll */
91 if (jack_activate (client
)) {
92 fprintf (stderr
, "cannot activate client");
96 /* connect the ports. Note: you can't do this before
97 the client is activated (this may change in the future).
101 if (jack_connect(client
, jack_port_name(input_port
), jack_port_name(output_port
))) {
102 fprintf (stderr
, "cannot connect ports\n");
107 if (jack_disconnect(client
, jack_port_name(input_port
), jack_port_name(output_port
))) {
108 fprintf (stderr
, "cannot disconnect ports\n");
112 jack_deactivate (client
);
113 jack_client_close (client
);
118 jack_client_close (client
);