summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
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 /src/plugin.c
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
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c76
1 files changed, 52 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
}