diff options
-rw-r--r-- | slv2/port.h | 12 | ||||
-rw-r--r-- | src/port.c | 26 | ||||
-rw-r--r-- | src/query.c | 3 | ||||
-rw-r--r-- | utils/lv2_inspect.c | 12 |
4 files changed, 51 insertions, 2 deletions
diff --git a/slv2/port.h b/slv2/port.h index 7846541..973d400 100644 --- a/slv2/port.h +++ b/slv2/port.h @@ -40,7 +40,7 @@ extern "C" { SLV2Values slv2_port_get_value(SLV2Plugin plugin, SLV2Port port, - const char* property); + const char* property_uri); /** Return the LV2 port properties of a port. @@ -62,6 +62,16 @@ slv2_port_has_property(SLV2Plugin p, const char* property_uri); +/** Return whether a port is an event port and supports a certain event type. + * + * Time = Query + */ +bool +slv2_port_supports_event(SLV2Plugin p, + SLV2Port port, + const char* event_uri); + + /** Get the symbol of a port given the index. * * The 'symbol' is a short string, a valid C identifier. @@ -150,6 +150,32 @@ slv2_port_has_property(SLV2Plugin p, } +bool +slv2_port_supports_event(SLV2Plugin p, + SLV2Port port, + const char* event) +{ + assert(event); + + char* query = slv2_strjoin( + "ASK WHERE {\n" + "<", librdf_uri_as_string(p->plugin_uri), "> lv2:port ?port ." + "?port lv2:symbol \"", port->symbol, "\";\n", + " lv2ev:supportsEvent <", event, "> .\n" + "}", NULL); + + librdf_query_results* results = slv2_plugin_query(p, query); + assert(librdf_query_results_is_boolean(results)); + + const bool ret = librdf_query_results_get_boolean(results); + + free(query); + librdf_free_query_results(results); + + return ret; +} + + SLV2Values slv2_port_get_value(SLV2Plugin p, SLV2Port port, diff --git a/src/query.c b/src/query.c index b226f04..6dbb47f 100644 --- a/src/query.c +++ b/src/query.c @@ -33,7 +33,8 @@ static const char* slv2_query_prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" "PREFIX doap: <http://usefulinc.com/ns/doap#>\n" "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" - "PREFIX lv2: <http://lv2plug.in/ns/lv2core#>\n"; + "PREFIX lv2: <http://lv2plug.in/ns/lv2core#>\n" + "PREFIX lv2ev: <http://lv2plug.in/ns/ext/event#>\n"; #if 0 char* diff --git a/utils/lv2_inspect.c b/utils/lv2_inspect.c index 5919201..55c6478 100644 --- a/utils/lv2_inspect.c +++ b/utils/lv2_inspect.c @@ -69,6 +69,18 @@ print_port(SLV2Plugin p, uint32_t index) printf("Unknown"); } + if (type == SLV2_PORT_DATA_TYPE_EVENT) { + SLV2Values supported = slv2_port_get_value(p, port, + "lv2ev:supportsEvent"); + if (slv2_values_size(supported) > 0) { + printf("\n\t\tSupported events:\n"); + for (unsigned i=0; i < slv2_values_size(supported); ++i) { + printf("\t\t\t%s\n", slv2_value_as_uri(slv2_values_get_at(supported, i))); + } + } + slv2_values_free(supported); + } + str = slv2_port_get_symbol(p, port); printf("\n\t\tSymbol: %s\n", str); free(str); |