From 0ad8f354bc936e09d7eb74fc18efd48c3842efd0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 27 Apr 2012 01:17:31 +0000 Subject: Add comm buffer size parameter and use Jack MIDI buffer size by default. Fix running console version with arguments. git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@4281 a436a847-0d15-0410-975c-d299462d15a1 --- src/jalv.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/jalv.c') 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); -- cgit v1.2.1