From 200565b81542d1b0fde1a657b807646733f2508c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 9 Feb 2007 00:17:15 +0000 Subject: Applied patch from Steve Harris, changes to work with new LV2 ontology port classes. git-svn-id: http://svn.drobilla.net/lad/slv2@291 a436a847-0d15-0410-975c-d299462d15a1 --- src/port.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/port.c b/src/port.c index eb4ba48..f64dbbe 100644 --- a/src/port.c +++ b/src/port.c @@ -49,7 +49,7 @@ slv2_port_by_symbol(const char* symbol) } -enum SLV2PortClass +SLV2PortClass slv2_port_get_class(SLV2Plugin* p, SLV2PortID id) { @@ -57,20 +57,39 @@ slv2_port_get_class(SLV2Plugin* p, assert(class); assert(class->num_values > 0); assert(class->values); - - enum SLV2PortClass ret; - - if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#ControlRateInputPort")) - ret = SLV2_CONTROL_RATE_INPUT; - else if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#ControlRateOutputPort")) - ret = SLV2_CONTROL_RATE_OUTPUT; - else if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#AudioRateInputPort")) - ret = SLV2_AUDIO_RATE_INPUT; - else if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#AudioRateOutputPort")) - ret = SLV2_AUDIO_RATE_OUTPUT; - else { - fprintf(stderr, "Unknown port class: %s\n", class->values[0]); - ret = SLV2_UNKNOWN_PORT_CLASS; + + SLV2PortClass ret = SLV2_UNKNOWN_PORT_CLASS; + + int io = -1; // 0 = in, 1 = out + enum { UNKNOWN, AUDIO, CONTROL, MIDI } type = UNKNOWN; + + for (size_t i=0; i < class->num_values; ++i) { + if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#InputPort")) + io = 0; + else if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#OutputPort")) + io = 1; + else if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#ControlPort")) + type = CONTROL; + else if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#AudioPort")) + type = AUDIO; + else if (!strcmp((char*)class->values[i], "http://ll-plugins.nongnu.org/lv2/ext/MidiPort")) + type = MIDI; + } + + if (io == 0) { + if (type == AUDIO) + ret = SLV2_AUDIO_INPUT; + else if (type == CONTROL) + ret = SLV2_CONTROL_INPUT; + else if (type == MIDI) + ret = SLV2_MIDI_INPUT; + } else if (io == 1) { + if (type == AUDIO) + ret = SLV2_AUDIO_OUTPUT; + else if (type == CONTROL) + ret = SLV2_CONTROL_OUTPUT; + else if (type == MIDI) + ret = SLV2_MIDI_OUTPUT; } slv2_value_free(class); -- cgit v1.2.1