51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <jack/jack.h>
|
|
#include "looper.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
(void)argc;
|
|
(void)argv;
|
|
const char *client_name = "looper";
|
|
jack_options_t options = JackNullOption;
|
|
jack_status_t status;
|
|
|
|
jack_client_t *client = jack_client_open(client_name, options, &status);
|
|
if (client == NULL) {
|
|
fprintf(stderr, "jack_client_open() failed, status = 0x%2.0x\n", status);
|
|
if (status & JackServerFailed)
|
|
fprintf(stderr, "Unable to connect to JACK server\n");
|
|
return 1;
|
|
}
|
|
|
|
if (status & JackNameNotUnique)
|
|
client_name = jack_get_client_name(client);
|
|
|
|
jack_set_process_callback(client, process_callback, NULL);
|
|
jack_on_shutdown(client, jack_shutdown_cb, NULL);
|
|
|
|
if (looper_init(client) != 0) {
|
|
fprintf(stderr, "looper initialisation failed\n");
|
|
jack_client_close(client);
|
|
return 1;
|
|
}
|
|
|
|
if (jack_activate(client)) {
|
|
fprintf(stderr, "Cannot activate client\n");
|
|
jack_client_close(client);
|
|
return 1;
|
|
}
|
|
|
|
fprintf(stderr, "looper running (client name '%s')\n", client_name);
|
|
|
|
while (1) {
|
|
looper_process_commands(client);
|
|
usleep(50000); /* check commands every 50 ms */
|
|
}
|
|
|
|
jack_client_close(client);
|
|
return 0;
|
|
}
|