summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-23 06:03:39 +0000
committerDavid Robillard <d@drobilla.net>2007-07-23 06:03:39 +0000
commit043e683a796e1338a8874b0e7c195292ff32b7de (patch)
treed580453b0d91ec7bdf304714ce52e9749a73db1d /src
parent64b48129d10118a9fbf11aec46fa557b5d302f31 (diff)
downloadlilv-043e683a796e1338a8874b0e7c195292ff32b7de.tar.gz
lilv-043e683a796e1338a8874b0e7c195292ff32b7de.tar.bz2
lilv-043e683a796e1338a8874b0e7c195292ff32b7de.zip
Broke API to separate input/output from type (less code repetition and SLV2 is more useful with unknown extended port types this way).
Switched enum symbol naming scheme to be more typical and future proof. Added LV2 OSC support. git-svn-id: http://svn.drobilla.net/lad/slv2@600 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c4
-rw-r--r--src/pluginguiinstance.c2
-rw-r--r--src/port.c107
3 files changed, 78 insertions, 35 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 80f59a5..ed80ff1 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -571,7 +571,7 @@ slv2_plugin_get_guis(SLV2Plugin plugin)
for (int i=0; i < raptor_sequence_size(result); ++i) {
SLV2Value val = (SLV2Value)raptor_sequence_get_at(result, i);
val->type = SLV2_VALUE_GUI;
- val->val.gui_type_val = SLV2_GTK2_GUI;
+ val->val.gui_type_val = SLV2_GUI_TYPE_GTK2;
}
return result;
@@ -612,7 +612,7 @@ const char*
slv2_gui_type_get_uri(SLV2GUIType type)
{
// Only one for now...
- assert(type == SLV2_GTK2_GUI);
+ assert(type == SLV2_GUI_TYPE_GTK2);
return "http://ll-plugins.nongnu.org/lv2/ext/gtk2gui";
}
diff --git a/src/pluginguiinstance.c b/src/pluginguiinstance.c
index c3a6292..c115751 100644
--- a/src/pluginguiinstance.c
+++ b/src/pluginguiinstance.c
@@ -40,7 +40,7 @@ slv2_plugin_gtk2_gui_instantiate(SLV2Plugin plugin,
{
assert(gui->type == SLV2_VALUE_GUI);
- if (gui->val.gui_type_val != SLV2_GTK2_GUI)
+ if (gui->val.gui_type_val != SLV2_GUI_TYPE_GTK2)
return NULL;
struct _SLV2GUIInstance* result = NULL;
diff --git a/src/port.c b/src/port.c
index b229806..08f9046 100644
--- a/src/port.c
+++ b/src/port.c
@@ -63,56 +63,99 @@ slv2_port_duplicate(SLV2Port port)
}
-SLV2PortClass
-slv2_port_get_class(SLV2Plugin p,
- SLV2Port port)
+SLV2PortDirection
+slv2_port_get_direction(SLV2Plugin p,
+ SLV2Port port)
{
- SLV2Values class = slv2_port_get_value(p, port, "rdf:type");
- assert(class);
+ SLV2Values direction = slv2_port_get_value(p, port, "rdf:type");
- SLV2PortClass ret = SLV2_UNKNOWN_PORT_CLASS;
+ SLV2PortDirection ret = SLV2_PORT_DIRECTION_UNKNOWN;
- int io = -1; // 0 = in, 1 = out
- enum { UNKNOWN, AUDIO, CONTROL, MIDI } type = UNKNOWN;
+ if (!direction)
+ return ret;
- for (unsigned i=0; i < slv2_values_size(class); ++i) {
- SLV2Value val = slv2_values_get_at(class, i);
+ for (unsigned i=0; i < slv2_values_size(direction); ++i) {
+ SLV2Value val = slv2_values_get_at(direction, i);
if (slv2_value_is_uri(val)) {
const char* uri = slv2_value_as_uri(val);
if (!strcmp(uri, "http://lv2plug.in/ontology#InputPort"))
- io = 0;
+ ret = SLV2_PORT_DIRECTION_INPUT;
else if (!strcmp(uri, "http://lv2plug.in/ontology#OutputPort"))
- io = 1;
- else if (!strcmp(uri, "http://lv2plug.in/ontology#ControlPort"))
- type = CONTROL;
+ ret = SLV2_PORT_DIRECTION_OUTPUT;
+ }
+ }
+
+ slv2_values_free(direction);
+
+ return ret;
+}
+
+
+SLV2PortType
+slv2_port_get_type(SLV2Plugin p,
+ SLV2Port port)
+{
+ SLV2Values type = slv2_port_get_value(p, port, "rdf:type");
+
+ SLV2PortType ret = SLV2_PORT_TYPE_UNKNOWN;
+
+ if (!type)
+ return ret;
+
+ for (unsigned i=0; i < slv2_values_size(type); ++i) {
+ SLV2Value val = slv2_values_get_at(type, i);
+ if (slv2_value_is_uri(val)) {
+ const char* uri = slv2_value_as_uri(val);
+ if (!strcmp(uri, "http://lv2plug.in/ontology#ControlPort"))
+ ret = SLV2_PORT_TYPE_CONTROL;
else if (!strcmp(uri, "http://lv2plug.in/ontology#AudioPort"))
- type = AUDIO;
+ ret = SLV2_PORT_TYPE_AUDIO;
else if (!strcmp(uri, "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"))
- type = MIDI;
+ ret = SLV2_PORT_TYPE_MIDI;
+ else if (!strcmp(uri, "http://drobilla.net/ns/lv2ext/osc/0#OSCPort"))
+ ret = SLV2_PORT_TYPE_OSC;
}
}
- 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_values_free(type);
+
+ return ret;
+}
+
+#if 0
+bool
+slv2_port_has_hint(SLV2Plugin p,
+ SLV2Port port,
+ SLV2Value hint)
+{
+ /* FIXME: Add SLV2Value QName stuff to make this not suck to use */
+
+ SLV2Values hints = slv2_port_get_value(p, port, "lv2:portHint");
+
+ if (!hints)
+ return false;
+
+ for (unsigned i=0; i < slv2_values_size(type); ++i) {
+ const SLV2Value val = slv2_values_get_at(type, i);
+ if (slv2_value_is_uri(val)) {
+ const char* uri = slv2_value_as_uri(val);
+ if (!strcmp(uri, "http://lv2plug.in/ontology#connectionOptional"))
+ return true;
+ ret = SLV2_PORT_TYPE_CONTROL;
+ else if (!strcmp(uri, "http://lv2plug.in/ontology#AudioPort"))
+ ret = SLV2_PORT_TYPE_AUDIO;
+ else if (!strcmp(uri, "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"))
+ ret = SLV2_PORT_TYPE_MIDI;
+ else if (!strcmp(uri, "http://drobilla.net/ns/lv2ext/osc/0#OSCPort"))
+ ret = SLV2_PORT_TYPE_OSC;
+ }
}
- slv2_values_free(class);
+ slv2_values_free(type);
return ret;
}
-
+#endif
SLV2Values
slv2_port_get_value(SLV2Plugin p,