|
|
@@ -35,6 +35,12 @@ srate (nframes_t nframes, void *arg) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
jack_shutdown (void *arg) |
|
|
|
|
|
{ |
|
|
|
|
|
exit (1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int |
|
|
int |
|
|
main (int argc, char *argv[]) |
|
|
main (int argc, char *argv[]) |
|
|
|
|
|
|
|
|
@@ -42,29 +48,66 @@ main (int argc, char *argv[]) |
|
|
jack_client_t *client; |
|
|
jack_client_t *client; |
|
|
|
|
|
|
|
|
if (argc < 2) { |
|
|
if (argc < 2) { |
|
|
fprintf (stderr, "usage: aeclient <name>\n"); |
|
|
|
|
|
|
|
|
fprintf (stderr, "usage: jack_simple_client <name>\n"); |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* try to become a client of the JACK server */ |
|
|
|
|
|
|
|
|
if ((client = jack_client_new (argv[1])) == 0) { |
|
|
if ((client = jack_client_new (argv[1])) == 0) { |
|
|
fprintf (stderr, "jack server not running?\n"); |
|
|
fprintf (stderr, "jack server not running?\n"); |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* tell the JACK server to call `process()' whenever |
|
|
|
|
|
there is work to be done. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
jack_set_process_callback (client, process, 0); |
|
|
jack_set_process_callback (client, process, 0); |
|
|
|
|
|
|
|
|
|
|
|
/* tell the JACK server to call `bufsize()' whenever |
|
|
|
|
|
the maximum number of frames that will be passed |
|
|
|
|
|
to `process()' changes |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
jack_set_buffer_size_callback (client, bufsize, 0); |
|
|
jack_set_buffer_size_callback (client, bufsize, 0); |
|
|
|
|
|
|
|
|
|
|
|
/* tell the JACK server to call `srate()' whenever |
|
|
|
|
|
the sample rate of the system changes. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jack_set_sample_rate_callback (client, srate, 0); |
|
|
jack_set_sample_rate_callback (client, srate, 0); |
|
|
|
|
|
|
|
|
|
|
|
/* tell the JACK server to call `jack_shutdown()' if |
|
|
|
|
|
it ever shuts down, either entirely, or if it |
|
|
|
|
|
just decides to stop calling us. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
jack_on_shutdown (client, jack_shutdown, 0); |
|
|
|
|
|
|
|
|
|
|
|
/* display the current sample rate. once the client is activated |
|
|
|
|
|
(see below), you should rely on your own sample rate |
|
|
|
|
|
callback (see above) for this value. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
printf ("engine sample rate: %lu\n", jack_get_sample_rate (client)); |
|
|
printf ("engine sample rate: %lu\n", jack_get_sample_rate (client)); |
|
|
|
|
|
|
|
|
|
|
|
/* create two ports */ |
|
|
|
|
|
|
|
|
input_port = jack_port_register (client, "input", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); |
|
|
input_port = jack_port_register (client, "input", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); |
|
|
output_port = jack_port_register (client, "output", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); |
|
|
output_port = jack_port_register (client, "output", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); |
|
|
|
|
|
|
|
|
|
|
|
/* tell the JACK server that we are ready to roll */ |
|
|
|
|
|
|
|
|
if (jack_activate (client)) { |
|
|
if (jack_activate (client)) { |
|
|
fprintf (stderr, "cannot activate client"); |
|
|
fprintf (stderr, "cannot activate client"); |
|
|
|
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
printf ("client activated\n"); |
|
|
|
|
|
|
|
|
/* connect the ports. Note: you can't do this before |
|
|
|
|
|
the client is activated (this may change in the future). |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
if (jack_port_connect (client, "ALSA I/O:Input 1", jack_port_name (input_port))) { |
|
|
if (jack_port_connect (client, "ALSA I/O:Input 1", jack_port_name (input_port))) { |
|
|
fprintf (stderr, "cannot connect input ports\n"); |
|
|
fprintf (stderr, "cannot connect input ports\n"); |
|
|
@@ -74,9 +117,9 @@ main (int argc, char *argv[]) |
|
|
fprintf (stderr, "cannot connect output ports\n"); |
|
|
fprintf (stderr, "cannot connect output ports\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sleep (5); |
|
|
|
|
|
|
|
|
/* Since this is just a toy, run for 5 seconds, then finish */ |
|
|
|
|
|
|
|
|
printf ("done sleeping, now closing...\n"); |
|
|
|
|
|
|
|
|
sleep (5); |
|
|
jack_client_close (client); |
|
|
jack_client_close (client); |
|
|
exit (0); |
|
|
exit (0); |
|
|
} |
|
|
} |
|
|
|