~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
JACK/example-clients/connect.c


** Warning: Cannot open xref database.

1 /* 2 Copyright (C) 2002 Jeremy Hall 3 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. 8 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. 13 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. 17 18 $Id: connect.c,v 1.3 2003/08/27 16:26:23 joq Exp $ 19 */ 20 21 #include <stdio.h> 22 #include <errno.h> 23 #include <unistd.h> 24 #include <string.h> 25 #include <stdlib.h> 26 27 #include <jack/jack.h> 28 29 jack_port_t *input_port; 30 jack_port_t *output_port; 31 int connecting, disconnecting; 32 #define TRUE 1 33 #define FALSE 0 34 35 int 36 main (int argc, char *argv[]) 37 38 { 39 jack_client_t *client; 40 char *my_name = strrchr(argv[0], '/'); 41 connecting = disconnecting = FALSE; 42 if (my_name == 0) { 43 my_name = argv[0]; 44 } else { 45 my_name ++; 46 } 47 48 if (strstr(my_name, "disconnect")) { 49 disconnecting = TRUE; 50 } else 51 if (strstr(my_name, "connect")) { 52 connecting = TRUE; 53 } else { 54 fprintf(stderr, "ERROR! client should be called jack_connect or jack_disconnect. client is called %s\n", my_name); 55 return 1; 56 } 57 58 if (argc != 3) { 59 fprintf (stderr, "usage: %s <src_port> <dst_port>\n", my_name); 60 fprintf(stderr, "The source port must be an output port of the source client.\n"); 61 fprintf (stderr, "The destination port must be an input port of the destination client.\n"); 62 return 1; 63 } 64 65 /* try to become a client of the JACK server */ 66 67 if ((client = jack_client_new (my_name)) == 0) { 68 fprintf (stderr, "jack server not running?\n"); 69 return 1; 70 } 71 72 /* display the current sample rate. once the client is activated 73 (see below), you should rely on your own sample rate 74 callback (see above) for this value. 75 */ 76 77 printf ("engine sample rate: %" PRIu32 "\n", 78 jack_get_sample_rate (client)); 79 80 /* find the two ports */ 81 82 if ((input_port = jack_port_by_name(client, argv[1])) == 0) { 83 fprintf (stderr, "ERROR %s not a valid port\n", argv[1]); 84 return 1; 85 } 86 if ((output_port = jack_port_by_name(client, argv[2])) == 0) { 87 fprintf (stderr, "ERROR %s not a valid port\n", argv[2]); 88 return 1; 89 } 90 91 /* tell the JACK server that we are ready to roll */ 92 93 if (jack_activate (client)) { 94 fprintf (stderr, "cannot activate client"); 95 return 1; 96 } 97 98 /* connect the ports. Note: you can't do this before 99 the client is activated (this may change in the future). 100 */ 101 102 /* jack_port_connect not implemented 103 if (jack_port_connect(client, input_port, output_port)) { 104 fprintf (stderr, "cannot connect ports\n"); 105 } 106 */ 107 if (connecting) { 108 if (jack_connect(client, jack_port_name(input_port), jack_port_name(output_port))) { 109 fprintf (stderr, "cannot connect ports\n"); 110 return 1; 111 } 112 } 113 if (disconnecting) { 114 if (jack_disconnect(client, jack_port_name(input_port), jack_port_name(output_port))) { 115 fprintf (stderr, "cannot disconnect ports\n"); 116 return 1; 117 } 118 } 119 120 jack_client_close (client); 121 exit (0); 122 } 123 124

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.