From 69e52cb83cf0233648695730c81cdc4f7c4f2a00 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 2 Sep 2006 08:26:17 +0000 Subject: Schema bug fixes (parsable now). Fixed some leaks. Internal query API cleanups. Added latency reporting support. git-svn-id: http://svn.drobilla.net/lad/libslv2@110 a436a847-0d15-0410-975c-d299462d15a1 --- src/plugin.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'src/plugin.c') diff --git a/src/plugin.c b/src/plugin.c index a6b2344..a024077 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -156,7 +156,7 @@ slv2_plugin_get_property(const SLV2Plugin* p, rasqal_query_results* results = slv2_plugin_run_query(p, query); - struct _Property* result = slv2_query_get_results(results); + SLV2Property result = slv2_query_get_results(results, "value"); rasqal_free_query_results(results); rasqal_finish(); @@ -169,8 +169,6 @@ slv2_plugin_get_property(const SLV2Plugin* p, uint32_t slv2_plugin_get_num_ports(const SLV2Plugin* p) { - uint32_t result = 0; - rasqal_init(); char* query = strjoin( @@ -179,12 +177,32 @@ slv2_plugin_get_num_ports(const SLV2Plugin* p) "} \n", NULL); rasqal_query_results* results = slv2_plugin_run_query(p, query); + const size_t result = slv2_query_get_num_results(results, "value"); - while (!rasqal_query_results_finished(results)) { - ++result; - rasqal_query_results_next(results); - } + rasqal_free_query_results(results); + rasqal_finish(); + free(query); + return result; +} + + +bool +slv2_plugin_has_latency(const SLV2Plugin* p) +{ + assert(p); + + rasqal_init(); + + char* query = + "SELECT DISTINCT ?value FROM data: WHERE { \n" + " plugin: lv2:port ?port . \n" + " ?port lv2:portHint lv2:reportsLatency . \n" + "}\n"; + + rasqal_query_results* results = slv2_plugin_run_query(p, query); + bool result = ( rasqal_query_results_get_bindings_count(results) > 0 ); + rasqal_free_query_results(results); rasqal_finish(); free(query); @@ -192,3 +210,34 @@ slv2_plugin_get_num_ports(const SLV2Plugin* p) return result; } +uint32_t +slv2_plugin_get_latency_port(const SLV2Plugin* p) +{ + assert(p); + + rasqal_init(); + + char* query = + "SELECT DISTINCT ?value FROM data: WHERE { \n" + " plugin: lv2:port ?port . \n" + " ?port lv2:portHint lv2:reportsLatency ; \n" + " lv2:index ?index . \n" + "}\n"; + + rasqal_query_results* results = slv2_plugin_run_query(p, query); + + struct _Property* result = slv2_query_get_results(results, "index"); + + // FIXME: need a sane error handling strategy + assert(result->num_values == 1); + char* endptr = 0; + uint32_t index = strtol(result->values[0], &endptr, 10); + // FIXME: check.. stuff.. + + rasqal_free_query_results(results); + rasqal_finish(); + free(query); + + return index; +} + -- cgit v1.2.1