summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/hosts/jack_host.c7
-rw-r--r--examples/hosts/test_host.c2
-rw-r--r--slv2/port.h9
-rw-r--r--slv2/query.h5
-rw-r--r--slv2/types.h7
-rw-r--r--src/plugin.c8
-rw-r--r--src/pluginlist.c2
-rw-r--r--src/port.c30
-rw-r--r--src/query.c12
9 files changed, 51 insertions, 31 deletions
diff --git a/examples/hosts/jack_host.c b/examples/hosts/jack_host.c
index 2247e03..1be62b8 100644
--- a/examples/hosts/jack_host.c
+++ b/examples/hosts/jack_host.c
@@ -149,10 +149,11 @@ create_port(struct JackHost* host,
unsigned long port_index)
{
/* Make sure this is a float port */
- enum SLV2DataType type = slv2_port_get_data_type(host->plugin, port_index);
- if (type != SLV2_DATA_TYPE_FLOAT)
+ uchar* type = slv2_port_get_data_type(host->plugin, port_index);
+ if (strcmp(type, SLV2_DATA_TYPE_FLOAT))
die("Unrecognized data type, aborting.");
-
+ free(type);
+
/* Get the port symbol (label) for console printing */
char* symbol = slv2_port_get_symbol(host->plugin, port_index);
diff --git a/examples/hosts/test_host.c b/examples/hosts/test_host.c
index 3ec8d86..16efa11 100644
--- a/examples/hosts/test_host.c
+++ b/examples/hosts/test_host.c
@@ -61,7 +61,7 @@ create_audio_output()
void
create_port(SLV2Plugin* plugin,
SLV2Instance* instance,
- unsigned long port_index)
+ unsigned long port_index)
{
enum SLV2PortClass class = slv2_port_get_class(plugin, port_index);
diff --git a/slv2/port.h b/slv2/port.h
index 749ea4e..601aa49 100644
--- a/slv2/port.h
+++ b/slv2/port.h
@@ -46,7 +46,7 @@ extern "C" {
/** Get a property of a port, by port index.
*
- * Return value must be free()'d by caller.
+ * Return value must be freed by caller with slv2_property_free.
*/
SLV2Property
slv2_port_get_property(SLV2Plugin* plugin,
@@ -73,9 +73,12 @@ slv2_port_get_class(SLV2Plugin* plugin,
unsigned long index);
-/** Get the data type of a port.
+/** Get the data type of a port (as a URI).
+ *
+ * The only data type included in the core LV2 specification is lv2:float.
+ * Compare this return value with @ref SLV2_DATA_TYPE_FLOAT to check for it.
*/
-enum SLV2DataType
+uchar*
slv2_port_get_data_type(SLV2Plugin* plugin,
unsigned long index);
diff --git a/slv2/query.h b/slv2/query.h
index f1708d7..79e7301 100644
--- a/slv2/query.h
+++ b/slv2/query.h
@@ -87,10 +87,13 @@ rasqal_query_results*
slv2_plugin_run_query(const SLV2Plugin* p,
const uchar* query_string, ...);
-
SLV2Property
slv2_query_get_results(rasqal_query_results* results);
+/** Free an SLV2Property. */
+void
+slv2_property_free(SLV2Property);
+
/** @} */
diff --git a/slv2/types.h b/slv2/types.h
index b6d71cc..79b1e0f 100644
--- a/slv2/types.h
+++ b/slv2/types.h
@@ -51,11 +51,8 @@ enum SLV2PortClass {
};
-/** Type contained in a port buffer. */
-enum SLV2DataType {
- SLV2_DATA_TYPE_FLOAT, /**< IEEE-754 32-bit floating point number */
- SLV2_UNKNOWN_DATA_TYPE
-};
+/** lv2:float, IEEE-754 32-bit floating point number */
+#define SLV2_DATA_TYPE_FLOAT "http://lv2plug.in/ontology#float"
#ifdef __cplusplus
diff --git a/src/plugin.c b/src/plugin.c
index 29083e8..b44eb56 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -90,23 +90,23 @@ bool
slv2_plugin_verify(const SLV2Plugin* plugin)
{
// FIXME: finish this (properly)
- /*
+
size_t num_values = 0;
- struct SLV2Property* prop = slv2_plugin_get_property(plugin, "doap:name");
+ struct _Property* prop = slv2_plugin_get_property(plugin, "doap:name");
if (prop) {
num_values = prop->num_values;
free(prop);
}
if (num_values < 1)
return false;
-
+/*
prop = slv2_plugin_get_property(plugin, "doap:license");
num_values = prop->num_values;
free(prop);
if (num_values < 1)
return false;
-*/
+*/
return true;
}
diff --git a/src/pluginlist.c b/src/pluginlist.c
index 20e9dea..6a1a8c1 100644
--- a/src/pluginlist.c
+++ b/src/pluginlist.c
@@ -141,7 +141,7 @@ slv2_list_load_bundle(SLV2List list,
// FIXME: leaks? rasqal really doesn't handle missing files well..
if (results) {
rasqal_free_query_results(results);
- rasqal_free_query(rq);
+ //rasqal_free_query(rq); // FIXME: crashes? leak?
raptor_free_uri(base_uri); // FIXME: leak?
}
rasqal_finish();
diff --git a/src/port.c b/src/port.c
index f37f82a..f80d33b 100644
--- a/src/port.c
+++ b/src/port.c
@@ -34,6 +34,8 @@ slv2_port_get_class(SLV2Plugin* p,
assert(class->num_values == 1);
assert(class->values);
+ // FIXME FIXME FIXME: leak
+
if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#ControlRateInputPort"))
return SLV2_CONTROL_RATE_INPUT;
else if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#ControlRateOutputPort"))
@@ -49,8 +51,8 @@ slv2_port_get_class(SLV2Plugin* p,
}
-enum SLV2DataType
-slv2_port_get_data_type(SLV2Plugin* p,
+uchar*
+slv2_port_get_data_type(SLV2Plugin* p,
unsigned long index)
{
SLV2Property type = slv2_port_get_property(p, index, U("lv2:datatype"));
@@ -58,15 +60,14 @@ slv2_port_get_data_type(SLV2Plugin* p,
assert(type->num_values == 1);
assert(type->values);
- if (!strcmp((char*)type->values[0], "http://lv2plug.in/ontology#float"))
- return SLV2_DATA_TYPE_FLOAT;
- else
- return SLV2_UNKNOWN_DATA_TYPE;
+ uchar* ret = type->values[0];
+ slv2_property_free(type);
+ return ret;
}
SLV2Property
-slv2_port_get_property(SLV2Plugin* p,
+slv2_port_get_property(SLV2Plugin* p,
unsigned long index,
const uchar* property)
{
@@ -94,7 +95,8 @@ slv2_port_get_property(SLV2Plugin* p,
uchar*
-slv2_port_get_symbol(SLV2Plugin* p, unsigned long index)
+slv2_port_get_symbol(SLV2Plugin* p,
+ unsigned long index)
{
// FIXME: leaks
uchar* result = NULL;
@@ -104,7 +106,7 @@ slv2_port_get_symbol(SLV2Plugin* p, unsigned long index)
if (prop && prop->num_values == 1)
result = (uchar*)strdup((char*)prop->values[0]);
- free(prop);
+ slv2_property_free(prop);
return result;
}
@@ -124,12 +126,14 @@ slv2_port_get_default_value(SLV2Plugin* p,
if (prop && prop->num_values == 1)
result = atof((char*)prop->values[0]);
+ slv2_property_free(prop);
+
return result;
}
float
-slv2_port_get_minimum_value(SLV2Plugin* p,
+slv2_port_get_minimum_value(SLV2Plugin* p,
unsigned long index)
{
// FIXME: do casting properly in the SPARQL query
@@ -142,12 +146,14 @@ slv2_port_get_minimum_value(SLV2Plugin* p,
if (prop && prop->num_values == 1)
result = atof((char*)prop->values[0]);
+ slv2_property_free(prop);
+
return result;
}
float
-slv2_port_get_maximum_value(SLV2Plugin* p,
+slv2_port_get_maximum_value(SLV2Plugin* p,
unsigned long index)
{
// FIXME: do casting properly in the SPARQL query
@@ -160,6 +166,8 @@ slv2_port_get_maximum_value(SLV2Plugin* p,
if (prop && prop->num_values == 1)
result = atof((char*)prop->values[0]);
+ slv2_property_free(prop);
+
return result;
}
diff --git a/src/query.c b/src/query.c
index ddaf648..da9239d 100644
--- a/src/query.c
+++ b/src/query.c
@@ -50,8 +50,8 @@ slv2_query_lang_filter(const uchar* variable)
// FILTER( LANG(?value) = "en" || LANG(?value) = "" )
result = ustrjoin(
//U("FILTER (lang(?value) = \""), lang, U("\")\n"), 0);
- U("FILTER( lang(?value) = \""), lang,
- U("\" || lang(?value) = \"\" )\n"), NULL);
+ U("FILTER( lang(?"), variable, U(") = \""), lang,
+ U("\" || lang(?"), variable, U(") = \"\" )\n"), NULL);
}
return result;
@@ -122,3 +122,11 @@ slv2_query_get_results(rasqal_query_results* results)
return result;
}
+void
+slv2_property_free(struct _Property* prop)
+{
+ //struct _Property* prop = (struct _Property*)property;
+ free(prop->values);
+ free(prop);
+}
+