Browse Source

Merge branch 'develop'

tags/v1.9.13
falkTX 7 years ago
parent
commit
03b8316c5b
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 74 additions and 53 deletions
  1. +13
    -10
      example-clients/bufsize.c
  2. +4
    -18
      example-clients/connect.c
  3. +57
    -25
      example-clients/lsp.c

+ 13
- 10
example-clients/bufsize.c View File

@@ -47,7 +47,6 @@ void signal_handler(int sig)

void parse_arguments(int argc, char *argv[])
{

/* basename $0 */
package = strrchr(argv[0], '/');
if (package == 0)
@@ -71,27 +70,31 @@ void parse_arguments(int argc, char *argv[])

nframes = strtoul(argv[1], NULL, 0);
if (errno == ERANGE) {
fprintf(stderr, "%s: invalid buffer size: %s (range is 1-8192)\n",
fprintf(stderr, "%s: invalid buffer size: %s (range is 1-16384)\n",
package, argv[1]);
exit(2);
}

if (nframes < 1 || nframes > 8192) {
fprintf(stderr, "%s: invalid buffer size: %s (range is 1-8192)\n",
if (nframes < 1 || nframes > 16384) {
fprintf(stderr, "%s: invalid buffer size: %s (range is 1-16384)\n",
package, argv[1]);
exit(3);
}
}

void silent_function( const char *ignore )
{
}

int main(int argc, char *argv[])
{
int rc;
jack_options_t options = JackNoStartServer;

parse_arguments(argc, argv);

if (just_print_bufsize)
jack_set_info_function( silent_function );

/* become a JACK client */
if ((client = jack_client_open(package, options, NULL)) == 0) {
if ((client = jack_client_open(package, JackNoStartServer, NULL)) == 0) {
fprintf(stderr, "JACK server not running?\n");
exit(1);
}
@@ -106,8 +109,8 @@ int main(int argc, char *argv[])
jack_on_shutdown(client, jack_shutdown, 0);

if (just_print_bufsize) {
fprintf(stdout, "buffer size = %d sample rate = %d\n", jack_get_buffer_size(client), jack_get_sample_rate(client));
rc=0;
fprintf(stdout, "%d\n", jack_get_buffer_size( client ) );
rc = 0;
}
else
{


+ 4
- 18
example-clients/connect.c View File

@@ -23,28 +23,21 @@
#endif
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <getopt.h>

#include <jack/jack.h>
#include <jack/session.h>

jack_port_t *input_port;
jack_port_t *output_port;
int connecting, disconnecting;
volatile int done = 0;
#define TRUE 1
#define FALSE 0

volatile int done = 0;

void port_connect_callback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg)
{
done = 1;
}

void error_callback (const char *err)
{
//fprintf (stderr, "%s\n", err);
}

void
show_version (char *my_name)
{
@@ -138,17 +131,10 @@ main (int argc, char *argv[])
return 1;
}

jack_set_error_function(error_callback);

/* try to become a client of the JACK server */

if ((client = jack_client_open (my_name, options, &status, server_name)) == 0) {
fprintf (stderr, "Error: cannot connect to JACK, ");
if (status & JackServerFailed) {
fprintf (stderr, "server is not running.\n");
} else {
fprintf (stderr, "jack_client_open() failed, status = 0x%2.0x\n", status);
}
fprintf (stderr, "jack server not running?\n");
return 1;
}



+ 57
- 25
example-clients/lsp.c View File

@@ -22,19 +22,34 @@
#include <string.h>
#include <getopt.h>
#include <inttypes.h>

#include <jack/jack.h>
#include <jack/session.h>
#include <jack/uuid.h>

char * my_name;

void error_callback (const char *err)
static void
show_version (void)
{
//fprintf (stderr, "%s\n", err);
//fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", my_name);
}

static void
show_version (void)
printf_name2uuid (jack_client_t* client, const char* pname)
{
//fprintf (stderr, "%s: JACK Audio Connection Kit version " VERSION "\n", my_name);
char *port_component = strchr( pname, ':' );
size_t csize = port_component - pname + 1;
char client_component[csize];
snprintf(client_component, csize, "%s", pname);

char *uuid = jack_get_uuid_for_client_name(client, client_component);
if (uuid) {
printf("%s%s\n", uuid, port_component );
} else {
printf("%s\n",pname);
}
jack_free(uuid);
}

static void
@@ -48,11 +63,13 @@ show_usage (void)
fprintf (stderr, " -s, --server <name> Connect to the jack server named <name>\n");
fprintf (stderr, " -A, --aliases List aliases for each port\n");
fprintf (stderr, " -c, --connections List connections to/from each port\n");
fprintf (stderr, " -l, --latency Display per-port latency in frames at each port\n");
fprintf (stderr, " -L, --latency Display total latency in frames at each port\n");
fprintf (stderr, " -l, --port-latency Display per-port latency in frames at each port\n");
fprintf (stderr, " -L, --total-latency Display total latency in frames at each port\n");
fprintf (stderr, " -p, --properties Display port properties. Output may include:\n"
" input|output, can-monitor, physical, terminal\n\n");
fprintf (stderr, " -t, --type Display port type\n");
fprintf (stderr, " -u, --uuid Display uuid instead of client name (if available)\n");
fprintf (stderr, " -U, --port-uuid Display port uuid\n");
fprintf (stderr, " -h, --help Display this help message\n");
fprintf (stderr, " --version Output version information and exit\n\n");
fprintf (stderr, "For more information see http://jackaudio.org/\n");
@@ -73,11 +90,12 @@ main (int argc, char *argv[])
int show_total_latency = 0;
int show_properties = 0;
int show_type = 0;
int show_uuid = 0;
int show_port_uuid = 0;
int c;
int option_index;
char* aliases[2];
char *server_name = NULL;
jack_port_t *port;

struct option long_options[] = {
{ "server", 1, 0, 's' },
@@ -87,6 +105,8 @@ main (int argc, char *argv[])
{ "total-latency", 0, 0, 'L' },
{ "properties", 0, 0, 'p' },
{ "type", 0, 0, 't' },
{ "uuid", 0, 0, 'u' },
{ "port-uuid", 0, 0, 'U' },
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ 0, 0, 0, 0 }
@@ -99,7 +119,7 @@ main (int argc, char *argv[])
my_name ++;
}

while ((c = getopt_long (argc, argv, "s:AclLphvt", long_options, &option_index)) >= 0) {
while ((c = getopt_long (argc, argv, "s:AclLphvtuU", long_options, &option_index)) >= 0) {
switch (c) {
case 's':
server_name = (char *) malloc (sizeof (char) * strlen(optarg));
@@ -126,6 +146,12 @@ main (int argc, char *argv[])
case 't':
show_type = 1;
break;
case 'u':
show_uuid = 1;
break;
case 'U':
show_port_uuid = 1;
break;
case 'h':
show_usage ();
return 1;
@@ -141,13 +167,9 @@ main (int argc, char *argv[])
}
}

jack_set_error_function(error_callback);

/* Open a client connection to the JACK server. Starting a
* new server only to list its ports seems pointless, so we
* specify JackNoStartServer. */
//JOQ: need a new server name option

if ((client = jack_client_open ("lsp", options, &status, server_name)) == 0) {
fprintf (stderr, "Error: cannot connect to JACK, ");
if (status & JackServerFailed) {
@@ -159,21 +181,31 @@ main (int argc, char *argv[])
}

ports = jack_get_ports (client, NULL, NULL, 0);
if (!ports)
goto error;

for (i = 0; ports && ports[i]; ++i) {
// skip over any that don't match ALL of the strings presented at command line
skip_port = 0;
for(k = optind; k < argc; k++){
if(strstr(ports[i], argv[k]) == NULL ){
for (k = optind; k < argc; k++){
if (strstr(ports[i], argv[k]) == NULL ){
skip_port = 1;
}
}
if (skip_port) continue;

printf ("%s\n", ports[i]);
port = jack_port_by_name (client, ports[i]);
if (show_uuid) {
printf_name2uuid(client, ports[i]);
} else {
printf ("%s\n", ports[i]);
}

jack_port_t *port = jack_port_by_name (client, ports[i]);

if (show_port_uuid) {
char buf[JACK_UUID_STRING_SIZE];
jack_uuid_t uuid = jack_port_uuid (port);
jack_uuid_unparse (uuid, buf);
printf (" uuid: %s\n", buf);
}

if (show_aliases) {
int cnt;
@@ -188,16 +220,19 @@ main (int argc, char *argv[])
if (show_con) {
if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) {
for (j = 0; connections[j]; j++) {
printf (" %s\n", connections[j]);
printf(" ");
if (show_uuid) {
printf_name2uuid(client, connections[j]);
} else {
printf("%s\n", connections[j]);
}
}
free (connections);
jack_free (connections);
}
}
if (show_port_latency) {
if (port) {
jack_latency_range_t range;
printf (" port latency = %" PRIu32 " frames\n",
jack_port_get_latency (port));

jack_port_get_latency_range (port, JackPlaybackLatency, &range);
printf (" port playback latency = [ %" PRIu32 " %" PRIu32 " ] frames\n",
@@ -233,7 +268,6 @@ main (int argc, char *argv[])
if (flags & JackPortIsTerminal) {
fputs ("terminal,", stdout);
}

putc ('\n', stdout);
}
}
@@ -246,7 +280,6 @@ main (int argc, char *argv[])
}
}

error:
if (show_aliases) {
free(aliases[0]);
free(aliases[1]);
@@ -256,4 +289,3 @@ error:
jack_client_close (client);
exit (0);
}


Loading…
Cancel
Save