Added basic JACK funcitonality.
This commit is contained in:
65
src/main.c
65
src/main.c
@@ -17,11 +17,19 @@
|
||||
*/
|
||||
|
||||
#include "args.h"
|
||||
#include "processing.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <readline/readline.h>
|
||||
#include <jack/jack.h>
|
||||
|
||||
jack_port_t *in_port;
|
||||
jack_port_t *out_port;
|
||||
jack_client_t *client;
|
||||
|
||||
void jack_shutdown(void *arg);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct arguments arguments;
|
||||
arguments.verbose = 0;
|
||||
@@ -29,5 +37,62 @@ int main(int argc, char *argv[]) {
|
||||
arguments.playlist_file = NULL;
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
/*const char **ports;*/
|
||||
const char *client_name = "saus";
|
||||
const char *server_name = NULL;
|
||||
jack_options_t options = JackNullOption;
|
||||
jack_status_t status;
|
||||
|
||||
client = jack_client_open(client_name, options, &status, server_name);
|
||||
if(!client)
|
||||
{
|
||||
fprintf(stderr, "jack_client_open() failed, "
|
||||
"status = 0x%2.0x\n", status);
|
||||
if(status & JackServerFailed)
|
||||
{
|
||||
fprintf(stderr, "Unable to connect to JACK server\n");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
if(status & JackServerStarted)
|
||||
{
|
||||
fprintf(stderr, "JACK server started\n");
|
||||
}
|
||||
if(status & JackNameNotUnique)
|
||||
{
|
||||
client_name = jack_get_client_name(client);
|
||||
fprintf(stderr, "unique name `%s' assigned\n", client_name);
|
||||
}
|
||||
|
||||
jack_set_process_callback(client, process, 0);
|
||||
jack_on_shutdown(client, jack_shutdown, "Shut down by JACK server");
|
||||
|
||||
in_port = jack_port_register(client, "input",
|
||||
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
|
||||
out_port = jack_port_register(client, "output",
|
||||
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
|
||||
|
||||
if(!in_port || !out_port)
|
||||
{
|
||||
fprintf(stderr, "No more JACK ports available\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(jack_activate(client))
|
||||
{
|
||||
fprintf(stderr, "Cannot activate JACK client\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// TODO: add main loop here
|
||||
|
||||
jack_client_close(client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void jack_shutdown(void *arg) {
|
||||
fprintf(stderr, "%s", (char*)arg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user