aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-12-28 02:04:31 +0000
committerDavid Robillard <d@drobilla.net>2013-12-28 02:04:31 +0000
commitcfdfb4606a7dac2e25f5ca6b12375cbdcfbb46b2 (patch)
tree414142fc56e29b037d845046bc799a10eee8c8d5
parenta3aa8a339c30de71de63d22a6141410c15cf251d (diff)
downloadjalv-cfdfb4606a7dac2e25f5ca6b12375cbdcfbb46b2.tar.gz
jalv-cfdfb4606a7dac2e25f5ca6b12375cbdcfbb46b2.tar.bz2
jalv-cfdfb4606a7dac2e25f5ca6b12375cbdcfbb46b2.zip
Don't expose non-MIDI event ports to Jack (fix #907).
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5220 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--NEWS5
-rw-r--r--src/jalv.c46
2 files changed, 28 insertions, 23 deletions
diff --git a/NEWS b/NEWS
index 2313d8d..82939a2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,13 +1,14 @@
jalv (1.4.3) unstable;
* Add -c option for setting controls from the command line
+ * Add --no-menu option for jalv.gtk
+ * Don't expose non-MIDI event ports to Jack
* Hide controls for ports with notOnGUI property in generic UI
(based on patch from Robin Gareus)
* Support ui:portMap feature to allow UIs to avoid hard-coded port indices
(useful for compatibility and separately distributed UIs)
- * Add --no-menu option for jalv.gtk
- -- David Robillard <d@drobilla.net> Wed, 25 Dec 2013 14:03:37 -0500
+ -- David Robillard <d@drobilla.net> Fri, 27 Dec 2013 21:03:33 -0500
jalv (1.4.2) stable;
diff --git a/src/jalv.c b/src/jalv.c
index ca3d7bf..7ed0aef 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -367,9 +367,12 @@ activate_port(Jalv* jalv,
JACK_DEFAULT_AUDIO_TYPE, jack_flags, 0);
break;
case TYPE_EVENT:
- port->jack_port = jack_port_register(
- jalv->jack_client, symbol_str,
- JACK_DEFAULT_MIDI_TYPE, jack_flags, 0);
+ if (lilv_port_supports_event(
+ jalv->plugin, port->lilv_port, jalv->nodes.midi_MidiEvent)) {
+ port->jack_port = jack_port_register(
+ jalv->jack_client, symbol_str,
+ JACK_DEFAULT_MIDI_TYPE, jack_flags, 0);
+ }
break;
default:
break;
@@ -472,10 +475,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
/* Prepare port buffers */
for (uint32_t p = 0; p < jalv->num_ports; ++p) {
struct Port* port = &jalv->ports[p];
- if (!port->jack_port)
- continue;
-
- if (port->type == TYPE_AUDIO) {
+ if (port->type == TYPE_AUDIO && port->jack_port) {
/* Connect plugin port directly to Jack port buffer */
lilv_instance_connect_port(
jalv->instance, p,
@@ -492,15 +492,17 @@ jack_process_cb(jack_nframes_t nframes, void* data)
lv2_pos->type, lv2_pos->size, LV2_ATOM_BODY(lv2_pos));
}
- /* Write Jack MIDI input */
- void* buf = jack_port_get_buffer(port->jack_port, nframes);
- for (uint32_t i = 0; i < jack_midi_get_event_count(buf); ++i) {
- jack_midi_event_t ev;
- jack_midi_event_get(&ev, buf, i);
- lv2_evbuf_write(&iter,
- ev.time, 0,
- jalv->midi_event_id,
- ev.size, ev.buffer);
+ if (port->jack_port) {
+ /* Write Jack MIDI input */
+ void* buf = jack_port_get_buffer(port->jack_port, nframes);
+ for (uint32_t i = 0; i < jack_midi_get_event_count(buf); ++i) {
+ jack_midi_event_t ev;
+ jack_midi_event_get(&ev, buf, i);
+ lv2_evbuf_write(&iter,
+ ev.time, 0,
+ jalv->midi_event_id,
+ ev.size, ev.buffer);
+ }
}
} else if (port->type == TYPE_EVENT) {
/* Clear event output for plugin to write to */
@@ -559,10 +561,12 @@ jack_process_cb(jack_nframes_t nframes, void* data)
/* Deliver MIDI output and UI events */
for (uint32_t p = 0; p < jalv->num_ports; ++p) {
struct Port* const port = &jalv->ports[p];
- if (port->jack_port && port->flow == FLOW_OUTPUT
- && port->type == TYPE_EVENT) {
- void* buf = jack_port_get_buffer(port->jack_port, nframes);
- jack_midi_clear_buffer(buf);
+ if (port->flow == FLOW_OUTPUT && port->type == TYPE_EVENT) {
+ void* buf = NULL;
+ if (port->jack_port) {
+ jack_port_get_buffer(port->jack_port, nframes);
+ jack_midi_clear_buffer(buf);
+ }
for (LV2_Evbuf_Iterator i = lv2_evbuf_begin(port->evbuf);
lv2_evbuf_is_valid(i);
@@ -570,7 +574,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
uint32_t frames, subframes, type, size;
uint8_t* body;
lv2_evbuf_get(i, &frames, &subframes, &type, &size, &body);
- if (type == jalv->midi_event_id) {
+ if (buf && type == jalv->midi_event_id) {
jack_midi_event_write(buf, frames, body, size);
}