summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/hosts/jack_host.c10
-rw-r--r--slv2/lv2.h6
-rw-r--r--slv2/plugininstance.h4
-rw-r--r--src/plugininstance.c9
4 files changed, 22 insertions, 7 deletions
diff --git a/examples/hosts/jack_host.c b/examples/hosts/jack_host.c
index a29fb13..655c939 100644
--- a/examples/hosts/jack_host.c
+++ b/examples/hosts/jack_host.c
@@ -28,7 +28,7 @@ struct JackHost {
jack_client_t* jack_client; /**< Jack client */
SLV2Plugin* plugin; /**< Plugin "class" (actually just a few strings) */
SLV2Instance* instance; /**< Plugin "instance" (loaded shared lib) */
- size_t num_ports; /**< Size of the two following arrays: */
+ uint32_t num_ports; /**< Size of the two following arrays: */
jack_port_t** jack_ports; /**< For audio ports, otherwise NULL */
float* controls; /**< For control ports, otherwise 0.0f */
};
@@ -97,10 +97,10 @@ main(int argc, char** argv)
/* Create ports */
host.num_ports = slv2_plugin_get_num_ports(host.plugin);
- host.jack_ports = calloc(host.num_ports, sizeof(jack_port_t*));
- host.controls = calloc(host.num_ports, sizeof(float*));
+ host.jack_ports = calloc((size_t)host.num_ports, sizeof(jack_port_t*));
+ host.controls = calloc((size_t)host.num_ports, sizeof(float*));
- for (size_t i=0; i < host.num_ports; ++i)
+ for (uint32_t i=0; i < host.num_ports; ++i)
create_port(&host, i);
/* Activate plugin and JACK */
@@ -198,7 +198,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
struct JackHost* host = (struct JackHost*)data;
/* Connect plugin ports directly to JACK buffers */
- for (size_t i=0; i < host->num_ports; ++i)
+ for (uint32_t i=0; i < host->num_ports; ++i)
if (host->jack_ports[i] != NULL)
slv2_instance_connect_port(host->instance, i,
jack_port_get_buffer(host->jack_ports[i], nframes));
diff --git a/slv2/lv2.h b/slv2/lv2.h
index b3d97bf..7e3b14e 100644
--- a/slv2/lv2.h
+++ b/slv2/lv2.h
@@ -146,13 +146,15 @@ typedef struct _LV2_Descriptor {
* found. This function must return NULL if instantiation fails.
*
* BundlePath is a string of the path to the plugin's .lv2 bundle
- * directory, it MUST not include the trailing /.
+ * directory, it MUST NOT include the trailing /.
*
* HostFeatures is a NULL terminated array of the URIs of the LV2
* features that the host supports. Plugins may refuse to instantiate
* if required features are not found here (however hosts SHOULD NOT use
* this as a discovery mechanism, instead reading the data file before
- * attempting to instantiate the plugin).
+ * attempting to instantiate the plugin). This array must always exist;
+ * if a host has no features, it MUST pass a single element array
+ * containing NULL (to simplify plugins).
*
* Note that instance initialisation should generally occur in
* activate() rather than here. If a host calls instantiate, it MUST
diff --git a/slv2/plugininstance.h b/slv2/plugininstance.h
index aba3f95..553bb74 100644
--- a/slv2/plugininstance.h
+++ b/slv2/plugininstance.h
@@ -54,6 +54,10 @@ typedef const struct _Instance SLV2Instance;
* \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.
*/
SLV2Instance*
diff --git a/src/plugininstance.c b/src/plugininstance.c
index 1566c7d..9db7d26 100644
--- a/src/plugininstance.c
+++ b/src/plugininstance.c
@@ -35,6 +35,12 @@ slv2_plugin_instantiate(const SLV2Plugin* plugin,
{
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;
+ }
+
const char* const lib_path = slv2_plugin_get_library_path(plugin);
if (!lib_path)
return NULL;
@@ -90,6 +96,9 @@ slv2_plugin_instantiate(const SLV2Plugin* plugin,
for (uint32_t i=0; i < slv2_plugin_get_num_ports(plugin); ++i)
result->descriptor->connect_port(result->lv2_handle, i, NULL);
+ if (local_host_features)
+ free(host_features);
+
return result;
}