summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-27 07:49:37 +0000
committerDavid Robillard <d@drobilla.net>2008-01-27 07:49:37 +0000
commit6de587b04154f2efdc2a94c0a78225f7adc88ff9 (patch)
treea25b1b2e1e80fe8d7fe9a16336d9077d3b0d64b2
parent6f4460aee9962a49ae872eef42ba75a439ea6e59 (diff)
downloadlilv-6de587b04154f2efdc2a94c0a78225f7adc88ff9.tar.gz
lilv-6de587b04154f2efdc2a94c0a78225f7adc88ff9.tar.bz2
lilv-6de587b04154f2efdc2a94c0a78225f7adc88ff9.zip
Packaging stuff.
Add scale points API. Display scale points in lv2_inspect. Fix bugs resulting in returning empty collections. git-svn-id: http://svn.drobilla.net/lad/slv2@1114 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ChangeLog12
-rw-r--r--debian/Makefile.am6
-rw-r--r--debian/control8
-rwxr-xr-xdebian/rules4
-rw-r--r--debian/shlibs.local2
-rw-r--r--slv2/Makefile.am2
-rw-r--r--slv2/port.h15
-rw-r--r--slv2/scalepoint.h55
-rw-r--r--slv2/scalepoints.h73
-rw-r--r--slv2/slv2.h2
-rw-r--r--slv2/types.h8
-rw-r--r--src/Makefile.am2
-rw-r--r--src/plugin.c2
-rw-r--r--src/port.c45
-rw-r--r--src/query.c2
-rw-r--r--src/scalepoint.c63
-rw-r--r--src/scalepoints.c57
-rw-r--r--src/slv2_internal.h11
-rw-r--r--utils/lv2_inspect.c23
19 files changed, 371 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f588d3..ea49620 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,17 @@
+slv2 (0.6.0) unstable; urgency=low
+
+ * Rework API to reduce dependence of SLV2 on specific LV2 features
+ * Use SLV2Value most everywhere in the API for performance reasons
+ * Typical use case performance improvements
+ * Add support for scale points
+ * *** API BREAK ***
+
+ -- Dave Robillard <dave@drobilla.net> Sat, 26 Jan 2008 23:36:52 -0500
+
slv2 (0.5.0) unstable; urgency=low
* Update LV2 UI header (API break)
- * *** API BREAK *** (Interface version 7)
+ * *** API BREAK ***
-- Dave Robillard <dave@drobilla.net> Thu, 17 Jan 2008 18:34:29 -0500
diff --git a/debian/Makefile.am b/debian/Makefile.am
index e354d9f..757249d 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -5,8 +5,4 @@ EXTRA_DIST = \
control \
copyright \
docs \
- postinst.ex \
- postrm.ex \
- rules \
- shlibs.local \
- shlibs
+ rules
diff --git a/debian/control b/debian/control
index 52dc4f6..6b78714 100644
--- a/debian/control
+++ b/debian/control
@@ -6,20 +6,20 @@ Standards-Version: 3.7.3
Section: libs
Package: slv2
-Depends: slv2-8
+Depends: slv2-9
Architecture: any
Description: A library for simple use of LV2 plugins
SLV2 is a library geared towards music and audio applications which makes
the use of LV2 plugins <http://lv2plug.in> as simple as possible.
Package: slv2-dev
-Depends: slv2-8-dev
+Depends: slv2-9-dev
Architecture: any
Description: Development files (headers) for SLV2
Files required for compiling programs which use SLV2, and developer
documentation.
-Package: slv2-8
+Package: slv2-9
Section: libs
Architecture: any
Pre-Depends: make
@@ -28,7 +28,7 @@ Description: A library for simple use of LV2 plugins
SLV2 is a library geared towards music and audio applications which makes
the use of LV2 plugins <http://lv2plug.in> as simple as possible.
-Package: slv2-8-dev
+Package: slv2-9-dev
Section: libdevel
Architecture: any
Pre-Depends: make
diff --git a/debian/rules b/debian/rules
index 7ac2503..3818d13 100755
--- a/debian/rules
+++ b/debian/rules
@@ -63,8 +63,8 @@ install: build
dh_clean -k
dh_installdirs
- $(MAKE) DESTDIR=$(CURDIR)/debian/slv2-8 install-exec
- $(MAKE) DESTDIR=$(CURDIR)/debian/slv2-8-dev install-data install-man
+ $(MAKE) DESTDIR=$(CURDIR)/debian/slv2-9 install-exec
+ $(MAKE) DESTDIR=$(CURDIR)/debian/slv2-9-dev install-data install-man
# Build architecture-independent files here.
diff --git a/debian/shlibs.local b/debian/shlibs.local
deleted file mode 100644
index 716fd14..0000000
--- a/debian/shlibs.local
+++ /dev/null
@@ -1,2 +0,0 @@
-libslv2 0.4.3 slv2 (>> 0.4.3-0), slv2 (<< 0.4.3-99)
-libjack 0 jackd (>= 0.107.0)
diff --git a/slv2/Makefile.am b/slv2/Makefile.am
index 2c11b91..4c37778 100644
--- a/slv2/Makefile.am
+++ b/slv2/Makefile.am
@@ -13,6 +13,8 @@ slv2include_HEADERS = \
port.h \
slv2.h \
types.h \
+ scalepoint.h \
+ scalepoints.h \
util.h \
value.h \
values.h \
diff --git a/slv2/port.h b/slv2/port.h
index 5c0549c..6b55a56 100644
--- a/slv2/port.h
+++ b/slv2/port.h
@@ -138,13 +138,26 @@ slv2_port_is_a(SLV2Plugin plugin,
* Time = Query
*/
void
-slv2_port_get_range(SLV2Plugin p,
+slv2_port_get_range(SLV2Plugin plugin,
SLV2Port port,
SLV2Value* def,
SLV2Value* min,
SLV2Value* max);
+/** Get the scale points (enumeration values) of a port.
+ *
+ * This returns a collection of 'interesting' named values of a port
+ * (e.g. appropriate entries for a UI selector associated with this port).
+ *
+ * Returned value may be NULL if @a port has no scale points, otherwise it
+ * must be freed by caller with slv2_scale_points_free.
+ */
+SLV2ScalePoints
+slv2_port_get_scale_points(SLV2Plugin plugin,
+ SLV2Port port);
+
+
/** @} */
#ifdef __cplusplus
diff --git a/slv2/scalepoint.h b/slv2/scalepoint.h
new file mode 100644
index 0000000..e5fd9cf
--- /dev/null
+++ b/slv2/scalepoint.h
@@ -0,0 +1,55 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __SLV2_SCALE_POINT_H__
+#define __SLV2_SCALE_POINT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <slv2/types.h>
+
+/** \addtogroup slv2_data
+ * @{
+ */
+
+
+/** Get the label of this scale point (enumeration value)
+ *
+ * Returned value is owned by \a point and must not be freed.
+ */
+SLV2Value
+slv2_scale_point_get_label(SLV2ScalePoint point);
+
+
+/** Get the value of this scale point (enumeration value)
+ *
+ * Returned value is owned by \a point and must not be freed.
+ */
+SLV2Value
+slv2_scale_point_get_value(SLV2ScalePoint point);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_SCALE_POINT_H__ */
diff --git a/slv2/scalepoints.h b/slv2/scalepoints.h
new file mode 100644
index 0000000..baaa43c
--- /dev/null
+++ b/slv2/scalepoints.h
@@ -0,0 +1,73 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __SLV2_SCALE_POINTS_H__
+#define __SLV2_SCALE_POINTS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+#include <slv2/value.h>
+
+/** \defgroup slv2_collections Collections of scale_points/objects
+ *
+ * Ordered collections of typed scale_points which are fast for random
+ * access by index (i.e. a fancy array).
+ *
+ * @{
+ */
+
+
+/** Allocate a new, empty SLV2Values
+ */
+SLV2Values
+slv2_scale_points_new();
+
+
+/** Free an SLV2Values.
+ */
+void
+slv2_scale_points_free(SLV2Values);
+
+
+/** Get the number of elements in a string list.
+ */
+unsigned
+slv2_scale_points_size(SLV2Values list);
+
+
+/** Get a string from a string list at the given index.
+ *
+ * @return the element at \a index, or NULL if index is out of range.
+ *
+ * Time = O(1)
+ */
+SLV2ScalePoint
+slv2_scale_points_get_at(SLV2ScalePoints points, unsigned index);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_SCALE_POINTS_H__ */
+
diff --git a/slv2/slv2.h b/slv2/slv2.h
index 6d0298b..3ddd85f 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -35,6 +35,8 @@ extern "C" {
#include <slv2/util.h>
#include <slv2/value.h>
#include <slv2/values.h>
+#include <slv2/scalepoint.h>
+#include <slv2/scalepoints.h>
#include <slv2/world.h>
#ifdef __cplusplus
diff --git a/slv2/types.h b/slv2/types.h
index ce73fc3..59ebefe 100644
--- a/slv2/types.h
+++ b/slv2/types.h
@@ -68,6 +68,14 @@ typedef struct _SLV2Value* SLV2Value;
typedef void* SLV2Values;
+/** A scale point */
+typedef struct _SLV2ScalePoint* SLV2ScalePoint;
+
+
+/** A collection of scale points. */
+typedef void* SLV2ScalePoints;
+
+
/** A plugin UI */
typedef struct _SLV2UI* SLV2UI;
diff --git a/src/Makefile.am b/src/Makefile.am
index 4c192c8..148fafb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,8 @@ libslv2_la_SOURCES = \
pluginuis.c \
port.c \
query.c \
+ scalepoint.c \
+ scalepoints.c \
slv2_internal.h \
util.c \
value.c \
diff --git a/src/plugin.c b/src/plugin.c
index 6ab21b4..437bcb6 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -339,7 +339,7 @@ slv2_plugin_get_name(SLV2Plugin plugin)
// FIXME: lang?
- if (results && slv2_values_size(results) > 0) {
+ if (results) {
SLV2Value val = slv2_values_get_at(results, 0);
if (slv2_value_is_string(val))
ret = slv2_value_duplicate(val);
diff --git a/src/port.c b/src/port.c
index a76bf7b..9166fcc 100644
--- a/src/port.c
+++ b/src/port.c
@@ -26,6 +26,7 @@
#include <slv2/types.h>
#include <slv2/util.h>
#include <slv2/values.h>
+#include <slv2/scalepoints.h>
#include "slv2_internal.h"
@@ -230,6 +231,50 @@ slv2_port_get_range(SLV2Plugin p,
}
+SLV2ScalePoints
+slv2_port_get_scale_points(SLV2Plugin p,
+ SLV2Port port)
+{
+ char* query = slv2_strjoin(
+ "SELECT DISTINCT ?value ?label WHERE {\n"
+ "<", slv2_value_as_uri(p->plugin_uri), "> lv2:port ?port .\n"
+ "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\" ;\n",
+ " lv2:scalePoint ?point .\n"
+ "?point rdf:value ?value ;\n"
+ " rdfs:label ?label .\n"
+ "\n} ORDER BY ?value", NULL);
+
+ librdf_query_results* results = slv2_plugin_query(p, query);
+
+ SLV2ScalePoints ret = NULL;
+
+ if (!librdf_query_results_finished(results))
+ ret = slv2_scale_points_new();
+
+ while (!librdf_query_results_finished(results)) {
+
+ librdf_node* value_node = librdf_query_results_get_binding_value(results, 0);
+ librdf_node* label_node = librdf_query_results_get_binding_value(results, 1);
+
+ SLV2Value value = slv2_value_new_librdf_node(p->world, value_node);
+ SLV2Value label = slv2_value_new_librdf_node(p->world, label_node);
+
+ raptor_sequence_push(ret, slv2_scale_point_new(value, label));
+
+ librdf_query_results_next(results);
+ }
+
+ librdf_free_query_results(results);
+
+ free(query);
+
+ assert(!ret || slv2_values_size(ret) > 0);
+
+ return ret;
+}
+
+
+
SLV2Values
slv2_port_get_properties(SLV2Plugin p,
SLV2Port port)
diff --git a/src/query.c b/src/query.c
index cc1349a..75e85e9 100644
--- a/src/query.c
+++ b/src/query.c
@@ -45,7 +45,7 @@ slv2_query_get_variable_bindings(SLV2World world,
{
SLV2Values result = NULL;
- if (librdf_query_results_get_bindings_count(results) > 0)
+ if (!librdf_query_results_finished(results))
result = slv2_values_new();
while (!librdf_query_results_finished(results)) {
diff --git a/src/scalepoint.c b/src/scalepoint.c
new file mode 100644
index 0000000..a22fef6
--- /dev/null
+++ b/src/scalepoint.c
@@ -0,0 +1,63 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _XOPEN_SOURCE 500
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <locale.h>
+#include <raptor.h>
+#include <slv2/value.h>
+#include "slv2_internal.h"
+
+
+/* private - ownership of value and label is taken */
+SLV2ScalePoint
+slv2_scale_point_new(SLV2Value value, SLV2Value label)
+{
+ SLV2ScalePoint point = (SLV2ScalePoint)malloc(sizeof(struct _SLV2ScalePoint));
+ point->value = value;
+ point->label= label;
+ return point;
+}
+
+
+/* private */
+void
+slv2_scale_point_free(SLV2ScalePoint point)
+{
+ slv2_value_free(point->value);
+ slv2_value_free(point->label);
+ free(point);
+}
+
+
+SLV2Value
+slv2_scale_point_get_value(SLV2ScalePoint p)
+{
+ return p->value;
+}
+
+
+SLV2Value
+slv2_scale_point_get_label(SLV2ScalePoint p)
+{
+ return p->label;
+}
+
diff --git a/src/scalepoints.c b/src/scalepoints.c
new file mode 100644
index 0000000..cecd3d5
--- /dev/null
+++ b/src/scalepoints.c
@@ -0,0 +1,57 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <raptor.h>
+#include <slv2/scalepoints.h>
+#include "slv2_internal.h"
+
+
+SLV2ScalePoints
+slv2_scale_points_new()
+{
+ return raptor_new_sequence((void (*)(void*))&slv2_scale_point_free, NULL);
+}
+
+
+void
+slv2_scale_points_free(SLV2ScalePoints points)
+{
+ if (points)
+ raptor_free_sequence(points);
+}
+
+
+unsigned
+slv2_scale_points_size(SLV2ScalePoints points)
+{
+ return (points ? raptor_sequence_size(points) : 0);
+}
+
+
+SLV2ScalePoint
+slv2_scale_points_get_at(SLV2ScalePoints points, unsigned index)
+{
+ if (index > INT_MAX)
+ return NULL;
+ else
+ return (SLV2ScalePoint)raptor_sequence_get_at(points, (int)index);
+}
+
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index eda0abd..d38daa4 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -225,6 +225,17 @@ librdf_uri* slv2_value_as_librdf_uri(SLV2Value value);
void slv2_values_set_at(SLV2Values list, unsigned index, void* value);
+/* ********* Scale Points ********* */
+
+struct _SLV2ScalePoint {
+ SLV2Value value;
+ SLV2Value label;
+};
+
+SLV2ScalePoint slv2_scale_point_new(SLV2Value value, SLV2Value label);
+void slv2_scale_point_free(SLV2ScalePoint point);
+
+
/* String utility functions */
char* slv2_strjoin(const char* first, ...);
diff --git a/utils/lv2_inspect.c b/utils/lv2_inspect.c
index fca4d6c..266d9e6 100644
--- a/utils/lv2_inspect.c
+++ b/utils/lv2_inspect.c
@@ -52,6 +52,17 @@ print_port(SLV2Plugin p, uint32_t index)
slv2_values_free(supported);
}
+ SLV2ScalePoints points = slv2_port_get_scale_points(p, port);
+ if (points)
+ printf("\t\tScale Points:\n");
+ for (unsigned i=0; i < slv2_scale_points_size(points); ++i) {
+ SLV2ScalePoint p = slv2_scale_points_get_at(points, i);
+ printf("\t\t\t%s = \"%s\"\n",
+ slv2_value_as_string(slv2_scale_point_get_value(p)),
+ slv2_value_as_string(slv2_scale_point_get_label(p)));
+ }
+ slv2_scale_points_free(points);
+
SLV2Value val = slv2_port_get_symbol(p, port);
printf("\n\t\tSymbol: %s\n", slv2_value_as_string(val));
@@ -162,28 +173,32 @@ print_plugin(SLV2Plugin p)
/* Required Features */
SLV2Values features = slv2_plugin_get_required_features(p);
- printf("\tRequired Features: ");
+ if (features)
+ printf("\tRequired Features: ");
for (unsigned i=0; i < slv2_values_size(features); ++i) {
if (i > 0) {
printf("\n\t ");
}
printf("%s\n", slv2_value_as_uri(slv2_values_get_at(features, i)));
}
- printf("\n");
+ if (features)
+ printf("\n");
slv2_values_free(features);
/* Optional Features */
features = slv2_plugin_get_optional_features(p);
- printf("\tOptional Features: ");
+ if (features)
+ printf("\tOptional Features: ");
for (unsigned i=0; i < slv2_values_size(features); ++i) {
if (i > 0) {
printf("\n\t ");
}
printf("%s\n", slv2_value_as_uri(slv2_values_get_at(features, i)));
}
- printf("\n");
+ if (features)
+ printf("\n");
slv2_values_free(features);