[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/3rdparty/slv2 CMakeLists.txt slv2/...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/3rdparty/slv2 CMakeLists.txt slv2/... |
Date: |
Wed, 07 Nov 2007 11:41:53 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/11/07 11:41:53
Modified files:
src/3rdparty/slv2: CMakeLists.txt
src/3rdparty/slv2/slv2: lv2.h pluginclasses.h pluginclass.h
plugin.h plugininstance.h plugins.h
port.h slv2.h types.h value.h values.h
world.h
src/3rdparty/slv2/src: plugin.c pluginclass.c pluginclasses.c
plugininstance.c plugins.c port.c query.c
slv2_internal.h value.c values.c world.c
Added files:
src/3rdparty/slv2/slv2: lv2_gui.h pluginui.h pluginuiinstance.h
pluginuis.h
src/3rdparty/slv2/src: pluginui.c pluginuiinstance.c pluginuis.c
Log message:
* update slv2 to latest svn version, since version 0.2.0 didn't work
(plugins acted weird, and 0.2.0 didn't look into all directories)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/CMakeLists.txt?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/lv2.h?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginclasses.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginclass.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/plugin.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/plugininstance.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/plugins.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/port.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/slv2.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/types.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/value.h?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/values.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/world.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/lv2_gui.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginui.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginuiinstance.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginuis.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/plugin.c?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginclass.c?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginclasses.c?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/plugininstance.c?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/plugins.c?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/port.c?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/query.c?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/slv2_internal.h?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/value.c?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/values.c?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/world.c?cvsroot=traverso&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginui.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginuiinstance.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginuis.c?cvsroot=traverso&rev=1.1
Patches:
Index: CMakeLists.txt
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/CMakeLists.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CMakeLists.txt 5 Nov 2007 16:15:26 -0000 1.1
+++ CMakeLists.txt 7 Nov 2007 11:41:50 -0000 1.2
@@ -3,6 +3,9 @@
SET(TRAVERSO_SLV2_SOURCES
src/plugin.c
+src/pluginui.c
+src/pluginuiinstance.c
+src/pluginuis.c
src/pluginclass.c
src/pluginclasses.c
src/plugininstance.c
Index: slv2/lv2.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/lv2.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- slv2/lv2.h 8 Jun 2007 09:29:06 -0000 1.2
+++ slv2/lv2.h 7 Nov 2007 11:41:50 -0000 1.3
@@ -1,8 +1,8 @@
/* LV2 - LADSPA (Linux Audio Developer's Simple Plugin API) Version 2.0
- * *** PROVISIONAL ***
+ * *** PROVISIONAL Revision 1.0beta6 (2007-10-03) ***
*
* Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
- * Stefan Westerfeld
+ * Stefan Westerfeld.
* Copyright (C) 2006-2007 Steve Harris, Dave Robillard.
*
* This header is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
/** @file lv2.h
*
- * Revision: 1.0beta3
+ * Revision: 1.0beta6
*
* == Overview ==
*
@@ -54,18 +54,19 @@
* possible - the data file is mandatory.
*
* Plugins are expected to distinguish between control rate and audio
- * rate data. Plugins have 'ports' that are inputs or outputs for audio
- * or control data and each plugin is 'run' for a 'block' corresponding
- * to a short time interval measured in samples. Audio rate data is
- * communicated using arrays with one element per sample processed,
+ * rate data (or other types of data defined by extensions). Plugins have
+ * 'ports' that are inputs or outputs and each plugin is 'run' for a 'block'
+ * corresponding to a short time interval measured in samples. Audio rate
+ * data is communicated using arrays with one element per sample processed,
* allowing a block of audio to be processed by the plugin in a single
* pass. Control rate data is communicated using single values. Control
* rate data has a single value at the start of a call to the 'run()'
* function, and may be considered to remain this value for its duration.
- * Thus the 'control rate' is determined by the block size, controlled
- * by the host. The plugin may assume that all its input and output
- * ports have been connected to the relevant data location (see the
- * 'connect_port()' function below) before it is asked to run.
+ * Thus the 'control rate' is determined by the block size, controlled by
+ * the host. The plugin may assume that all its input and output ports have
+ * been connected to the relevant data location (see the 'connect_port()'
+ * function below) before it is asked to run, unless the port has been set
+ * 'connection optional' in the plugin's data file.
*
* Plugins will reside in shared object files suitable for dynamic linking
* by dlopen() and family. The file will provide a number of 'plugin
@@ -84,14 +85,16 @@
* To facilitate this, the functions provided by a plugin are divided into
* classes:
*
+ * - Discovery class: lv2_descriptor(), extension_data()
+ * - Instantiation class: instantiate(), cleanup(), activate(), deactivate()
* - Audio class: run(), connect_port()
- * - Instantiation class: instantiate(), cleanup(),
- * activate(), deactivate()
*
* Extensions to this specification which add new functions MUST declare in
* which of these classes the functions belong, or define new classes for them.
* The rules that hosts must follow are these:
*
+ * - When a function from the Discovery class is running, no other
+ * functions in the same shared object file may run.
* - When a function from the Instantiation class is running for a plugin
* instance, no other functions for that instance may run.
* - When a function is running for a plugin instance, no other
@@ -100,9 +103,6 @@
* Any simultaneous calls that are not explicitly forbidden by these rules
* are allowed. For example, a host may call run() for two different plugin
* instances simultaneously.
- *
- * The extension_data() function and the lv2_descriptor() function are never
- * associated with any plugin instances and may be called at any time.
*/
@@ -121,20 +121,19 @@
/* ************************************************************************* */
-/** Host feature.
+/** Feature data.
*
* These are passed to a plugin's instantiate method to represent a special
* feature the host has which the plugin may depend on. This is to allow
- * extensions to the LV2 specification without causing any breakage. The base
- * LV2 specification does not define any host features; hosts are not required
- * to use this facility.
- */
-typedef struct _LV2_Host_Feature {
+ * extensions to the LV2 specification without causing any breakage.
+ * Extensions may specify what data needs to be passed here. The base
+ * LV2 specification does not define any features; hosts are not required
+ * to use this facility. */
+typedef struct _LV2_Feature {
/** A globally unique, case-sensitive identifier for this feature.
*
* This MUST be defined in the specification of any LV2 extension which
- * defines a host feature.
- */
+ * defines a host feature. */
const char * URI;
/** Pointer to arbitrary data.
@@ -144,10 +143,9 @@
* specification makes no restrictions on the contents of this data.
* The data here MUST be cleary defined by the LV2 extension which
defines
* this feature.
- * If no data is required, this may be set to NULL.
- */
+ * If no data is required, this may be set to NULL. */
void * data;
-} LV2_Host_Feature;
+} LV2_Feature;
/* ************************************************************************* */
@@ -195,10 +193,10 @@
* Note that instance initialisation should generally occur in
* activate() rather than here. If a host calls instantiate, it MUST
* call cleanup() at some point in the future. */
- LV2_Handle (*instantiate)(const struct _LV2_Descriptor * Descriptor,
- uint32_t SampleRate,
- const char * BundlePath,
- const LV2_Host_Feature *const * HostFeatures);
+ LV2_Handle (*instantiate)(const struct _LV2_Descriptor * descriptor,
+ double sample_rate,
+ const char * bundle_path,
+ const LV2_Feature *const * features);
/** Function pointer that connects a port on a plugin instance to a memory
* location where the block of data for the port will be read/written.
@@ -210,6 +208,10 @@
* present at the time of this connection call MUST NOT be
* considered meaningful.
*
+ * The host MUST NOT try to connect a data buffer to a port index
+ * that is not defined in the RDF data for the plugin. If it does,
+ * the plugin's behaviour is undefined.
+ *
* connect_port() may be called more than once for a plugin instance
* to allow the host to change the buffers that the plugin is reading
* or writing. These calls may be made before or after activate()
@@ -228,12 +230,12 @@
* However, overlapped buffers or use of a single buffer for both
* audio and control data may result in unexpected behaviour.
*
- * If the plugin has the property lv2:hardRTCapable then there are
+ * If the plugin has the feature lv2:hardRTCapable then there are
* various things that the plugin MUST NOT do within the connect_port()
* function (see lv2.ttl). */
- void (*connect_port)(LV2_Handle Instance,
- uint32_t Port,
- void * DataLocation);
+ void (*connect_port)(LV2_Handle instance,
+ uint32_t port,
+ void * data_location);
/** Function pointer that initialises a plugin instance and activates
* it for use.
@@ -257,7 +259,7 @@
*
* Note that connect_port() may be called before or after a call to
* activate(). */
- void (*activate)(LV2_Handle Instance);
+ void (*activate)(LV2_Handle instance);
/** Function pointer that runs a plugin instance for a block.
*
@@ -270,11 +272,11 @@
* the plugin instance may not be reused until activate() has been
* called again.
*
- * If the plugin has the property lv2:hardRTCapable then there are
+ * If the plugin has the feature lv2:hardRTCapable then there are
* various things that the plugin MUST NOT do within the run()
* function (see lv2.ttl). */
- void (*run)(LV2_Handle Instance,
- uint32_t SampleCount);
+ void (*run)(LV2_Handle instance,
+ uint32_t sampleCount);
/** This is the counterpart to activate() (see above). If there is
* nothing for deactivate() to do then the plugin writer may provide
@@ -291,7 +293,7 @@
* instance will be reinitialised when activate() is called to reuse it.
* Hosts MUST NOT call deactivate() unless activate() was previously
* called. */
- void (*deactivate)(LV2_Handle Instance);
+ void (*deactivate)(LV2_Handle instance);
/** This is the counterpart to instantiate() (see above). Once an instance
* of a plugin has been finished with it can be deleted using this
@@ -302,7 +304,7 @@
* call to deactivate() MUST be made before cleanup() is called.
* Hosts MUST NOT call cleanup() unless instantiate() was previously
* called. */
- void (*cleanup)(LV2_Handle Instance);
+ void (*cleanup)(LV2_Handle instance);
/** Function pointer that can be used to return additional instance data for
* a plugin defined by some extenion (e.g. a struct containing additional
@@ -320,14 +322,15 @@
* as a discovery method (e.g. hosts should only call this function for
* extensions known to be supported by the plugin from the data file).
*
- * NOTE: It is highly recommended that this function returns a struct, and
- * NOT a direct function pointer. Standard C++ (for real reasons) does not
+ * The host is never responsible for freeing the returned value.
+ *
+ * NOTE: This function should return a struct (likely containing
function
+ * pointers) and NOT a direct function pointer. Standard C and C++ do
not
* allow type casts from void* to a function pointer type. To provide
* additional functions a struct should be returned containing the extra
- * function pointers (which is valid standard C++, and a much better idea
- * for extensibility anyway).
- */
- void* (*extension_data)(const char * URI);
+ * function pointers (which is valid standard code, and a much better
idea
+ * for extensibility anyway). */
+ const void* (*extension_data)(const char * uri);
} LV2_Descriptor;
@@ -360,12 +363,12 @@
* index that results in NULL being returned. Index has no meaning,
* hosts MUST NOT depend on it remaining constant (ie when serialising)
* in any way. */
-const LV2_Descriptor * lv2_descriptor(uint32_t Index);
+const LV2_Descriptor * lv2_descriptor(uint32_t index);
/** Datatype corresponding to the lv2_descriptor() function. */
typedef const LV2_Descriptor *
-(*LV2_Descriptor_Function)(uint32_t Index);
+(*LV2_Descriptor_Function)(uint32_t index);
/* ******************************************************************** */
Index: slv2/pluginclasses.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/pluginclasses.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- slv2/pluginclasses.h 8 Jun 2007 09:29:06 -0000 1.1
+++ slv2/pluginclasses.h 7 Nov 2007 11:41:50 -0000 1.2
@@ -25,8 +25,7 @@
extern "C" {
#endif
-/** \defgroup plugin_classes Plugin classes
- *
+/** \addtogroup collections
* @{
*/
Index: slv2/pluginclass.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/pluginclass.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- slv2/pluginclass.h 8 Jun 2007 09:29:06 -0000 1.1
+++ slv2/pluginclass.h 7 Nov 2007 11:41:50 -0000 1.2
@@ -33,6 +33,7 @@
/** Get the URI of this class' superclass.
*
* Returned value is owned by \a plugin_class and must not be freed by caller.
+ * Returned value may be NULL, if class has no parent.
*
* Time = O(1)
*/
Index: slv2/plugin.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/plugin.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- slv2/plugin.h 6 Nov 2007 18:22:41 -0000 1.3
+++ slv2/plugin.h 7 Nov 2007 11:41:50 -0000 1.4
@@ -153,7 +153,7 @@
*
* <code><plugin-uri> predicate ?object</code>
*
- * May return NULL if the property was not found, or if object is not
+ * May return NULL if the property was not found, or if object(s) is not
* sensibly represented as an SLV2Values (e.g. blank nodes).
*
* Return value must be freed by caller with slv2_values_free.
@@ -195,31 +195,51 @@
const char* predicate);
-/** Get the LV2 Properties of a plugin.
+/** Get the LV2 Features supported (required or optionally) by a plugin.
+ *
+ * A feature is "supported" by a plugin if it is required OR optional.
*
- * LV2 Properties are mandatory. Hosts MUST NOT use a plugin if they do not
- * understand all the LV2 Properties associated with that plugin (if this is
- * not what you want, see slv2_plugin_get_hints).
+ * Since required features have special rules the host must obey, this function
+ * probably shouldn't be used by normal hosts. Using
slv2_plugin_get_optional_features
+ * and slv2_plugin_get_required_features separately is best in most cases.
*
- * Return value must be freed by caller with slv2_value_free.
+ * Returned value must be freed by caller with slv2_values_free.
*
* Time = Query
*/
SLV2Values
-slv2_plugin_get_properties(SLV2Plugin p);
+slv2_plugin_get_supported_features(SLV2Plugin p);
-/** Get the LV2 Hints of a plugin.
+/** Get the LV2 Features required by a plugin.
*
- * LV2 Hints are suggestions that may be useful for a host. LV2 Hints may be
- * ignored and the plugin will still function correctly.
+ * If a feature is required by a plugin, hosts MUST NOT use the plugin if they
do not
+ * understand (or are unable to support) that feature.
*
- * Return value must be freed by caller with slv2_value_free.
+ * All values returned here MUST be passed to the plugin's instantiate method
+ * (along with data, if necessary, as defined by the feature specification)
+ * or plugin instantiation will fail.
+ *
+ * Return value must be freed by caller with slv2_values_free.
*
* Time = Query
*/
SLV2Values
-slv2_plugin_get_hints(SLV2Plugin p);
+slv2_plugin_get_required_features(SLV2Plugin p);
+
+
+/** Get the LV2 Features optionally supported by a plugin.
+ *
+ * Hosts MAY ignore optional plugin features for whatever reasons. Plugins
+ * MUST operate (at least somewhat) if they are instantiated without being
+ * passed optional features.
+ *
+ * Return value must be freed by caller with slv2_values_free.
+ *
+ * Time = Query
+ */
+SLV2Values
+slv2_plugin_get_optional_features(SLV2Plugin p);
/** Get the number of ports on this plugin.
@@ -241,8 +261,7 @@
slv2_plugin_has_latency(SLV2Plugin p);
-/** Return the index of the plugin's latency port, or the empty string if the
- * plugin has no latency.
+/** Return the index of the plugin's latency port.
*
* It is a fatal error to call this on a plugin without checking if the port
* exists by first calling slv2_plugin_has_latency.
@@ -257,39 +276,6 @@
slv2_plugin_get_latency_port(SLV2Plugin p);
-/** Get a plugin's supported host features / extensions.
- *
- * This returns a list of all supported features (both required and optional).
- *
- * Time = Query
- */
-SLV2Values
-slv2_plugin_get_supported_features(SLV2Plugin p);
-
-
-/** Get a plugin's requires host features / extensions.
- *
- * All feature URI's returned by this call MUST be passed to the plugin's
- * instantiate method for the plugin to instantiate successfully.
- *
- * Time = Query
- */
-SLV2Values
-slv2_plugin_get_required_features(SLV2Plugin p);
-
-
-/** Get a plugin's optional host features / extensions.
- *
- * If the feature URI's returned by this method are passed to the plugin's
- * instantiate method, those features will be used by the function, otherwise
- * the plugin will act as it would if it did not support that feature at all.
- *
- * Time = Query
- */
-SLV2Values
-slv2_plugin_get_optional_features(SLV2Plugin p);
-
-
/** Query a plugin for a single variable.
*
* \param plugin The plugin to query.
@@ -342,30 +328,20 @@
const char* symbol);
-/** Get a list of all GUIs available for this plugin.
+/** Get a list of all UIs available for this plugin.
*
- * Note this returns the URI of the GUI, and not the path/URI to its shared
- * library, use slv2_plugin_gui_get_library_uri with the values returned
+ * Note this returns the URI of the UI, and not the path/URI to its shared
+ * library, use slv2_ui_get_library_uri with the values returned
* here for that.
*
- * \param plugin The plugin to get the GUIs for.
- *
- * Time = Query
- */
-SLV2Values
-slv2_plugin_get_guis(SLV2Plugin plugin);
-
-
-/** Get the URI for a GUI library.
+ * Returned value must be freed by caller using slv2_uis_free.
*
- * \param plugin The plugin that the GUI is for.
- * \param gui A GUI identifier as returned by slv2_plugin_get_guis() (with
type SLV2_VALUE_GUI).
+ * \param plugin The plugin to get the UIs for.
*
* Time = Query
*/
-SLV2Value
-slv2_plugin_get_gui_library_uri(SLV2Plugin plugin,
- SLV2Value gui);
+SLV2UIs
+slv2_plugin_get_uis(SLV2Plugin plugin);
/** @} */
Index: slv2/plugininstance.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/plugininstance.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- slv2/plugininstance.h 6 Nov 2007 18:22:41 -0000 1.3
+++ slv2/plugininstance.h 7 Nov 2007 11:41:50 -0000 1.4
@@ -74,7 +74,7 @@
SLV2Instance
slv2_plugin_instantiate(SLV2Plugin plugin,
double sample_rate,
- const LV2_Host_Feature** host_features);
+ const LV2_Feature** features);
/** Free a plugin instance.
@@ -147,9 +147,9 @@
{
assert(instance);
assert(instance->lv2_descriptor);
- assert(instance->lv2_handle),
- assert(instance->lv2_descriptor->run);
+ assert(instance->lv2_handle);
+ if (instance->lv2_descriptor->run)
instance->lv2_descriptor->run(instance->lv2_handle, sample_count);
}
Index: slv2/plugins.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/plugins.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- slv2/plugins.h 8 Jun 2007 09:29:06 -0000 1.1
+++ slv2/plugins.h 7 Nov 2007 11:41:50 -0000 1.2
@@ -26,12 +26,7 @@
extern "C" {
#endif
-/** \defgroup plugins Collections of plugins
- *
- * These functions work with lists of plugins which come from an
- * SLV2World. These lists contain only a weak reference to an LV2 plugin
- * in the Model.
- *
+/** \addtogroup collections
* @{
*/
Index: slv2/port.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/port.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- slv2/port.h 6 Nov 2007 18:22:42 -0000 1.3
+++ slv2/port.h 7 Nov 2007 11:41:51 -0000 1.4
@@ -33,7 +33,7 @@
*/
-/** Port equivalent to slv2_plugin_get_value.
+/** Port analog of slv2_plugin_get_value.
*
* Time = Query
*/
@@ -43,7 +43,7 @@
const char* property);
-/** Port equivalent to slv2_plugin_get_properties.
+/** Return the LV2 port properties of a port.
*
* Time = Query
*/
@@ -52,25 +52,18 @@
SLV2Port port);
-/** Port equivalent to slv2_plugin_get_hints.
- *
- * Time = Query
- */
-SLV2Values
-slv2_port_get_hints(SLV2Plugin plugin,
- SLV2Port port);
-
#if 0
-/** Return whether a port has a certain hint.
+/** Return whether a port has a certain property.
*
* Time = Query
*/
bool
-slv2_port_has_hint(SLV2Plugin p,
+slv2_port_has_property(SLV2Plugin p,
SLV2Port port,
SLV2Value hint)
#endif
+
/** Get the symbol of a port given the index.
*
* The 'symbol' is a short string, a valid C identifier.
Index: slv2/slv2.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/slv2.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- slv2/slv2.h 6 Nov 2007 18:22:42 -0000 1.3
+++ slv2/slv2.h 7 Nov 2007 11:41:51 -0000 1.4
@@ -24,13 +24,14 @@
#endif
#include <slv2/types.h>
-#include <slv2/gui.h>
#include <slv2/world.h>
#include <slv2/pluginclass.h>
#include <slv2/plugin.h>
+#include <slv2/pluginui.h>
+#include <slv2/pluginuis.h>
#include <slv2/port.h>
#include <slv2/plugins.h>
-#include <slv2/pluginguiinstance.h>
+#include <slv2/pluginuiinstance.h>
#include <slv2/plugininstance.h>
#include <slv2/value.h>
#include <slv2/values.h>
Index: slv2/types.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/types.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- slv2/types.h 6 Nov 2007 18:22:42 -0000 1.3
+++ slv2/types.h 7 Nov 2007 11:41:51 -0000 1.4
@@ -69,13 +69,6 @@
} SLV2URIType;
-/** A type of plugin GUI (corresponding to some LV2 GUI extension).
- */
-typedef enum _SLV2GUIType {
- SLV2_GUI_TYPE_GTK2 ///< http://ll-plugins.nongnu.org/lv2/ext/gtk2gui
-} SLV2GUIType;
-
-
/** A port on a plugin. Opaque, but valid to compare to NULL. */
typedef struct _SLV2Port* SLV2Port;
@@ -108,8 +101,12 @@
typedef void* SLV2Values;
-/** A plugin GUI */
-typedef void* SLV2GUI;
+/** A plugin UI */
+typedef struct _SLV2UI* SLV2UI;
+
+
+/** A collection of plugin UIs. */
+typedef void* SLV2UIs;
#ifdef __cplusplus
Index: slv2/value.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/value.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- slv2/value.h 6 Nov 2007 18:22:42 -0000 1.2
+++ slv2/value.h 7 Nov 2007 11:41:51 -0000 1.3
@@ -31,6 +31,10 @@
*/
+/*SLV2Value
+slv2_value_new_uri(const char* uri);*/
+
+
/** Free an SLV2Value.
*/
void
@@ -73,8 +77,7 @@
/** Return this value as a URI string, e.g. "http://example.org/foo".
*
- * Valid to call only if slv2_value_is_uri(\a value) or
- * slv2_value_is_gui(\a value) returns true.
+ * Valid to call only if slv2_value_is_uri(\a value) returns true.
* Returned value is owned by \a value and must not be freed by caller.
*
* Time = O(1)
@@ -172,29 +175,6 @@
slv2_value_as_int(SLV2Value value);
-/** Return whether this value is a GUI (URI and type).
- *
- * If this returns true, slv2_value_as_uri will return the URI of the GUI,
- * and slv2_value_as_gui_type will return the SLV2GUIType (which can be
- * used to find the URI of the corresponding GUI spec itself, with
- * slv2_gui_type_get_uri).
- *
- * Time = O(1)
- */
-bool
-slv2_value_is_gui(SLV2Value value);
-
-
-/** Return \a value as an SLV2GUIType.
- *
- * Valid to call only if slv2_value_is_gui(\a value) returns true.
- *
- * Time = O(1)
- */
-SLV2GUIType
-slv2_value_as_gui_type(SLV2Value value);
-
-
/** @} */
#ifdef __cplusplus
Index: slv2/values.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/values.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- slv2/values.h 8 Jun 2007 09:29:07 -0000 1.1
+++ slv2/values.h 7 Nov 2007 11:41:51 -0000 1.2
@@ -26,9 +26,9 @@
extern "C" {
#endif
-/** \defgroup values Collections of values
+/** \defgroup collections Collections of values/objects
*
- * SLV2Values is an ordered collection of typed values which is fast for random
+ * Ordered collections of typed values which are fast for random
* access by index (i.e. a fancy array).
*
* @{
Index: slv2/world.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/world.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- slv2/world.h 6 Nov 2007 18:22:42 -0000 1.3
+++ slv2/world.h 7 Nov 2007 11:41:51 -0000 1.4
@@ -27,7 +27,7 @@
extern "C" {
#endif
-/** \defgroup world Library
+/** \defgroup world Global library state
*
* The "world" represents all library state, and the data found in bundles'
* manifest.ttl (ie it is an in-memory index of all things LV2 found).
@@ -70,31 +70,6 @@
void
slv2_world_free(SLV2World world);
-#if 0
-/** Set the RDF lock function.
- *
- * If set, this function will be called before any calls to librdf functions.
- * This can be used to make SLV2 thread-safe.
- *
- * \a lock will be called with \a data as a parameter, whenever SLV2 is going
- * to perform an RDF operation.
- */
-void
-slv2_world_set_rdf_lock_function(SLV2World world, void (*lock)(void*), void*
data);
-
-
-/** Set the unlock function.
- *
- * This is the counterpart to the RDF lock function set with
- * slv2_world_set_rdf_lock_function. Be sure to call this after locking,
- * or a deadlock will occur.
- *
- * \a unlock will be called with the same data pointer set with
- * slv2_world_set_rdf_lock_function.
- */
-void
-slv2_world_set_rdf_unlock_function(SLV2World world, void (*unlock)(void*));
-#endif
/** Load all installed LV2 bundles on the system.
*
Index: src/plugin.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/plugin.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/plugin.c 6 Nov 2007 18:22:42 -0000 1.3
+++ src/plugin.c 7 Nov 2007 11:41:51 -0000 1.4
@@ -29,6 +29,7 @@
#include <slv2/values.h>
#include <slv2/pluginclass.h>
#include <slv2/pluginclasses.h>
+#include <slv2/pluginuis.h>
/* private */
@@ -166,8 +167,11 @@
while (!librdf_query_results_finished(results)) {
librdf_node* class_node =
librdf_query_results_get_binding_value(results, 0);
librdf_uri* class_uri = librdf_node_get_uri(class_node);
+ assert(class_uri);
const char* class_uri_str = (const
char*)librdf_uri_as_string(class_uri);
+ if ( ! librdf_uri_equals(class_uri,
p->world->lv2_plugin_class->uri) ) {
+
SLV2PluginClass plugin_class = slv2_plugin_classes_get_by_uri(
p->world->plugin_classes, class_uri_str);
@@ -177,12 +181,13 @@
p->plugin_class = plugin_class;
break;
}
+ }
librdf_query_results_next(results);
}
if (p->plugin_class == NULL)
- p->plugin_class =
raptor_sequence_get_at(p->world->plugin_classes, 0); // lv2:Plugin
+ p->plugin_class = p->world->lv2_plugin_class;
librdf_free_query_results(results);
librdf_free_query(q);
@@ -239,6 +244,8 @@
const char*
slv2_plugin_get_uri(SLV2Plugin p)
{
+ assert(p);
+ assert(p->plugin_uri);
return (const char*)librdf_uri_as_string(p->plugin_uri);
}
@@ -246,6 +253,8 @@
const char*
slv2_plugin_get_bundle_uri(SLV2Plugin p)
{
+ assert(p);
+ assert(p->bundle_uri);
return (const char*)librdf_uri_as_string(p->bundle_uri);
}
@@ -253,6 +262,8 @@
const char*
slv2_plugin_get_library_uri(SLV2Plugin p)
{
+ assert(p);
+ assert(p->binary_uri);
return (const char*)librdf_uri_as_string(p->binary_uri);
}
@@ -453,7 +464,7 @@
const char* const query =
"SELECT DISTINCT ?index WHERE {\n"
" <> lv2:port ?port .\n"
- " ?port lv2:portHint lv2:reportsLatency ;\n"
+ " ?port lv2:portProperty lv2:reportsLatency ;\n"
" lv2:index ?index .\n"
"}\n";
@@ -471,7 +482,7 @@
const char* const query =
"SELECT DISTINCT ?index WHERE {\n"
" <> lv2:port ?port .\n"
- " ?port lv2:portHint lv2:reportsLatency ;\n"
+ " ?port lv2:portProperty lv2:reportsLatency ;\n"
" lv2:index ?index .\n"
"}\n";
@@ -491,9 +502,9 @@
{
const char* const query =
"SELECT DISTINCT ?feature WHERE {\n"
- " { <> lv2:optionalHostFeature ?feature }\n"
+ " { <> lv2:optionalFeature ?feature }\n"
" UNION\n"
- " { <> lv2:requiredHostFeature ?feature }\n"
+ " { <> lv2:requiredFeature ?feature }\n"
"}\n";
SLV2Values result = slv2_plugin_simple_query(p, query, 0);
@@ -505,28 +516,14 @@
SLV2Values
slv2_plugin_get_optional_features(SLV2Plugin p)
{
- const char* const query =
- "SELECT DISTINCT ?feature WHERE {\n"
- " <> lv2:optionalHostFeature ?feature\n"
- "}\n";
-
- SLV2Values result = slv2_plugin_simple_query(p, query, 0);
-
- return result;
+ return slv2_plugin_get_value(p, SLV2_QNAME, "lv2:optionalFeature");
}
SLV2Values
slv2_plugin_get_required_features(SLV2Plugin p)
{
- const char* const query =
- "SELECT DISTINCT ?feature WHERE {\n"
- " <> lv2:requiredHostFeature ?feature\n"
- "}\n";
-
- SLV2Values result = slv2_plugin_simple_query(p, query, 0);
-
- return result;
+ return slv2_plugin_get_value(p, SLV2_QNAME, "lv2:requiredFeature");
}
@@ -559,36 +556,62 @@
}
-SLV2Values
-slv2_plugin_get_guis(SLV2Plugin plugin)
+SLV2UIs
+slv2_plugin_get_uis(SLV2Plugin plugin)
{
- if (!plugin->rdf)
- slv2_plugin_load(plugin);
+ const char* const query_str =
+ "PREFIX guiext:
<http://ll-plugins.nongnu.org/lv2/ext/gui/dev/1#>\n"
+ "SELECT DISTINCT ?uri ?type ?binary WHERE {\n"
+ "<> guiext:gui ?uri .\n"
+ "?uri a ?type ;\n"
+ " guiext:binary ?binary .\n"
+ "}\n";
+
+ librdf_query_results* results = slv2_plugin_query(plugin, query_str);
+
+ SLV2UIs result = slv2_uis_new();
+
+ while (!librdf_query_results_finished(results)) {
+ librdf_node* uri_node =
librdf_query_results_get_binding_value(results, 0);
+ librdf_node* type_node =
librdf_query_results_get_binding_value(results, 1);
+ librdf_node* binary_node =
librdf_query_results_get_binding_value(results, 2);
+
+ SLV2UI ui = slv2_ui_new(plugin->world,
+ librdf_node_get_uri(uri_node),
+ librdf_node_get_uri(type_node),
+ librdf_node_get_uri(binary_node));
- SLV2Values result = slv2_plugin_get_value(plugin, SLV2_URI,
- "http://ll-plugins.nongnu.org/lv2/ext/gtk2gui#gui");
+ raptor_sequence_push(result, ui);
- for (int i=0; i < raptor_sequence_size(result); ++i) {
- SLV2Value val = (SLV2Value)raptor_sequence_get_at(result, i);
- val->type = SLV2_VALUE_GUI;
- val->val.gui_type_val = SLV2_GUI_TYPE_GTK2;
+ librdf_free_node(uri_node);
+ librdf_free_node(type_node);
+ librdf_free_node(binary_node);
+
+ librdf_query_results_next(results);
}
+ librdf_free_query_results(results);
+
+ if (slv2_uis_size(result) > 0) {
return result;
+ } else {
+ slv2_uis_free(result);
+ return NULL;
+ }
}
-
+#if 0
SLV2Value
-slv2_plugin_get_gui_library_uri(SLV2Plugin plugin,
- SLV2Value gui)
+slv2_plugin_get_ui_library_uri(SLV2Plugin plugin,
+ SLV2Value ui)
{
- assert(gui->type == SLV2_VALUE_GUI);
+ assert(ui->type == SLV2_VALUE_UI);
if (!plugin->rdf)
slv2_plugin_load(plugin);
- SLV2Values values = slv2_plugin_get_value_for_subject(plugin, gui,
SLV2_URI,
- "http://ll-plugins.nongnu.org/lv2/ext/gtk2gui#binary");
+ SLV2Values values = slv2_plugin_get_value_for_subject(plugin, ui,
SLV2_URI,
+
"http://ll-plugins.nongnu.org/lv2/ext/gui/dev/1#binary");
if (!values || slv2_values_size(values) == 0) {
slv2_values_free(values);
@@ -606,29 +629,22 @@
return value;
}
-
-
-const char*
-slv2_gui_type_get_uri(SLV2GUIType type)
-{
- if (type == SLV2_GUI_TYPE_GTK2)
- return "http://ll-plugins.nongnu.org/lv2/ext/gtk2gui";
- else
- return NULL;
-}
+#endif
void*
-slv2_plugin_load_gui(SLV2Plugin plugin,
- SLV2Value gui)
+slv2_plugin_load_ui(SLV2Plugin plugin,
+ SLV2Value ui)
{
- SLV2Value lib_uri = slv2_plugin_get_gui_library_uri(plugin, gui);
+#if 0
+ SLV2Value lib_uri = slv2_plugin_get_ui_library_uri(plugin, ui);
if (!lib_uri)
return NULL;
//LV2UI_Handle handle =
//
+#endif
return NULL;
}
Index: src/pluginclass.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/pluginclass.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- src/pluginclass.c 8 Jun 2007 09:29:07 -0000 1.1
+++ src/pluginclass.c 7 Nov 2007 11:41:51 -0000 1.2
@@ -18,6 +18,7 @@
#define _XOPEN_SOURCE 500
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <slv2/pluginclass.h>
@@ -30,10 +31,10 @@
SLV2PluginClass plugin_class = (SLV2PluginClass)malloc(sizeof(struct
_SLV2PluginClass));
plugin_class->world = world;
if (parent_uri)
- plugin_class->parent_uri = strdup(parent_uri);
+ plugin_class->parent_uri = librdf_new_uri(world->world, (const
unsigned char*)parent_uri);
else
plugin_class->parent_uri = NULL;
- plugin_class->uri = strdup(uri);
+ plugin_class->uri = librdf_new_uri(world->world, (const unsigned
char*)uri);
plugin_class->label = strdup(label);
return plugin_class;
}
@@ -42,8 +43,8 @@
void
slv2_plugin_class_free(SLV2PluginClass plugin_class)
{
- free(plugin_class->uri);
- free(plugin_class->parent_uri);
+ librdf_free_uri(plugin_class->uri);
+ librdf_free_uri(plugin_class->parent_uri);
free(plugin_class->label);
free(plugin_class);
}
@@ -52,14 +53,18 @@
const char*
slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class)
{
- return plugin_class->parent_uri;
+ if (plugin_class->parent_uri)
+ return (const
char*)librdf_uri_as_string(plugin_class->parent_uri);
+ else
+ return NULL;
}
const char*
slv2_plugin_class_get_uri(SLV2PluginClass plugin_class)
{
- return plugin_class->uri;
+ assert(plugin_class->uri);
+ return (const char*)librdf_uri_as_string(plugin_class->uri);
}
Index: src/pluginclasses.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/pluginclasses.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/pluginclasses.c 6 Nov 2007 18:22:42 -0000 1.2
+++ src/pluginclasses.c 7 Nov 2007 11:41:51 -0000 1.3
@@ -38,6 +38,7 @@
slv2_plugin_classes_free(SLV2PluginClasses list)
{
//if (list != world->plugin_classes)
+ if (list)
raptor_free_sequence(list);
}
@@ -45,7 +46,7 @@
unsigned
slv2_plugin_classes_size(SLV2PluginClasses list)
{
- return raptor_sequence_size(list);
+ return (list ? raptor_sequence_size(list) : 0);
}
@@ -63,7 +64,7 @@
SLV2PluginClass p = raptor_sequence_get_at(list, i);
- int cmp = strcmp(slv2_plugin_class_get_uri(p), uri);
+ const int cmp = strcmp(slv2_plugin_class_get_uri(p), uri);
if (cmp == 0)
return p;
Index: src/plugininstance.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/plugininstance.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/plugininstance.c 6 Nov 2007 18:22:42 -0000 1.3
+++ src/plugininstance.c 7 Nov 2007 11:41:51 -0000 1.4
@@ -33,14 +33,14 @@
SLV2Instance
slv2_plugin_instantiate(SLV2Plugin plugin,
double sample_rate,
- const LV2_Host_Feature** host_features)
+ const LV2_Feature** features)
{
struct _Instance* result = NULL;
- bool local_host_features = (host_features == NULL);
- if (local_host_features) {
- host_features = malloc(sizeof(LV2_Host_Feature));
- host_features[0] = NULL;
+ bool local_features = (features == NULL);
+ if (local_features) {
+ features = malloc(sizeof(LV2_Feature));
+ features[0] = NULL;
}
const char* const lib_uri = slv2_plugin_get_library_uri(plugin);
@@ -81,6 +81,8 @@
break; // return NULL
} else if (!strcmp(ld->URI,
slv2_plugin_get_uri(plugin))) {
+ assert(plugin->plugin_uri);
+
printf("Found %s at index %u in:\n\t%s\n\n",
librdf_uri_as_string(plugin->plugin_uri), i, lib_path);
@@ -89,7 +91,7 @@
// Create SLV2Instance to return
result = malloc(sizeof(struct _Instance));
result->lv2_descriptor = ld;
- result->lv2_handle = ld->instantiate(ld,
sample_rate, (char*)bundle_path, host_features);
+ result->lv2_handle = ld->instantiate(ld,
sample_rate, (char*)bundle_path, features);
struct _InstanceImpl* impl =
malloc(sizeof(struct _InstanceImpl));
impl->lib_handle = lib;
result->pimpl = impl;
@@ -114,8 +116,8 @@
result->lv2_descriptor->connect_port(result->lv2_handle, i, NULL);
}
- if (local_host_features)
- free(host_features);
+ if (local_features)
+ free(features);
return result;
}
Index: src/plugins.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/plugins.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/plugins.c 6 Nov 2007 18:22:42 -0000 1.2
+++ src/plugins.c 7 Nov 2007 11:41:51 -0000 1.3
@@ -42,7 +42,7 @@
void
slv2_plugins_free(SLV2World world, SLV2Plugins list)
{
- if (list != world->plugins)
+ if (list && list != world->plugins)
raptor_free_sequence(list);
}
@@ -58,217 +58,13 @@
raptor_sequence_push(dest, slv2_plugin_duplicate(p));
}
}
-
-
-void
-slv2_plugins_load_all(SLV2Plugins list)
-{
- /* FIXME: this is much slower than it should be in many ways.. */
-
- assert(list);
-
- char* slv2_path = getenv("LV2_PATH");
-
- SLV2Plugins load_list = slv2_plugins_new();
-
- if (slv2_path) {
- slv2_plugins_load_path(load_list, slv2_path);
- } else {
- const char* const home = getenv("HOME");
- const char* const suffix = "/.lv2:/usr/local/lib/lv2:usr/lib/lv2";
- slv2_path = slv2_strjoin(home, suffix, NULL);
-
- fprintf(stderr, "$LV2_PATH is unset. Using default path %s\n",
slv2_path);
-
- /* pass 1: find all plugins */
- slv2_plugins_load_path(load_list, slv2_path);
-
- /* pass 2: find all data files for plugins */
- slv2_plugins_load_path(load_list, slv2_path);
-
- free(slv2_path);
- }
-
- /* insert only valid plugins into list */
- slv2_plugins_filter(list, load_list, slv2_plugin_verify);
- slv2_plugins_free(load_list);
-}
-
-
-/* This is the parser for manifest.ttl
- * This is called twice on each bundle in the discovery process, which is
(much) less
- * efficient than it could be.... */
-void
-slv2_plugins_load_bundle(SLV2Plugins list,
- const char* bundle_base_url)
-{
- assert(list);
-
- unsigned char* manifest_url = malloc(
- (strlen((char*)bundle_base_url) + strlen("manifest.ttl") + 2) *
sizeof(unsigned char));
- memcpy(manifest_url, bundle_base_url, strlen((char*)bundle_base_url)+1
* sizeof(unsigned char));
- if (bundle_base_url[strlen(bundle_base_url)-1] == '/')
- strcat((char*)manifest_url, "manifest.ttl");
- else
- strcat((char*)manifest_url, "/manifest.ttl");
-
- librdf_query_results *results;
- librdf_uri *base_uri = librdf_new_uri(slv2_rdf_world, manifest_url);
-
- /* Get all plugins explicitly mentioned in the manifest (discovery pass
1) */
- char* query_string =
- "PREFIX : <http://lv2plug.in/ns/lv2core#>\n\n"
- "SELECT DISTINCT ?plugin_uri FROM <>\n"
- "WHERE { ?plugin_uri a :Plugin }\n";
-
- librdf_query *rq = librdf_new_query(slv2_rdf_world, "sparql", NULL,
- (unsigned char*)query_string, base_uri);
-
-
-
- //printf("%s\n\n", query_string);
-
- results = librdf_query_execute(rq, model->model);
-
- while (!librdf_query_results_finished(results)) {
-
- librdf_node* literal =
librdf_query_results_get_binding_value(results, 0);
- assert(literal);
-
- if (!slv2_plugins_get_by_uri(list, (const
char*)librdf_node_get_literal_value(literal))) {
- /* Create a new plugin */
- struct _Plugin* new_plugin = slv2_plugin_new();
- new_plugin->plugin_uri = strdup((const
char*)librdf_node_get_literal_value(literal));
- new_plugin->bundle_url = strdup(bundle_base_url);
- raptor_sequence_push(new_plugin->data_uris,
strdup((const char*)manifest_url));
-
- raptor_sequence_push(list, new_plugin);
-
- }
-
- librdf_query_results_next(results);
- }
-
- if (results)
- librdf_free_query_results(results);
-
- librdf_free_query(rq);
-
- /* Get all data files linked to plugins (discovery pass 2) */
- query_string =
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
- "PREFIX : <http://lv2plug.in/ns/lv2core#>\n\n"
- "SELECT DISTINCT ?subject ?data_uri ?binary FROM <>\n"
- "WHERE { ?subject rdfs:seeAlso ?data_uri\n"
- "OPTIONAL { ?subject :binary ?binary } }\n";
-
- rq = librdf_new_query(slv2_rdf_world, "sparql", NULL,
- (unsigned char*)query_string, base_uri);
-
- //printf("%s\n\n", query_string);
-
- results = librdf_query_execute(rq, slv2_model);
-
- while (!librdf_query_results_finished(results)) {
-
- const char* subject = (const
char*)librdf_node_get_literal_value(
- librdf_query_results_get_binding_value(results,
0));
-
- const char* data_uri = (const
char*)librdf_node_get_literal_value(
- librdf_query_results_get_binding_value(results,
1));
-
- const char* binary = (const char*)librdf_node_get_literal_value(
- librdf_query_results_get_binding_value(results,
2));
-
- SLV2Plugin plugin = slv2_plugins_get_by_uri(list, subject);
-
- if (plugin && data_uri &&
!slv2_values_contains(plugin->data_uris, data_uri))
- raptor_sequence_push(plugin->data_uris,
strdup(data_uri));
-
- if (plugin && binary && !plugin->lib_uri)
- ((struct _Plugin*)plugin)->lib_uri = strdup(binary);
-
- librdf_query_results_next(results);
-
- }
-
- if (results)
- librdf_free_query_results(results);
-
- librdf_free_query(rq);
-
- librdf_free_uri(base_uri);
- free(manifest_url);
-}
-
-
-/* Add all the plugins found in dir to list.
- * (Private helper function, not exposed in public API)
- */
-void
-slv2_plugins_load_dir(SLV2Plugins list, const char* dir)
-{
- assert(list);
-
- DIR* pdir = opendir(dir);
- if (!pdir)
- return;
-
- struct dirent* pfile;
- while ((pfile = readdir(pdir))) {
- if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
- continue;
-
- char* bundle_path = slv2_strjoin(dir, "/", pfile->d_name, NULL);
- char* bundle_url = slv2_strjoin("file://", dir, "/",
pfile->d_name, NULL);
- DIR* bundle_dir = opendir(bundle_path);
-
- if (bundle_dir != NULL) {
- closedir(bundle_dir);
-
- slv2_plugins_load_bundle(list, bundle_url);
- //printf("Loaded bundle %s\n", bundle_url);
- }
-
- free(bundle_path);
- free(bundle_url);
- }
-
- closedir(pdir);
-}
-
-
-void
-slv2_plugins_load_path(SLV2Plugins list,
- const char* lv2_path)
-{
- assert(list);
-
- char* path = slv2_strjoin(lv2_path, ":", NULL);
- char* dir = path; // Pointer into path
-
- // Go through string replacing ':' with '\0', using the substring,
- // then replacing it with 'X' and moving on. i.e. strtok on crack.
- while (strchr(path, ':') != NULL) {
- char* delim = strchr(path, ':');
- *delim = '\0';
-
- slv2_plugins_load_dir(list, dir);
-
- *delim = 'X';
- dir = delim + 1;
- }
-
- //char* slv2_path = strdup(slv2
-
- free(path);
-}
#endif
+
unsigned
slv2_plugins_size(SLV2Plugins list)
{
- return raptor_sequence_size(list);
+ return (list ? raptor_sequence_size(list) : 0);
}
@@ -286,7 +82,7 @@
SLV2Plugin p = raptor_sequence_get_at(list, i);
- int cmp = strcmp(slv2_plugin_get_uri(p), uri);
+ const int cmp = strcmp(slv2_plugin_get_uri(p), uri);
if (cmp == 0)
return p;
Index: src/port.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/port.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/port.c 6 Nov 2007 18:22:42 -0000 1.3
+++ src/port.c 7 Nov 2007 11:41:52 -0000 1.4
@@ -124,7 +124,7 @@
#if 0
bool
-slv2_port_has_hint(SLV2Plugin p,
+slv2_port_has_property(SLV2Plugin p,
SLV2Port port,
SLV2Value hint)
{
@@ -271,11 +271,3 @@
return slv2_port_get_value(p, port, "lv2:portProperty");
}
-
-SLV2Values
-slv2_port_get_hints(SLV2Plugin p,
- SLV2Port port)
-{
- return slv2_port_get_value(p, port, "lv2:portHint");
-}
-
Index: src/query.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/query.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/query.c 6 Nov 2007 18:22:42 -0000 1.3
+++ src/query.c 7 Nov 2007 11:41:52 -0000 1.4
@@ -74,6 +74,7 @@
switch (librdf_node_get_type(node)) {
case LIBRDF_NODE_TYPE_RESOURCE:
type = SLV2_VALUE_URI;
+ assert(librdf_node_get_uri(node));
str_val = (const
char*)librdf_uri_as_string(librdf_node_get_uri(node));
break;
case LIBRDF_NODE_TYPE_LITERAL:
Index: src/slv2_internal.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/slv2_internal.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/slv2_internal.h 6 Nov 2007 18:22:42 -0000 1.2
+++ src/slv2_internal.h 7 Nov 2007 11:41:52 -0000 1.3
@@ -28,7 +28,7 @@
#include <inttypes.h>
#include <librdf.h>
#include <slv2/types.h>
-#include <slv2/lv2-gtk2gui.h>
+#include <slv2/lv2_gui.h>
@@ -98,12 +98,12 @@
};
-/* ********* GUI Instance ********* */
-struct _SLV2GUIInstanceImpl {
+/* ********* UI Instance ********* */
+struct _SLV2UIInstanceImpl {
void* lib_handle;
const LV2UI_Descriptor* lv2ui_descriptor;
LV2UI_Handle lv2ui_handle;
- void* widget;
+ LV2UI_Widget widget;
};
@@ -112,8 +112,8 @@
struct _SLV2PluginClass {
struct _SLV2World* world;
- char* parent_uri;
- char* uri;
+ librdf_uri* parent_uri;
+ librdf_uri* uri;
char* label;
};
@@ -141,24 +141,14 @@
librdf_storage* storage;
librdf_model* model;
librdf_parser* parser;
+ SLV2PluginClass lv2_plugin_class;
SLV2PluginClasses plugin_classes;
SLV2Plugins plugins;
librdf_node* lv2_specification_node;
librdf_node* lv2_plugin_node;
librdf_node* rdf_a_node;
-
- void (*rdf_lock)(void*);
- void (*rdf_unlock)(void*);
- void* rdf_lock_data;
- int rdf_lock_count;
};
-void
-slv2_world_lock_if_necessary(SLV2World world);
-
-void
-slv2_world_unlock_if_necessary(SLV2World world);
-
/** Load all bundles found in \a search_path.
*
* \param search_path A colon-delimited list of directories. These directories
@@ -180,13 +170,23 @@
slv2_world_load_file(SLV2World world, librdf_uri* file_uri);
-/* ********* GUI ********* */
+/* ********* Plugin UI ********* */
-struct _SLV2GUI {
- SLV2GUIType type;
- char* uri;
-};
+struct _SLV2UI {
+ librdf_uri* uri;
+ librdf_uri* bundle_uri;
+ librdf_uri* binary_uri;
+ SLV2Values types;
+};
+
+SLV2UIs slv2_uis_new();
+SLV2UI
+slv2_ui_new(SLV2World world,
+ librdf_uri* uri,
+ librdf_uri* type_uri,
+ librdf_uri* binary_uri);
+void slv2_ui_free(SLV2UI ui);
/* ********* Value ********* */
@@ -197,7 +197,6 @@
SLV2_VALUE_STRING,
SLV2_VALUE_INT,
SLV2_VALUE_FLOAT,
- SLV2_VALUE_GUI
} SLV2ValueType;
struct _SLV2Value {
@@ -206,7 +205,6 @@
union {
int int_val;
float float_val;
- SLV2GUIType gui_type_val;
} val;
};
Index: src/value.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/value.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/value.c 6 Nov 2007 18:22:42 -0000 1.2
+++ src/value.c 7 Nov 2007 11:41:52 -0000 1.3
@@ -50,6 +50,14 @@
}
+/*
+SLV2Value
+slv2_value_new_uri(const char* uri)
+{
+ return slv2_value_new(SLV2_VALUE_URI, uri);
+}
+*/
+
SLV2Value
slv2_value_duplicate(SLV2Value val)
{
@@ -90,7 +98,6 @@
char* result = NULL;
switch (value->type) {
- case SLV2_VALUE_GUI:
case SLV2_VALUE_URI:
len = strlen(value->str_val) + 3;
result = calloc(len, sizeof(char));
@@ -119,14 +126,14 @@
bool
slv2_value_is_uri(SLV2Value value)
{
- return (value->type == SLV2_VALUE_URI || value->type == SLV2_VALUE_GUI);
+ return (value->type == SLV2_VALUE_URI);
}
const char*
slv2_value_as_uri(SLV2Value value)
{
- assert(slv2_value_is_uri(value) || slv2_value_is_gui(value));
+ assert(slv2_value_is_uri(value));
return value->str_val;
}
@@ -185,18 +192,3 @@
return (float)value->val.int_val;
}
-
-bool
-slv2_value_is_gui(SLV2Value value)
-{
- return (value->type == SLV2_VALUE_GUI);
-}
-
-
-SLV2GUIType
-slv2_value_as_gui_type(SLV2Value value)
-{
- assert(slv2_value_is_gui(value));
- return value->val.gui_type_val;
-}
-
Index: src/values.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/values.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- src/values.c 8 Jun 2007 09:29:08 -0000 1.1
+++ src/values.c 7 Nov 2007 11:41:53 -0000 1.2
@@ -34,6 +34,7 @@
void
slv2_values_free(SLV2Values list)
{
+ if (list)
raptor_free_sequence(list);
}
@@ -41,7 +42,7 @@
unsigned
slv2_values_size(SLV2Values list)
{
- return raptor_sequence_size(list);
+ return (list ? raptor_sequence_size(list) : 0);
}
Index: src/world.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/world.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- src/world.c 6 Nov 2007 18:22:42 -0000 1.4
+++ src/world.c 7 Nov 2007 11:41:53 -0000 1.5
@@ -56,12 +56,10 @@
if (!world->parser)
goto fail;
- world->plugin_classes = slv2_plugin_classes_new();
-
- // Add the ever-present lv2:Plugin to classes
static const char* lv2_plugin_uri =
"http://lv2plug.in/ns/lv2core#Plugin";
- raptor_sequence_push(world->plugin_classes, slv2_plugin_class_new(
- world, NULL, lv2_plugin_uri, "Plugin"));
+ world->lv2_plugin_class = slv2_plugin_class_new(world, NULL,
lv2_plugin_uri, "Plugin");
+
+ world->plugin_classes = slv2_plugin_classes_new();
world->plugins = slv2_plugins_new();
@@ -74,11 +72,6 @@
world->rdf_a_node = librdf_new_node_from_uri_string(world->world,
(unsigned
char*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
- world->rdf_lock = NULL;
- world->rdf_unlock = NULL;
- world->rdf_lock_data = NULL;
- world->rdf_lock_count = 0;
-
return world;
fail:
@@ -111,12 +104,10 @@
if (!world->parser)
goto fail;
- world->plugin_classes = slv2_plugin_classes_new();
-
- // Add the ever-present lv2:Plugin to classes
static const char* lv2_plugin_uri =
"http://lv2plug.in/ns/lv2core#Plugin";
- raptor_sequence_push(world->plugin_classes, slv2_plugin_class_new(
- world, NULL, lv2_plugin_uri, "Plugin"));
+ world->lv2_plugin_class = slv2_plugin_class_new(world, NULL,
lv2_plugin_uri, "Plugin");
+
+ world->plugin_classes = slv2_plugin_classes_new();
world->plugins = slv2_plugins_new();
@@ -129,11 +120,6 @@
world->rdf_a_node = librdf_new_node_from_uri_string(rdf_world,
(unsigned
char*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
- world->rdf_lock = NULL;
- world->rdf_unlock = NULL;
- world->rdf_lock_data = NULL;
- world->rdf_lock_count = 0;
-
return world;
fail:
@@ -145,9 +131,6 @@
void
slv2_world_free(SLV2World world)
{
- if (world->rdf_lock)
- world->rdf_lock(world->rdf_lock_data);
-
librdf_free_node(world->lv2_specification_node);
librdf_free_node(world->lv2_plugin_node);
librdf_free_node(world->rdf_a_node);
@@ -174,63 +157,15 @@
world->world = NULL;
- if (world->rdf_unlock)
- world->rdf_unlock(world->rdf_lock_data);
-
free(world);
}
-void
-slv2_world_set_rdf_lock_function(SLV2World world, void (*lock)(void*), void*
data)
-{
- world->rdf_lock = lock;
- world->rdf_lock_data = data;
-}
-
-
-void
-slv2_world_set_rdf_unlock_function(SLV2World world, void (*unlock)(void*))
-{
- world->rdf_unlock = unlock;
-}
-
-
-void
-slv2_world_lock_if_necessary(SLV2World world)
-{
- if (world->rdf_lock) {
-
- if (world->rdf_lock_count == 0)
- world->rdf_lock(world->rdf_lock_data);
-
- ++world->rdf_lock_count;
-
- }
-}
-
-
-void
-slv2_world_unlock_if_necessary(SLV2World world)
-{
- if (world->rdf_lock && world->rdf_lock_count > 0) {
-
- if (world->rdf_lock_count == 1 && world->rdf_unlock)
- world->rdf_unlock(world->rdf_lock_data);
-
- world->rdf_lock_count = 0;
-
- }
-}
-
-
/** Load the entire contents of a file into the world model.
*/
void
slv2_world_load_file(SLV2World world, librdf_uri* file_uri)
{
- slv2_world_lock_if_necessary(world);
-
librdf_storage* storage = librdf_new_storage(world->world,
"memory", NULL, NULL);
librdf_model* model = librdf_new_model(world->world,
@@ -244,8 +179,6 @@
librdf_free_model(model);
librdf_free_storage(storage);
-
- slv2_world_unlock_if_necessary(world);
}
@@ -253,8 +186,6 @@
void
slv2_world_load_bundle(SLV2World world, const char* bundle_uri_str)
{
- slv2_world_lock_if_necessary(world);
-
librdf_uri* bundle_uri = librdf_new_uri(world->world,
(const unsigned char*)bundle_uri_str);
@@ -301,6 +232,7 @@
}
librdf_free_stream(results);
+ free(q);
/* Query statement: ?specification a lv2:Specification */
q = librdf_new_statement_from_nodes(world->world,
@@ -334,6 +266,7 @@
}
librdf_free_stream(results);
+ free(q);
/* Join the temporary model to the main model */
librdf_stream* manifest_stream = librdf_model_as_stream(manifest_model);
@@ -341,12 +274,9 @@
librdf_free_stream(manifest_stream);
librdf_free_model(manifest_model);
- free(q);
librdf_free_storage(manifest_storage);
librdf_free_uri(manifest_uri);
librdf_free_uri(bundle_uri);
-
- slv2_world_unlock_if_necessary(world);
}
@@ -405,18 +335,6 @@
}
-/** comparator for sorting */
-/*int
-slv2_plugin_compare_by_uri(const void* a, const void* b)
-{
- SLV2Plugin plugin_a = *(SLV2Plugin*)a;
- SLV2Plugin plugin_b = *(SLV2Plugin*)b;
-
- return strcmp((const char*)librdf_uri_as_string(plugin_a->plugin_uri),
- (const char*)librdf_uri_as_string(plugin_b->plugin_uri));
-}
-*/
-
void
slv2_world_load_specifications(SLV2World world)
{
@@ -480,8 +398,10 @@
librdf_node* label_node =
librdf_query_results_get_binding_value(results, 2);
const char* label = (const
char*)librdf_node_get_literal_value(label_node);
+ assert(class_uri);
+
SLV2PluginClass plugin_class = slv2_plugin_class_new(world,
- (const char*)librdf_uri_as_string(parent_uri),
+ parent_uri ? (const
char*)librdf_uri_as_string(parent_uri) : NULL,
(const char*)librdf_uri_as_string(class_uri),
label);
raptor_sequence_push(world->plugin_classes, plugin_class);
@@ -572,6 +492,9 @@
librdf_node* binary_node =
librdf_query_results_get_binding_value(results, 3);
librdf_uri* binary_uri = librdf_node_get_uri(binary_node);
+ assert(plugin_uri);
+ assert(data_uri);
+
SLV2Plugin plugin = slv2_plugins_get_by_uri(world->plugins,
(const char*)librdf_uri_as_string(plugin_uri));
@@ -595,9 +518,6 @@
librdf_query_results_next(results);
}
- // 'ORDER BY ?plugin' guarantees this
- //raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri);
-
if (results)
librdf_free_query_results(results);
@@ -629,7 +549,7 @@
SLV2PluginClass
slv2_world_get_plugin_class(SLV2World world)
{
- return raptor_sequence_get_at(world->plugin_classes, 0);
+ return world->lv2_plugin_class;
}
Index: slv2/lv2_gui.h
===================================================================
RCS file: slv2/lv2_gui.h
diff -N slv2/lv2_gui.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ slv2/lv2_gui.h 7 Nov 2007 11:41:50 -0000 1.1
@@ -0,0 +1,346 @@
+/************************************************************************
+ *
+ * In-process UI extension for LV2
+ *
+ * Copyright (C) 2006-2007 Lars Luthman <address@hidden>
+ *
+ * Based on lv2.h, which is:
+ *
+ * Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
+ * Stefan Westerfeld
+ * Copyright (C) 2006 Steve Harris, Dave Robillard.
+ *
+ * This header is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * This header 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA.
+ *
+ ***********************************************************************/
+
+/** @file
+ This extension defines an interface that can be used in LV2 plugins and
+ hosts to create GUIs for plugins. The GUIs are plugins that reside in
+ shared object files in an LV2 bundle and be referenced in the RDF file
+ using the triples (Turtle shown)
+<pre>
+ @prefix guiext: <http://ll-plugins.nongnu.org/lv2/ext/ipgui/1#> .
+ <http://my.plugin> guiext:gui <http://my.plugingui> .
+ <http://my.plugingui> guiext:binary <mygui.so> .
+</pre>
+ where <http://my.plugin> is the URI of the plugin, <http://my.plugingui> is
+ the URI of the plugin GUI and <mygui.so> is the relative URI to the shared
+ object file. While it is possible to have the plugin GUI and the plugin in
+ the same shared object file it is probably a good idea to keep them
+ separate so that hosts that don't want GUIs don't have to load the GUI
code.
+
+ (Note: the prefix above is used throughout this file for the same URI)
+
+ It's entirely possible to have multiple GUIs for the same plugin, or to
have
+ the GUI for a plugin in a different bundle from the actual plugin - this
+ way people other than the plugin author can write plugin GUIs independently
+ without editing the original plugin bundle. If a GUI is in a separate
bundle
+ the first triple above should be in that bundle's manifest.ttl file so that
+ hosts can find the GUI when scanning the manifests.
+
+ Note that the process that loads the shared object file containing the GUI
+ code and the process that loads the shared object file containing the
+ actual plugin implementation does not have to be the same. There are many
+ valid reasons for having the plugin and the GUI in different processes, or
+ even on different machines. This means that you can _not_ use singletons
+ and global variables and expect them to refer to the same objects in the
+ GUI and the actual plugin. The function callback interface defined in this
+ header is all you can expect to work.
+
+ Since the LV2 specification itself allows for extensions that may add
+ new types of data and configuration parameters that plugin authors may
+ want to control with a GUI, this extension allows for meta-extensions that
+ can extend the interface between the GUI and the host. See the
+ instantiate() and extension_data() callback pointers for more details.
+
+ Note that this extension is NOT a Host Feature. There is no way for a
plugin
+ to know whether the host that loads it supports GUIs or not, and the plugin
+ must ALWAYS work without the GUI (although it may be rather useless unless
+ it has been configured using the GUI in a previous session).
+
+ GUIs written to this specification do not need to be threadsafe - the
+ functions defined below may only be called in the same thread as the UI
+ main loop is running in.
+*/
+
+#ifndef LV2_GUI_H
+#define LV2_GUI_H
+
+#include "lv2.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** A pointer to some widget.
+ * The actual type of the widget is defined by the type URI of the GUI.
+ * e.g. if "<http://example.org/somegui> a guiext:GtkGUI", this is a pointer
+ * to a GtkWidget. All the functionality provided by this extension is
+ * toolkit independent, the host only needs to pass the necessary callbacks
+ * and display the widget, if possible. Plugins may have several GUIs,
+ * in various toolkits.
+ */
+typedef void* LV2UI_Widget;
+
+
+/** This handle indicates a particular instance of a GUI.
+ It is valid to compare this to NULL (0 for C++) but otherwise the
+ host MUST not attempt to interpret it. The GUI plugin may use it to
+ reference internal instance data. */
+typedef void* LV2UI_Handle;
+
+
+/** This handle indicates a particular plugin instance, provided by the host.
+ It is valid to compare this to NULL (0 for C++) but otherwise the
+ GUI plugin MUST not attempt to interpret it. The host may use it to
+ reference internal instance data. */
+typedef void* LV2UI_Controller;
+
+
+/** This is the type of the host-provided function that the GUI can use to
+ send data to a plugin's input ports. The @c buffer parameter must point
+ to a block of data, @c buffer_size bytes large. The contents of this buffer
+ will depend on the class of the port it's being sent to. For ports of the
+ class lv2:ControlPort, buffer_size should be sizeof(float) and the buffer
+ contents should be a float value. For ports of the class llext:MidiPort the
+ buffer should contain the data bytes of a single MIDI event, and
buffer_size
+ should be the number of bytes in the event. No other port classes are
+ allowed, unless the format and the meaning of the buffer passed to this
+ function is defined in the extension that specifies that class or in a
+ separate GUI host feature extension that is required by this GUI.
+
+ The GUI is responsible for allocating the buffer and deallocating it after
+ the call. There are no timing guarantees at all for this function, although
+ the faster the host can get the data to the plugin port the better. A
+ function pointer of this type will be provided to the GUI by the host in
+ the instantiate() function. */
+typedef void (*LV2UI_Write_Function)(LV2UI_Controller controller,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ const void* buffer);
+
+/** This is the type of the host-provided function that the GUI can use to
+ send arbitrary commands to the plugin. The parameters after the first one
+ should be const char* variables, terminated by a NULL pointer, and will be
+ interpreted as a command with arguments. A function of this type will be
+ provided to the GUI by the host in the instantiate() function. */
+typedef void (*LV2UI_Command_Function)(LV2UI_Controller controller,
+ uint32_t argc,
+ const char* const* argv);
+
+/** This is the type of the host-provided function that the GUI can use to
+ request a program change in the host. A function of this type will be
+ provided to the GUI by the host in the instantiate() function. Calling
+ this function does not guarantee that the program will change, it is just
+ a request. If the program does change, the GUI's current_program_changed()
+ callback will be called, either before or after this function returns
+ depending on whether the GUI host <-> plugin instance communication is
+ synchronous or asynchronous. */
+typedef void (*LV2UI_Program_Change_Function)(LV2UI_Controller controller,
+ unsigned char program);
+
+/** This is the type of the host-provided function that the GUI can use to
+ request that the current state of the plugin is saved to a program.
+ A function of this type will be provided to the GUI by the host in the
+ instantiate function. Calling this function does not guarantee that the
+ state will be saved, it is just a request. If the state is saved, the
+ GUI's program_added() callback will be called, either before or after
+ this function returns depending on whether the GUI host <-> plugin
+ instance communication is synchronous or asynchronous. */
+typedef void (*LV2UI_Program_Save_Function)(LV2UI_Controller controller,
+ unsigned char program,
+ const char* name);
+
+
+/** */
+typedef struct _LV2UI_Descriptor {
+
+ /** The URI for this GUI (not for the plugin it controls). */
+ const char* URI;
+
+ /** Create a new GUI object and return a handle to it. This function works
+ similarly to the instantiate() member in LV2_Descriptor, with the
+ additions that the URI for the plugin that this GUI is for is passed
+ as a parameter, a function pointer and a controller handle are passed to
+ allow the plugin to write to input ports in the plugin (write_function
+ and controller) and a pointer to a LV2_Widget is passed, which the GUI
+ plugin should set to point to a newly created widget which will be the
+ GUI for the plugin. This widget may only be destroyed by cleanup().
+
+ The features array works like the one in the instantiate() member
+ in LV2_Descriptor, except that the URIs should be denoted with the
triples
+ <pre>
+ <http://my.plugingui> guiext:optionalFeature <http://my.guifeature>
+ </pre>
+ or
+ <pre>
+ <http://my.plugingui> guiext:requiredFeature <http://my.guifeature>
+ </pre>
+ in the RDF file, instead of the lv2:optionalFeature or
lv2:requiredFeature
+ that is used by host features. These features are associated with the
GUI,
+ not with the plugin - they are not actually LV2 Host Features, they just
+ use the same data structure.
+
+ The same rules apply for these features as for normal host features -
+ if a feature is listed as required in the RDF file and the host does not
+ support it, it must not load the GUI.
+ */
+ LV2UI_Handle (*instantiate)(const struct _LV2UI_Descriptor* descriptor,
+ const char* plugin_uri,
+ const char* bundle_path,
+ LV2UI_Write_Function write_function,
+ LV2UI_Command_Function command_function,
+ LV2UI_Program_Change_Function program_function,
+ LV2UI_Program_Save_Function save_function,
+ LV2UI_Controller controller,
+ LV2UI_Widget* widget,
+ const LV2_Feature* const* features);
+
+
+ /** Destroy the GUI object and the associated widget.
+ */
+ void (*cleanup)(LV2UI_Handle gui);
+
+ /** Tell the GUI that something interesting has happened at a plugin port.
+ For control ports this would be when the value in the buffer has changed,
+ for message-based port classes like MIDI or OSC it would be when a
+ message has arrived in the buffer. For other port classes it is not
+ defined when this function is called, unless it is specified in the
+ definition of that port class extension. For control ports the default
+ setting is to call this function whenever an input control port value
+ has changed but not when any output control port value has changed, for
+ all other port classes the default setting is to never call this
function.
+
+ However, the default setting can be modified by using the following
+ URIs:
+ <pre>
+ guiext:portNotification
+ guiext:noPortNotification
+ guiext:plugin
+ guiext:portIndex
+ </pre>
+ For example, if you want the GUI with uri
+ <code><http://my.plugingui></code> for the plugin with URI
+ <code><http://my.plugin></code> to get notified when the value of the
+ output control port with index 4 changes, you would use the following
+ in the RDF for your GUI:
+ <pre>
+ <http://my.plugingui> guiext:portNotification [ guiext:plugin
<http://my.plugin> ;
+ guiext:portIndex 4 ] .
+ </pre>
+ and similarly with <code>guiext:noPortNotification</code> if you wanted
to
+ prevent notifications for a port for which it would be on by default
+ otherwise.
+
+ The @c buffer is only valid during the time of this function call, so if
+ the GUI wants to keep it for later use it has to copy the contents to an
+ internal buffer.
+
+ The buffer is subject to the same rules as the ones for the
+ LV2_Write_Function type. This means that a plugin GUI may not request a
+ portNotification for a port that has a class other than lv2:ControlPort
+ or llext:MidiPort unless the buffer format and meaning is specified in
+ the extension that defines that port class, or in a separate GUI host
+ feature extension that is required by the GUI. Any GUI that does that
+ should be considered broken and the host should not use it.
+
+ This member may be set to NULL if the GUI is not interested in any
+ port events.
+ */
+ void (*port_event)(LV2UI_Handle gui,
+ uint32_t port,
+ uint32_t buffer_size,
+ const void* buffer);
+
+ /** This function is called when the plugin instance wants to send feedback
+ to the GUI. It may be called in response to a command function call,
+ either before or after the command function has returned (depending on
+ whether the GUI host <-> plugin instance communication is synchronous or
+ asynchronous). */
+ void (*feedback)(LV2UI_Handle gui,
+ uint32_t argc,
+ const char* const* argv);
+
+ /** This function is called when the host adds a new program to its program
+ list, or changes the name of an old one. It may be set to NULL if the
+ GUI isn't interested in displaying program information. */
+ void (*program_added)(LV2UI_Handle gui,
+ unsigned char number,
+ const char* name);
+
+ /** This function is called when the host removes a program from its program
+ list. It may be set to NULL if the GUI isn't interested in displaying
+ program information. */
+ void (*program_removed)(LV2UI_Handle gui,
+ unsigned char number);
+
+ /** This function is called when the host clears its program list. It may be
+ set to NULL if the GUI isn't interested in displaying program
+ information. */
+ void (*programs_cleared)(LV2UI_Handle gui);
+
+ /** This function is called when the host changes the current program. It may
+ be set to NULL if the GUI isn't interested in displaying program
+ information. */
+ void (*current_program_changed)(LV2UI_Handle gui,
+ unsigned char number);
+
+ /** Returns a data structure associated with an extension URI, for example
+ a struct containing additional function pointers. Avoid returning
+ function pointers directly since standard C++ has no valid way of
+ casting a void* to a function pointer. This member may be set to NULL
+ if the GUI is not interested in supporting any extensions. This is
similar
+ to the extension_data() member in LV2_Descriptor.
+ */
+ void* (*extension_data)(LV2UI_Handle gui,
+ const char* uri);
+
+} LV2UI_Descriptor;
+
+
+
+/** A plugin programmer must include a function called "lv2ui_descriptor"
+ with the following function prototype within the shared object
+ file. This function will have C-style linkage (if you are using
+ C++ this is taken care of by the 'extern "C"' clause at the top of
+ the file). This function will be accessed by the GUI host using the
+ @c dlsym() function and called to get a LV2UI_UIDescriptor for the
+ wanted plugin.
+
+ Just like lv2_descriptor(), this function takes an index parameter. The
+ index should only be used for enumeration and not as any sort of ID number
-
+ the host should just iterate from 0 and upwards until the function returns
+ NULL, or a descriptor with an URI matching the one the host is looking for
+ is returned.
+*/
+const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index);
+
+
+/** This is the type of the lv2ui_descriptor() function. */
+typedef const LV2UI_Descriptor* (*LV2UI_DescriptorFunction)(uint32_t index);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* LV2_GUI_H */
+
Index: slv2/pluginui.h
===================================================================
RCS file: slv2/pluginui.h
diff -N slv2/pluginui.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ slv2/pluginui.h 7 Nov 2007 11:41:50 -0000 1.1
@@ -0,0 +1,89 @@
+/* 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_PLUGIN_UI_H__
+#define __SLV2_PLUGIN_UI_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \addtogroup data
+ * @{
+ */
+
+
+/** Get the URI of a Plugin UI.
+ *
+ * \param ui The Plugin UI
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_ui_get_uri(SLV2UI ui);
+
+
+/** Get the types (URIs of RDF classes) of a Plugin UI.
+ *
+ * \param ui The Plugin UI
+ *
+ * Time = O(1)
+ */
+SLV2Values
+slv2_ui_get_types(SLV2UI ui);
+
+
+/** Check whether a plugin UI is a given type.
+ *
+ * \param ui The Plugin UI
+ * \param type_uri The URI of the LV2 UI type to check this UI against
+ *
+ * Time = O(1)
+ */
+bool
+slv2_ui_is_type(SLV2UI ui, const char* type_uri);
+
+
+/** Get the URI for a Plugin UI's bundle.
+ *
+ * \param ui The Plugin UI
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_ui_get_bundle_uri(SLV2UI ui);
+
+
+/** Get the URI for a Plugin UI's shared library.
+ *
+ * \param ui The Plugin UI
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_ui_get_binary_uri(SLV2UI ui);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_PLUGIN_UI_H__ */
+
Index: slv2/pluginuiinstance.h
===================================================================
RCS file: slv2/pluginuiinstance.h
diff -N slv2/pluginuiinstance.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ slv2/pluginuiinstance.h 7 Nov 2007 11:41:50 -0000 1.1
@@ -0,0 +1,121 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ * Author: Lars Luthman
+ *
+ * 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_PLUGINUIINSTANCE_H__
+#define __SLV2_PLUGINUIINSTANCE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <assert.h>
+#include <slv2/lv2_gui.h>
+#include <slv2/plugin.h>
+
+/** \addtogroup lib
+ * @{
+ */
+
+
+typedef struct _SLV2UIInstanceImpl* SLV2UIInstanceImpl;
+
+
+
+/** Instance of a plugin UI.
+ *
+ * All details are in hidden in the pimpl member to avoid making the
+ * implementation a part of the ABI.
+ */
+typedef struct _SLV2UIInstance {
+ SLV2UIInstanceImpl pimpl; ///< Private implementation
+}* SLV2UIInstance;
+
+
+
+/** Instantiate a plugin UI.
+ *
+ * The returned object represents shared library objects loaded into memory,
+ * it must be cleaned up with slv2_ui_instance_free when no longer
+ * needed.
+ *
+ * \a plugin is not modified or directly referenced by the returned object
+ * (instances store only a copy of the plugin's URI).
+ *
+ * \a host_features NULL-terminated array of features the host supports.
+ * NULL may be passed if the host supports no additional features (unlike
+ * the LV2 specification - SLV2 takes care of it).
+ *
+ * \return NULL if instantiation failed.
+ */
+SLV2UIInstance
+slv2_ui_instantiate(SLV2Plugin plugin,
+ SLV2UI ui,
+ LV2UI_Write_Function write_function,
+ LV2UI_Command_Function command_function,
+ LV2UI_Program_Change_Function program_function,
+ LV2UI_Program_Save_Function save_function,
+ LV2UI_Controller controller,
+ const LV2_Feature* const* features);
+
+
+/** Free a plugin UI instance.
+ *
+ * \a instance is invalid after this call.
+ */
+void
+slv2_ui_instance_free(SLV2UIInstance instance);
+
+
+/** Get the widget for the UI instance.
+ */
+LV2UI_Widget
+slv2_ui_instance_get_widget(SLV2UIInstance instance);
+
+
+/** Get the LV2UI_Descriptor of the plugin UI instance.
+ *
+ * Normally hosts should not need to access the LV2UI_Descriptor directly,
+ * use the slv2_ui_instance_* functions.
+ *
+ * The returned descriptor is shared and must not be deleted.
+ */
+const LV2UI_Descriptor*
+slv2_ui_instance_get_descriptor(SLV2UIInstance instance);
+
+
+/** Get the LV2UI_Handle of the plugin UI instance.
+ *
+ * Normally hosts should not need to access the LV2UI_Handle directly,
+ * use the slv2_ui_instance_* functions.
+ *
+ * The returned handle is shared and must not be deleted.
+ */
+LV2UI_Handle
+slv2_ui_instance_get_handle(SLV2UIInstance instance);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __SLV2_PLUGINUIINSTANCE_H__ */
+
Index: slv2/pluginuis.h
===================================================================
RCS file: slv2/pluginuis.h
diff -N slv2/pluginuis.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ slv2/pluginuis.h 7 Nov 2007 11:41:51 -0000 1.1
@@ -0,0 +1,87 @@
+/* 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_PLUGIN_UIS_H__
+#define __SLV2_PLUGIN_UIS_H__
+
+#include <slv2/types.h>
+#include <slv2/plugin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \addtogroup collections
+ *
+ * @{
+ */
+
+
+/** Free a plugin list.
+ *
+ * Freeing a plugin list does not destroy the plugins it contains (plugins
+ * are owned by the world). \a list is invalid after this call.
+ */
+void
+slv2_uis_free(SLV2UIs list);
+
+
+/** Get the number of plugins in the list.
+ */
+unsigned
+slv2_uis_size(SLV2UIs list);
+
+
+/** Get a plugin from the list by URI.
+ *
+ * Return value is shared (stored in \a list) and must not be freed or
+ * modified by the caller in any way.
+ *
+ * Time = O(log2(n))
+ *
+ * \return NULL if plugin with \a url not found in \a list.
+ */
+SLV2UI
+slv2_uis_get_by_uri(SLV2UIs list,
+ const char* uri);
+
+
+/** Get a plugin from the list by index.
+ *
+ * \a index has no significance other than as an index into this list.
+ * Any \a index not less than slv2_list_get_length(list) will return NULL,
+ * so all plugins in a list can be enumerated by repeated calls
+ * to this function starting with \a index = 0.
+ *
+ * Time = O(1)
+ *
+ * \return NULL if \a index out of range.
+ */
+SLV2UI
+slv2_uis_get_at(SLV2UIs list,
+ unsigned index);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_PLUGIN_UIS_H__ */
+
Index: src/pluginui.c
===================================================================
RCS file: src/pluginui.c
diff -N src/pluginui.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/pluginui.c 7 Nov 2007 11:41:52 -0000 1.1
@@ -0,0 +1,121 @@
+/* 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 <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <slv2/values.h>
+#include "slv2_internal.h"
+
+
+/* private */
+SLV2UI
+slv2_ui_new(SLV2World world,
+ librdf_uri* uri,
+ librdf_uri* type_uri,
+ librdf_uri* binary_uri)
+{
+ assert(uri);
+ assert(type_uri);
+ assert(binary_uri);
+
+ struct _SLV2UI* ui = malloc(sizeof(struct _SLV2UI));
+ ui->uri = librdf_new_uri_from_uri(uri);
+ ui->binary_uri = librdf_new_uri_from_uri(binary_uri);
+
+ assert(ui->binary_uri);
+
+ // FIXME: kludge
+ char* bundle = strdup((const
char*)librdf_uri_as_string(ui->binary_uri));
+ char* last_slash = strrchr(bundle, '/') + 1;
+ *last_slash = '\0';
+ ui->bundle_uri = librdf_new_uri(world->world, (const unsigned
char*)bundle);
+ free(bundle);
+
+ ui->types = slv2_values_new();
+ raptor_sequence_push(ui->types, slv2_value_new(SLV2_VALUE_URI,
+ (const char*)librdf_uri_as_string(type_uri)));
+
+ return ui;
+}
+
+
+/* private */
+void
+slv2_ui_free(SLV2UI ui)
+{
+ librdf_free_uri(ui->uri);
+ ui->uri = NULL;
+
+ librdf_free_uri(ui->bundle_uri);
+ ui->bundle_uri = NULL;
+
+ librdf_free_uri(ui->binary_uri);
+ ui->binary_uri = NULL;
+
+ slv2_values_free(ui->types);
+
+ free(ui);
+}
+
+
+const char*
+slv2_ui_get_uri(SLV2UI ui)
+{
+ assert(ui);
+ assert(ui->uri);
+ return (const char*)librdf_uri_as_string(ui->uri);
+}
+
+
+SLV2Values
+slv2_ui_get_types(SLV2UI ui)
+{
+ return ui->types;
+}
+
+
+bool
+slv2_ui_is_type(SLV2UI ui, const char* type_uri)
+{
+ SLV2Value type = slv2_value_new(SLV2_VALUE_URI, type_uri);
+ bool ret = slv2_values_contains(ui->types, type);
+ slv2_value_free(type);
+ return ret;
+}
+
+
+const char*
+slv2_ui_get_bundle_uri(SLV2UI ui)
+{
+ assert(ui);
+ assert(ui->bundle_uri);
+ return (const char*)librdf_uri_as_string(ui->bundle_uri);
+}
+
+
+const char*
+slv2_ui_get_binary_uri(SLV2UI ui)
+{
+ assert(ui);
+ assert(ui->binary_uri);
+ return (const char*)librdf_uri_as_string(ui->binary_uri);
+}
+
Index: src/pluginuiinstance.c
===================================================================
RCS file: src/pluginuiinstance.c
diff -N src/pluginuiinstance.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/pluginuiinstance.c 7 Nov 2007 11:41:52 -0000 1.1
@@ -0,0 +1,171 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ * Author: Lars Luthman
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <dlfcn.h>
+#include <slv2/types.h>
+#include <slv2/plugin.h>
+#include <slv2/pluginui.h>
+#include <slv2/pluginuiinstance.h>
+#include <slv2/util.h>
+#include "slv2_internal.h"
+
+
+SLV2UIInstance
+slv2_ui_instantiate(SLV2Plugin plugin,
+ SLV2UI ui,
+ LV2UI_Write_Function write_function,
+ LV2UI_Command_Function command_function,
+ LV2UI_Program_Change_Function program_function,
+ LV2UI_Program_Save_Function save_function,
+ LV2UI_Controller controller,
+ const LV2_Feature* const* features)
+{
+ struct _SLV2UIInstance* result = NULL;
+
+ bool local_features = (features == NULL);
+ if (local_features) {
+ features = malloc(sizeof(LV2_Feature));
+ ((LV2_Feature**)features)[0] = NULL;
+ }
+
+ const char* const lib_uri = slv2_ui_get_binary_uri(ui);
+ const char* const lib_path = slv2_uri_to_path(lib_uri);
+
+ if (!lib_path)
+ return NULL;
+
+ dlerror();
+ void* lib = dlopen(lib_path, RTLD_NOW);
+ if (!lib) {
+ fprintf(stderr, "Unable to open UI library %s (%s)\n",
lib_path, dlerror());
+ return NULL;
+ }
+
+ LV2UI_DescriptorFunction df = dlsym(lib, "lv2ui_descriptor");
+
+ if (!df) {
+ fprintf(stderr, "Could not find symbol 'lv2ui_descriptor', "
+ "%s is not a LV2 plugin UI.\n", lib_path);
+ dlclose(lib);
+ return NULL;
+ } else {
+
+ const char* bundle_path =
slv2_uri_to_path(slv2_ui_get_bundle_uri(ui));
+
+ for (uint32_t i=0; 1; ++i) {
+
+ const LV2UI_Descriptor* ld = df(i);
+
+ if (!ld) {
+ fprintf(stderr, "Did not find UI %s in %s\n",
+ slv2_ui_get_uri(ui), lib_path);
+ dlclose(lib);
+ break; // return NULL
+ } else if (!strcmp(ld->URI, slv2_ui_get_uri(ui))) {
+
+
+ assert(plugin->plugin_uri);
+
+ printf("Found UI %s at index %u in:\n\t%s\n\n",
+
librdf_uri_as_string(plugin->plugin_uri), i, lib_path);
+
+ assert(ld->instantiate);
+
+ // Create SLV2UIInstance to return
+ result = malloc(sizeof(struct _SLV2UIInstance));
+ struct _SLV2UIInstanceImpl* impl =
malloc(sizeof(struct _SLV2UIInstanceImpl));
+ impl->lv2ui_descriptor = ld;
+ impl->lv2ui_handle = ld->instantiate(ld,
+ slv2_plugin_get_uri(plugin),
+ (char*)bundle_path,
+ write_function,
+ command_function,
+ program_function,
+ save_function,
+ controller,
+ &impl->widget,
+ features);
+ impl->lib_handle = lib;
+ result->pimpl = impl;
+ break;
+ }
+ }
+ }
+
+ assert(result);
+ assert(slv2_plugin_get_num_ports(plugin) > 0);
+
+ // Failed to instantiate
+ if (result->pimpl->lv2ui_handle == NULL) {
+ //printf("Failed to instantiate %s\n", plugin->plugin_uri);
+ free(result);
+ return NULL;
+ }
+
+ // Failed to create a widget, but still got a handle - this means that
+ // the plugin is buggy
+ if (result->pimpl->widget == NULL) {
+ slv2_ui_instance_free(result);
+ return NULL;
+ }
+
+ if (local_features)
+ free((LV2_Feature**)features);
+
+ return result;
+}
+
+
+void
+slv2_ui_instance_free(SLV2UIInstance instance)
+{
+ struct _SLV2UIInstance* i = (struct _SLV2UIInstance*)instance;
+ i->pimpl->lv2ui_descriptor->cleanup(i->pimpl->lv2ui_handle);
+ i->pimpl->lv2ui_descriptor = NULL;
+ dlclose(i->pimpl->lib_handle);
+ i->pimpl->lib_handle = NULL;
+ free(i->pimpl);
+ i->pimpl = NULL;
+ free(i);
+}
+
+
+LV2UI_Widget
+slv2_ui_instance_get_widget(SLV2UIInstance instance) {
+ return instance->pimpl->widget;
+}
+
+
+const LV2UI_Descriptor*
+slv2_ui_instance_get_descriptor(SLV2UIInstance instance) {
+ return instance->pimpl->lv2ui_descriptor;
+}
+
+
+LV2UI_Handle
+slv2_ui_instance_get_handle(SLV2UIInstance instance) {
+ return instance->pimpl->lv2ui_handle;
+}
+
Index: src/pluginuis.c
===================================================================
RCS file: src/pluginuis.c
diff -N src/pluginuis.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/pluginuis.c 7 Nov 2007 11:41:52 -0000 1.1
@@ -0,0 +1,92 @@
+/* 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 <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <librdf.h>
+#include <slv2/types.h>
+#include <slv2/pluginuis.h>
+#include <slv2/pluginui.h>
+#include <slv2/util.h>
+#include "slv2_internal.h"
+
+
+SLV2UIs
+slv2_uis_new()
+{
+ return raptor_new_sequence((void (*)(void*))&slv2_ui_free, NULL);
+ //return raptor_new_sequence(NULL, NULL);
+}
+
+
+void
+slv2_uis_free(SLV2UIs list)
+{
+ if (list)
+ raptor_free_sequence(list);
+}
+
+
+unsigned
+slv2_uis_size(SLV2UIs list)
+{
+ return (list ? raptor_sequence_size(list) : 0);
+}
+
+
+SLV2UI
+slv2_uis_get_by_uri(SLV2UIs list, const char* uri)
+{
+ // good old fashioned binary search
+
+ int lower = 0;
+ int upper = raptor_sequence_size(list) - 1;
+ int i;
+
+ while (upper >= lower) {
+ i = lower + ((upper - lower) / 2);
+
+ SLV2UI ui = raptor_sequence_get_at(list, i);
+
+ const int cmp = strcmp(slv2_ui_get_uri(ui), uri);
+
+ if (cmp == 0)
+ return ui;
+ else if (cmp > 0)
+ upper = i - 1;
+ else
+ lower = i + 1;
+ }
+
+ return NULL;
+}
+
+
+SLV2UI
+slv2_uis_get_at(SLV2UIs list, unsigned index)
+{
+ if (index > INT_MAX)
+ return NULL;
+ else
+ return (SLV2UI)raptor_sequence_get_at(list, (int)index);
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/3rdparty/slv2 CMakeLists.txt slv2/...,
Remon Sijrier <=