summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lilv/lilv.h22
-rw-r--r--src/lilv_internal.h15
-rw-r--r--src/plugin.c17
-rw-r--r--src/port.c66
-rw-r--r--utils/lv2info.c4
-rw-r--r--utils/lv2jack.c16
6 files changed, 58 insertions, 82 deletions
diff --git a/lilv/lilv.h b/lilv/lilv.h
index d3b3782..a9c2992 100644
--- a/lilv/lilv.h
+++ b/lilv/lilv.h
@@ -48,14 +48,20 @@
extern "C" {
#endif
-#define LILV_NAMESPACE_LV2 "http://lv2plug.in/ns/lv2core#"
-#define LILV_PORT_CLASS_PORT "http://lv2plug.in/ns/lv2core#Port"
-#define LILV_PORT_CLASS_INPUT "http://lv2plug.in/ns/lv2core#InputPort"
-#define LILV_PORT_CLASS_OUTPUT "http://lv2plug.in/ns/lv2core#OutputPort"
-#define LILV_PORT_CLASS_CONTROL "http://lv2plug.in/ns/lv2core#ControlPort"
-#define LILV_PORT_CLASS_AUDIO "http://lv2plug.in/ns/lv2core#AudioPort"
-#define LILV_PORT_CLASS_EVENT "http://lv2plug.in/ns/ext/event#EventPort"
-#define LILV_EVENT_CLASS_MIDI "http://lv2plug.in/ns/ext/midi#MidiEvent"
+#define LILV_NS_DOAP "http://usefulinc.com/ns/doap#"
+#define LILV_NS_LILV "http://drobilla.net/ns/lilv#"
+#define LILV_NS_LV2 "http://lv2plug.in/ns/lv2core#"
+#define LILV_NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define LILV_NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
+#define LILV_NS_XSD "http://www.w3.org/2001/XMLSchema#"
+
+#define LILV_URI_AUDIO_PORT "http://lv2plug.in/ns/lv2core#AudioPort"
+#define LILV_URI_CONTROL_PORT "http://lv2plug.in/ns/lv2core#ControlPort"
+#define LILV_URI_EVENT_PORT "http://lv2plug.in/ns/ext/event#EventPort"
+#define LILV_URI_INPUT_PORT "http://lv2plug.in/ns/lv2core#InputPort"
+#define LILV_URI_MIDI_EVENT "http: //lv2plug.in/ns/ext/midi#MidiEvent"
+#define LILV_URI_OUTPUT_PORT "http://lv2plug.in/ns/lv2core#OutputPort"
+#define LILV_URI_PORT "http://lv2plug.in/ns/lv2core#Port"
typedef struct LilvPluginImpl LilvPlugin; /**< LV2 Plugin. */
typedef struct LilvPluginClassImpl LilvPluginClass; /**< Plugin Class. */
diff --git a/src/lilv_internal.h b/src/lilv_internal.h
index caa5fbc..c405a0d 100644
--- a/src/lilv_internal.h
+++ b/src/lilv_internal.h
@@ -48,13 +48,6 @@ static inline char* dlerror(void) { return "Unknown error"; }
# include "lv2/lv2plug.in/ns/ext/dyn-manifest/dyn-manifest.h"
#endif
-#define LILV_NS_DOAP "http://usefulinc.com/ns/doap#"
-#define LILV_NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
-#define LILV_NS_LILV "http://drobilla.net/ns/lilv#"
-#define LILV_NS_LV2 "http://lv2plug.in/ns/lv2core#"
-#define LILV_NS_XSD "http://www.w3.org/2001/XMLSchema#"
-#define LILV_NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-
/*
*
* Types
@@ -66,6 +59,7 @@ typedef struct LilvSpecImpl LilvSpec;
typedef void LilvCollection;
struct LilvPortImpl {
+ SordNode* node; ///< RDF node
uint32_t index; ///< lv2:index
LilvNode* symbol; ///< lv2:symbol
LilvNodes* classes; ///< rdf:type
@@ -194,8 +188,11 @@ struct LilvUIImpl {
*
*/
-LilvPort* lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol);
-void lilv_port_free(LilvPort* port);
+LilvPort* lilv_port_new(LilvWorld* world,
+ const SordNode* node,
+ uint32_t index,
+ const char* symbol);
+void lilv_port_free(const LilvPlugin* plugin, LilvPort* port);
LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri);
void lilv_plugin_load_if_necessary(const LilvPlugin* p);
diff --git a/src/plugin.c b/src/plugin.c
index 32c40da..25ae481 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -69,8 +69,9 @@ lilv_plugin_free(LilvPlugin* p)
#endif
if (p->ports) {
- for (uint32_t i = 0; i < p->num_ports; ++i)
- lilv_port_free(p->ports[i]);
+ for (uint32_t i = 0; i < p->num_ports; ++i) {
+ lilv_port_free(p, p->ports[i]);
+ }
free(p->ports);
p->ports = NULL;
}
@@ -184,9 +185,9 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
NULL);
FOREACH_MATCH(ports) {
- LilvNode* index = NULL;
- const SordNode* port = lilv_match_object(ports);
- LilvNode* symbol = lilv_plugin_get_unique(
+ LilvNode* index = NULL;
+ const SordNode* port = lilv_match_object(ports);
+ LilvNode* symbol = lilv_plugin_get_unique(
p, port, p->world->lv2_symbol_node);
if (!lilv_node_is_string(symbol)) {
@@ -217,6 +218,7 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
// Havn't seen this port yet, add it to array
if (!this_port) {
this_port = lilv_port_new(p->world,
+ port,
this_index,
lilv_node_as_string(symbol));
p->ports[this_index] = this_port;
@@ -241,8 +243,9 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
lilv_node_free(index);
if (p->num_ports == 0) {
if (p->ports) {
- for (uint32_t i = 0; i < p->num_ports; ++i)
- lilv_port_free(p->ports[i]);
+ for (uint32_t i = 0; i < p->num_ports; ++i) {
+ lilv_port_free(p, p->ports[i]);
+ }
free(p->ports);
p->ports = NULL;
}
diff --git a/src/port.c b/src/port.c
index 48f169f..b11980a 100644
--- a/src/port.c
+++ b/src/port.c
@@ -25,18 +25,23 @@
#include "lilv_internal.h"
LilvPort*
-lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol)
+lilv_port_new(LilvWorld* world,
+ const SordNode* node,
+ uint32_t index,
+ const char* symbol)
{
LilvPort* port = malloc(sizeof(struct LilvPortImpl));
- port->index = index;
- port->symbol = lilv_node_new(world, LILV_VALUE_STRING, symbol);
+ port->node = sord_node_copy(node);
+ port->index = index;
+ port->symbol = lilv_node_new(world, LILV_VALUE_STRING, symbol);
port->classes = lilv_nodes_new();
return port;
}
void
-lilv_port_free(LilvPort* port)
+lilv_port_free(const LilvPlugin* plugin, LilvPort* port)
{
+ sord_node_free(plugin->world->world, port->node);
lilv_nodes_free(port->classes);
lilv_node_free(port->symbol);
free(port);
@@ -55,37 +60,6 @@ lilv_port_is_a(const LilvPlugin* plugin,
return false;
}
-static const SordNode*
-lilv_port_get_node(const LilvPlugin* p,
- const LilvPort* port)
-{
- SordIter* ports = lilv_world_query(
- p->world,
- p->plugin_uri->val.uri_val,
- p->world->lv2_port_node,
- NULL);
- const SordNode* ret = NULL;
- FOREACH_MATCH(ports) {
- const SordNode* node = lilv_match_object(ports);
- LilvNode* symbol = lilv_plugin_get_unique(
- p,
- node,
- p->world->lv2_symbol_node);
-
- const bool matches = lilv_node_equals(symbol,
- lilv_port_get_symbol(p, port));
-
- lilv_node_free(symbol);
- if (matches) {
- ret = node;
- break;
- }
- }
- lilv_match_end(ports);
- assert(ret);
- return ret;
-}
-
LILV_API
bool
lilv_port_has_property(const LilvPlugin* p,
@@ -93,10 +67,9 @@ lilv_port_has_property(const LilvPlugin* p,
const LilvNode* property)
{
assert(property);
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* results = lilv_world_query(
+ SordIter* results = lilv_world_query(
p->world,
- port_node,
+ port->node,
p->world->lv2_portproperty_node,
lilv_node_as_node(property));
@@ -114,10 +87,9 @@ lilv_port_supports_event(const LilvPlugin* p,
#define NS_EV (const uint8_t*)"http://lv2plug.in/ns/ext/event#"
assert(event);
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* results = lilv_world_query(
+ SordIter* results = lilv_world_query(
p->world,
- port_node,
+ port->node,
sord_new_uri(p->world->world, NS_EV "supportsEvent"),
lilv_node_as_node(event));
@@ -129,14 +101,13 @@ lilv_port_supports_event(const LilvPlugin* p,
static LilvNodes*
lilv_port_get_value_by_node(const LilvPlugin* p,
const LilvPort* port,
- const SordNode* predicate)
+ const SordNode* predicate)
{
assert(sord_node_get_type(predicate) == SORD_URI);
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* results = lilv_world_query(
+ SordIter* results = lilv_world_query(
p->world,
- port_node,
+ port->node,
predicate,
NULL);
@@ -237,10 +208,9 @@ LilvScalePoints*
lilv_port_get_scale_points(const LilvPlugin* p,
const LilvPort* port)
{
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* points = lilv_world_query(
+ SordIter* points = lilv_world_query(
p->world,
- port_node,
+ port->node,
sord_new_uri(p->world->world, (const uint8_t*)LILV_NS_LV2 "scalePoint"),
NULL);
diff --git a/utils/lv2info.c b/utils/lv2info.c
index f1f3fab..53d9b05 100644
--- a/utils/lv2info.c
+++ b/utils/lv2info.c
@@ -327,8 +327,8 @@ main(int argc, char** argv)
#define NS_PSET "http://lv2plug.in/ns/ext/presets#"
#define NS_EV "http://lv2plug.in/ns/ext/event#"
- control_class = lilv_new_uri(world, LILV_PORT_CLASS_CONTROL);
- event_class = lilv_new_uri(world, LILV_PORT_CLASS_EVENT);
+ control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT);
+ event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT);
in_group_pred = lilv_new_uri(world, NS_PG "inGroup");
preset_pred = lilv_new_uri(world, NS_PSET "hasPreset");
role_pred = lilv_new_uri(world, NS_PG "role");
diff --git a/utils/lv2jack.c b/utils/lv2jack.c
index 8a388f3..88e41d8 100644
--- a/utils/lv2jack.c
+++ b/utils/lv2jack.c
@@ -83,7 +83,7 @@ uri_to_id(LV2_URI_Map_Callback_Data callback_data,
const char* uri)
{
/* Note a non-trivial host needs to use an actual dictionary here */
- if (!strcmp(map, LV2_EVENT_URI) && !strcmp(uri, LILV_EVENT_CLASS_MIDI))
+ if (!strcmp(map, LV2_EVENT_URI) && !strcmp(uri, LILV_URI_MIDI_EVENT))
return MIDI_EVENT_ID;
else
return 0; /* Refuse to map ID */
@@ -310,13 +310,13 @@ main(int argc, char** argv)
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
/* Set up the port classes this app supports */
- host.input_class = lilv_new_uri(world, LILV_PORT_CLASS_INPUT);
- host.output_class = lilv_new_uri(world, LILV_PORT_CLASS_OUTPUT);
- host.control_class = lilv_new_uri(world, LILV_PORT_CLASS_CONTROL);
- host.audio_class = lilv_new_uri(world, LILV_PORT_CLASS_AUDIO);
- host.event_class = lilv_new_uri(world, LILV_PORT_CLASS_EVENT);
- host.midi_class = lilv_new_uri(world, LILV_EVENT_CLASS_MIDI);
- host.optional = lilv_new_uri(world, LILV_NAMESPACE_LV2
+ host.input_class = lilv_new_uri(world, LILV_URI_INPUT_PORT);
+ host.output_class = lilv_new_uri(world, LILV_URI_OUTPUT_PORT);
+ host.control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT);
+ host.audio_class = lilv_new_uri(world, LILV_URI_AUDIO_PORT);
+ host.event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT);
+ host.midi_class = lilv_new_uri(world, LILV_URI_MIDI_EVENT);
+ host.optional = lilv_new_uri(world, LILV_NS_LV2
"connectionOptional");
#ifdef LILV_JACK_SESSION