summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-09 00:17:15 +0000
committerDavid Robillard <d@drobilla.net>2007-02-09 00:17:15 +0000
commit200565b81542d1b0fde1a657b807646733f2508c (patch)
tree85d2b9890c7edc69ee9843812f758f32e9b4fdd6 /src
parent735173b0f47f362896594deab1a3b76ac3f7081f (diff)
downloadlilv-200565b81542d1b0fde1a657b807646733f2508c.tar.gz
lilv-200565b81542d1b0fde1a657b807646733f2508c.tar.bz2
lilv-200565b81542d1b0fde1a657b807646733f2508c.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/port.c49
1 files changed, 34 insertions, 15 deletions
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);