diff options
author | David Robillard <d@drobilla.net> | 2006-09-02 08:26:17 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-09-02 08:26:17 +0000 |
commit | 69e52cb83cf0233648695730c81cdc4f7c4f2a00 (patch) | |
tree | 5e8ebb5773cba2c1ffd827baf9a4fe528fbcaeeb /src/plugin.c | |
parent | cf11310c243320bbe53dbf7c6738cc84e33ba9d3 (diff) | |
download | lilv-69e52cb83cf0233648695730c81cdc4f7c4f2a00.tar.gz lilv-69e52cb83cf0233648695730c81cdc4f7c4f2a00.tar.bz2 lilv-69e52cb83cf0233648695730c81cdc4f7c4f2a00.zip |
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
Diffstat (limited to 'src/plugin.c')
-rw-r--r-- | src/plugin.c | 63 |
1 files changed, 56 insertions, 7 deletions
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; +} + |