summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c53
-rw-r--r--src/port.c8
2 files changed, 35 insertions, 26 deletions
diff --git a/src/plugin.c b/src/plugin.c
index dfeff76..c6d36a7 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -586,38 +586,39 @@ lilv_plugin_has_latency(const LilvPlugin* p)
}
LILV_API
-uint32_t
-lilv_plugin_get_latency_port_index(const LilvPlugin* p)
+LilvPort*
+lilv_plugin_get_port_by_property(const LilvPlugin* plugin,
+ const LilvNode* port_property)
{
- lilv_plugin_load_if_necessary(p);
- SordIter* ports = lilv_world_query_internal(
- p->world,
- p->plugin_uri->val.uri_val,
- p->world->uris.lv2_port,
- NULL);
+ lilv_plugin_load_ports_if_necessary(plugin);
+ for (uint32_t i = 0; i < plugin->num_ports; ++i) {
+ LilvPort* port = plugin->ports[i];
+ SordIter* iter = lilv_world_query_internal(
+ plugin->world,
+ port->node,
+ plugin->world->uris.lv2_portProperty,
+ port_property->val.uri_val);
- uint32_t ret = 0;
- FOREACH_MATCH(ports) {
- const SordNode* port = lilv_match_object(ports);
- SordIter* reports_latency = lilv_world_query_internal(
- p->world,
- port,
- p->world->uris.lv2_portProperty,
- p->world->uris.lv2_reportsLatency);
- if (!lilv_matches_end(reports_latency)) {
- LilvNode* index = lilv_plugin_get_unique(
- p, port, p->world->uris.lv2_index);
+ const bool found = !lilv_matches_end(iter);
+ lilv_match_end(iter);
- ret = lilv_node_as_int(index);
- lilv_node_free(index);
- lilv_match_end(reports_latency);
- break;
+ if (found) {
+ return port;
}
- lilv_match_end(reports_latency);
}
- lilv_match_end(ports);
- return ret; // FIXME: error handling
+ return NULL;
+}
+
+LILV_API
+uint32_t
+lilv_plugin_get_latency_port_index(const LilvPlugin* p)
+{
+ LilvNode* property = lilv_node_new_from_node(
+ p->world, p->world->uris.lv2_reportsLatency);
+ LilvPort* latency_port = lilv_plugin_get_port_by_property(p, property);
+ lilv_node_free(property);
+ return latency_port ? latency_port->index : UINT32_MAX;
}
LILV_API
diff --git a/src/port.c b/src/port.c
index f008020..f2f8fd6 100644
--- a/src/port.c
+++ b/src/port.c
@@ -131,6 +131,14 @@ lilv_port_get_value(const LilvPlugin* p,
}
LILV_API
+uint32_t
+lilv_port_get_index(const LilvPlugin* p,
+ const LilvPort* port)
+{
+ return port->index;
+}
+
+LILV_API
const LilvNode*
lilv_port_get_symbol(const LilvPlugin* p,
const LilvPort* port)