summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-30 00:03:52 +0000
committerDavid Robillard <d@drobilla.net>2011-01-30 00:03:52 +0000
commite0c3f426f0b7b40cdb9c65f99ac77f4974f086a8 (patch)
treef50e03e731d6583518e3cf9b48d7b8b601f8d8b6
parent801876c89ef1e4dcd16f5c5f9c29416b78ac15c4 (diff)
downloadlilv-e0c3f426f0b7b40cdb9c65f99ac77f4974f086a8.tar.gz
lilv-e0c3f426f0b7b40cdb9c65f99ac77f4974f086a8.tar.bz2
lilv-e0c3f426f0b7b40cdb9c65f99ac77f4974f086a8.zip
Non-SPARQL versions of slv2_plugin_has_latency and slv2_plugin_get_latency_port_index.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2861 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/plugin.c76
-rw-r--r--src/slv2_internal.h1
-rw-r--r--src/world.c2
3 files changed, 55 insertions, 24 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 08e873c..a0a9bb4 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -723,41 +723,69 @@ slv2_plugin_get_num_ports_of_class(SLV2Plugin p,
bool
slv2_plugin_has_latency(SLV2Plugin p)
{
- const char* const query =
- "SELECT ?index WHERE {\n"
- " <> lv2:port ?port .\n"
- " ?port lv2:portProperty lv2:reportsLatency ;\n"
- " lv2:index ?index .\n"
- "}\n";
+ librdf_stream* ports = slv2_plugin_find_statements(
+ p,
+ librdf_new_node_from_uri(p->world->world, p->plugin_uri->val.uri_val),
+ librdf_new_node_from_node(p->world->lv2_port_node),
+ NULL);
- SLV2Values results = slv2_plugin_query_variable(p, query, 0);
- const bool latent = (slv2_values_size(results) > 0);
- slv2_values_free(results);
+ bool ret = false;
+ for (; !librdf_stream_end(ports); librdf_stream_next(ports)) {
+ librdf_statement* s = librdf_stream_get_object(ports);
+ librdf_node* port = librdf_statement_get_object(s);
- return latent;
+ librdf_stream* reports_latency = slv2_plugin_find_statements(
+ p,
+ librdf_new_node_from_node(port),
+ librdf_new_node_from_node(p->world->lv2_portproperty_node),
+ librdf_new_node_from_uri_string(p->world->world,
+ SLV2_NS_LV2 "reportsLatency"));
+
+ if (!librdf_stream_end(reports_latency)) {
+ ret = true;
+ break;
+ }
+
+ librdf_free_stream(reports_latency);
+ }
+
+ return ret;
}
uint32_t
slv2_plugin_get_latency_port_index(SLV2Plugin p)
{
- const char* const query =
- "SELECT ?index WHERE {\n"
- " <> lv2:port ?port .\n"
- " ?port lv2:portProperty lv2:reportsLatency ;\n"
- " lv2:index ?index .\n"
- "}\n";
+ librdf_stream* ports = slv2_plugin_find_statements(
+ p,
+ librdf_new_node_from_uri(p->world->world, p->plugin_uri->val.uri_val),
+ librdf_new_node_from_node(p->world->lv2_port_node),
+ NULL);
- SLV2Values result = slv2_plugin_query_variable(p, query, 0);
+ uint32_t ret = 0;
+ for (; !librdf_stream_end(ports); librdf_stream_next(ports)) {
+ librdf_statement* s = librdf_stream_get_object(ports);
+ librdf_node* port = librdf_statement_get_object(s);
- // FIXME: need a sane error handling strategy
- assert(slv2_values_size(result) > 0);
- SLV2Value val = slv2_values_get_at(result, 0);
- assert(slv2_value_is_int(val));
+ librdf_stream* reports_latency = slv2_plugin_find_statements(
+ p,
+ librdf_new_node_from_node(port),
+ librdf_new_node_from_node(p->world->lv2_portproperty_node),
+ librdf_new_node_from_uri_string(p->world->world,
+ SLV2_NS_LV2 "reportsLatency"));
- int ret = slv2_value_as_int(val);
- slv2_values_free(result);
- return ret;
+ if (!librdf_stream_end(reports_latency)) {
+ SLV2Value index = slv2_plugin_get_unique(
+ p,
+ librdf_new_node_from_node(port),
+ librdf_new_node_from_node(p->world->lv2_index_node));
+ ret = slv2_value_as_int(index);
+ slv2_value_free(index);
+ break;
+ }
+ }
+
+ return ret; // FIXME: error handling
}
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index adf9e8b..c76a11e 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -159,6 +159,7 @@ struct _SLV2World {
librdf_node* lv2_plugin_node;
librdf_node* lv2_binary_node;
librdf_node* lv2_port_node;
+ librdf_node* lv2_portproperty_node;
librdf_node* lv2_index_node;
librdf_node* lv2_symbol_node;
librdf_node* rdf_a_node;
diff --git a/src/world.c b/src/world.c
index 53bee59..1909ca5 100644
--- a/src/world.c
+++ b/src/world.c
@@ -64,6 +64,7 @@ slv2_world_new_internal(SLV2World world)
world->lv2_plugin_node = NEW_URI(SLV2_NS_LV2 "Plugin");
world->lv2_binary_node = NEW_URI(SLV2_NS_LV2 "binary");
world->lv2_port_node = NEW_URI(SLV2_NS_LV2 "port");
+ world->lv2_portproperty_node = NEW_URI(SLV2_NS_LV2 "portProperty");
world->lv2_index_node = NEW_URI(SLV2_NS_LV2 "index");
world->lv2_symbol_node = NEW_URI(SLV2_NS_LV2 "symbol");
world->rdf_a_node = NEW_URI(SLV2_NS_RDF "type");
@@ -162,6 +163,7 @@ slv2_world_free(SLV2World world)
librdf_free_node(world->lv2_plugin_node);
librdf_free_node(world->lv2_binary_node);
librdf_free_node(world->lv2_port_node);
+ librdf_free_node(world->lv2_portproperty_node);
librdf_free_node(world->lv2_index_node);
librdf_free_node(world->lv2_symbol_node);
librdf_free_node(world->rdf_a_node);