aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c29
-rw-r--r--src/jalv_console.c7
-rw-r--r--src/jalv_gtk2.c2
-rw-r--r--src/jalv_internal.h9
4 files changed, 34 insertions, 13 deletions
diff --git a/src/jalv.c b/src/jalv.c
index a2c83b9..ec7b3c5 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -463,8 +463,6 @@ jack_process_cb(jack_nframes_t nframes, void* data)
lv2_evbuf_get(i, &frames, &subframes, &type, &size, &data);
if (type == host->midi_event_id) {
jack_midi_event_write(buf, frames, data, size);
- } else {
- fprintf(stderr, "Non-MIDI event output type %d\n", type);
}
/* TODO: Be more disciminate about what to send */
@@ -479,6 +477,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
atom->size = size;
if (jack_ringbuffer_write_space(host->plugin_events)
< sizeof(buf) + size) {
+ fprintf(stderr, "Plugin => UI buffer overflow!\n");
break;
}
jack_ringbuffer_write(host->plugin_events, buf, sizeof(buf));
@@ -495,7 +494,10 @@ jack_process_cb(jack_nframes_t nframes, void* data)
ev->protocol = 0;
ev->size = sizeof(float);
*(float*)ev->body = port->control;
- jack_ringbuffer_write(host->plugin_events, buf, sizeof(buf));
+ if (jack_ringbuffer_write(host->plugin_events, buf, sizeof(buf))
+ < sizeof(buf)) {
+ fprintf(stderr, "Plugin => UI buffer overflow!\n");
+ }
}
}
@@ -749,7 +751,7 @@ main(int argc, char** argv)
}
plugin_uri = lilv_node_duplicate(lilv_state_get_plugin_uri(state));
} else if (argc > 1) {
- plugin_uri = lilv_new_uri(world, argv[1]);
+ plugin_uri = lilv_new_uri(world, argv[argc - 1]);
} else {
fprintf(stderr, "Missing plugin URI parameter\n");
return EXIT_FAILURE;
@@ -790,11 +792,6 @@ main(int argc, char** argv)
fprintf(stderr, "No appropriate UI found\n");
}
- host.ui_events = jack_ringbuffer_create(4096);
- host.plugin_events = jack_ringbuffer_create(4096);
- jack_ringbuffer_mlock(host.ui_events);
- jack_ringbuffer_mlock(host.plugin_events);
-
/* Create port structures (host.ports) */
jalv_create_ports(&host);
@@ -839,6 +836,20 @@ main(int argc, char** argv)
#endif
printf("MIDI buffers: %zu bytes\n", host.midi_buf_size);
+ if (host.opts.buffer_size == 0) {
+ fprintf(stderr, "USING DEFAULT BUFFER SIZE\n");
+ host.opts.buffer_size = host.midi_buf_size;
+ } else {
+ fprintf(stderr, "BUFFER SIZE: %d\n", host.opts.buffer_size);
+ }
+
+ /* Create Plugin <=> UI communication buffers */
+ host.ui_events = jack_ringbuffer_create(host.opts.buffer_size);
+ host.plugin_events = jack_ringbuffer_create(host.opts.buffer_size);
+ jack_ringbuffer_mlock(host.ui_events);
+ jack_ringbuffer_mlock(host.plugin_events);
+
+
/* Instantiate the plugin */
host.instance = lilv_plugin_instantiate(
host.plugin, jack_get_sample_rate(host.jack_client), features);
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 65708d0..5508532 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -31,6 +31,7 @@ print_usage(const char* name, bool error)
fprintf(os, " -u UUID UUID for Jack session restoration\n");
fprintf(os, " -l DIR Load state from save directory\n");
fprintf(os, " -d DIR Dump plugin <=> UI communication\n");
+ fprintf(os, " -b SIZE Buffer size for plugin <=> UI communication\n");
return error ? 1 : 0;
}
@@ -68,6 +69,12 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
return 1;
}
opts->load = jalv_strdup((*argv)[a]);
+ } else if ((*argv)[a][1] == 'b') {
+ if (++a == *argc) {
+ fprintf(stderr, "Missing argument for -b\n");
+ return 1;
+ }
+ opts->buffer_size = atoi((*argv)[a]);
} else if ((*argv)[a][1] == 'd') {
opts->dump = true;
} else {
diff --git a/src/jalv_gtk2.c b/src/jalv_gtk2.c
index 5e2da3f..ec0c444 100644
--- a/src/jalv_gtk2.c
+++ b/src/jalv_gtk2.c
@@ -44,6 +44,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
"Dump plugin <=> UI communication", NULL },
{ "generic-ui", 'g', 0, G_OPTION_ARG_NONE, &opts->generic_ui,
"Use Jalv generic UI and not the plugin UI", NULL},
+ { "buffer-size", 'b', 0, G_OPTION_ARG_INT, &opts->buffer_size,
+ "Buffer size for plugin <=> UI communication", "SIZE"},
{ 0, 0, 0, 0, 0, 0, 0 } };
GError* error = NULL;
const int err = gtk_init_with_args(
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 87abddb..bca3c92 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -85,10 +85,11 @@ typedef struct {
} ControlChange;
typedef struct {
- char* uuid;
- char* load;
- bool dump;
- bool generic_ui;
+ char* uuid;
+ char* load;
+ uint32_t buffer_size;
+ bool dump;
+ bool generic_ui;
} JalvOptions;
typedef struct {