summaryrefslogtreecommitdiffstats
path: root/slv2/plugininstance.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-06 20:20:33 +0000
committerDavid Robillard <d@drobilla.net>2006-06-06 20:20:33 +0000
commit7fd4168fe8581e46f4ee35cc182db6220b6eed04 (patch)
tree403d603debb6304193f60c2adda8a53863c45e04 /slv2/plugininstance.h
parente9a163310bc7b0a607d89ed5cb70c6bba99e919d (diff)
downloadlilv-7fd4168fe8581e46f4ee35cc182db6220b6eed04.tar.gz
lilv-7fd4168fe8581e46f4ee35cc182db6220b6eed04.tar.bz2
lilv-7fd4168fe8581e46f4ee35cc182db6220b6eed04.zip
Moved libslv2 into it's own subdirectory
git-svn-id: http://svn.drobilla.net/lad/libslv2@4 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'slv2/plugininstance.h')
-rw-r--r--slv2/plugininstance.h205
1 files changed, 205 insertions, 0 deletions
diff --git a/slv2/plugininstance.h b/slv2/plugininstance.h
new file mode 100644
index 0000000..5fd9393
--- /dev/null
+++ b/slv2/plugininstance.h
@@ -0,0 +1,205 @@
+/* LibSLV2
+ * Copyright (C) 2006 Dave Robillard <drobilla@connect.carleton.ca>
+ *
+ * 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_PLUGININSTANCE_H__
+#define __SLV2_PLUGININSTANCE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <lv2.h>
+#include <slv2/private_types.h>
+#include <slv2/plugininstance.h>
+#include <slv2/plugin.h>
+#include <slv2/port.h>
+
+
+typedef const struct _Instance SLV2Instance;
+
+
+/** \defgroup lib Plugin library access
+ *
+ * An SLV2Instance is an instantiated SLV2Plugin (eg a loaded dynamic
+ * library). These functions interact with the binary library code only,
+ * they do not read any RDF data files whatsoever.
+ *
+ * @{
+ */
+
+
+/** Instantiate a plugin.
+ *
+ * The returned object represents shared library objects loaded into memory,
+ * it must be cleaned up with slv2instance_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).
+ *
+ * \return NULL if instantiation failed.
+ */
+SLV2Instance*
+slv2_plugin_instantiate(const SLV2Plugin* plugin,
+ unsigned long sample_rate,
+ const LV2_Host_Feature** host_features);
+
+
+/** Free a plugin instance.
+ *
+ * \a instance is invalid after this call.
+ */
+void
+slv2_instance_free(SLV2Instance* instance);
+
+
+#ifndef LIBSLV2_SOURCE
+
+
+/** Get the URI of the plugin which \a instance is an instance of.
+ *
+ * Returned string is shared and must not be modified or deleted.
+ */
+inline const char*
+slv2_instance_get_uri(SLV2Instance* instance)
+{
+ assert(instance);
+ assert(instance->descriptor);
+
+ return instance->descriptor->URI;
+}
+
+
+/** Connect a port to a data location.
+ *
+ * This may be called regardless of whether the plugin is activated,
+ * activation and deactivation does not destroy port connections.
+ */
+inline void
+slv2_instance_connect_port(SLV2Instance* instance,
+ unsigned long port_index,
+ void* data_location)
+{
+ assert(instance);
+ assert(instance->descriptor);
+ assert(instance->descriptor->connect_port);
+
+ instance->descriptor->connect_port
+ (instance->lv2_handle, port_index, data_location);
+}
+
+
+/** Activate a plugin instance.
+ *
+ * This resets all state information in the plugin, except for port data
+ * locations (as set by slv2instance_connect_port). This MUST be called
+ * before calling slv2instance_run.
+ */
+inline void
+slv2_instance_activate(SLV2Instance* instance)
+{
+ assert(instance);
+ assert(instance->descriptor);
+
+ if (instance->descriptor->activate)
+ instance->descriptor->activate(instance->lv2_handle);
+}
+
+
+/** Run \a instance for \a sample_count frames.
+ *
+ * If the hint lv2:realtimeSafe is set for this plugin, this function is
+ * guaranteed not to block.
+ */
+inline void
+slv2_instance_run(SLV2Instance* instance,
+ unsigned long sample_count)
+{
+ assert(instance);
+ assert(instance->descriptor);
+ assert(instance->lv2_handle),
+ assert(instance->descriptor->run);
+
+ instance->descriptor->run(instance->lv2_handle, sample_count);
+}
+
+
+/** Deactivate a plugin instance.
+ *
+ * Note that to run the plugin after this you must activate it, which will
+ * reset all state information (except port connections).
+ */
+inline void
+slv2_instance_deactivate(SLV2Instance* instance)
+{
+ assert(instance);
+ assert(instance->descriptor);
+ assert(instance->lv2_handle);
+
+ if (instance->descriptor->deactivate)
+ instance->descriptor->deactivate(instance->lv2_handle);
+}
+
+
+/** Get the LV2_Descriptor of the plugin instance.
+ *
+ * Normally hosts should not need to access the LV2_Descriptor directly,
+ * use the slv2instance_* functions.
+ *
+ * The returned descriptor is shared and must not be deleted.
+ */
+inline const LV2_Descriptor*
+slv2_instance_get_descriptor(SLV2Instance* instance)
+{
+ assert(instance);
+ assert(instance->descriptor);
+
+ return instance->descriptor;
+}
+
+
+/** Get the LV2_Handle of the plugin instance.
+ *
+ * Normally hosts should not need to access the LV2_Handle directly,
+ * use the slv2instance_* functions.
+ *
+ * The returned handle is shared and must not be deleted.
+ */
+inline LV2_Handle
+slv2_instance_get_handle(SLV2Instance* instance)
+{
+ assert(instance);
+ assert(instance->descriptor);
+
+ return instance->lv2_handle;
+}
+
+#endif /* LIBSLV2_SOURCE */
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __SLV2_PLUGININSTANCE_H__ */
+