SLV2 0.6.6
plugininstance.h
1/* SLV2
2 * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net>
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef __SLV2_PLUGININSTANCE_H__
20#define __SLV2_PLUGININSTANCE_H__
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <stddef.h>
27#include <stdlib.h>
28#include "lv2.h"
29#include "slv2/plugin.h"
30#include "slv2/port.h"
31
32typedef struct _InstanceImpl* SLV2InstanceImpl;
33
35
36/* Instance of a plugin.
37 *
38 * The LV2 descriptor and handle of this are exposed to allow inlining of
39 * performance critical functions like slv2_instance_run (which are exposed
40 * in lv2.h anyway). This is for performance only, this struct is not
41 * documented and should not be used directly. The remaining implementation
42 * details are in the opaque pimpl member.
43 */
44typedef struct _Instance {
45 const LV2_Descriptor* lv2_descriptor;
46 LV2_Handle lv2_handle;
47 SLV2InstanceImpl pimpl;
48}* SLV2Instance;
49
51
52
61
77SLV2Instance
78slv2_plugin_instantiate(SLV2Plugin plugin,
79 double sample_rate,
80 const LV2_Feature*const* features);
81
82
87void
88slv2_instance_free(SLV2Instance instance);
89
90#ifndef LIBSLV2_SOURCE
91
96static inline const char*
97slv2_instance_get_uri(SLV2Instance instance)
98{
99 return instance->lv2_descriptor->URI;
100}
101
102
108static inline void
109slv2_instance_connect_port(SLV2Instance instance,
110 uint32_t port_index,
111 void* data_location)
112{
113 instance->lv2_descriptor->connect_port
114 (instance->lv2_handle, port_index, data_location);
115}
116
117
124static inline void
125slv2_instance_activate(SLV2Instance instance)
126{
127 if (instance->lv2_descriptor->activate)
128 instance->lv2_descriptor->activate(instance->lv2_handle);
129}
130
131
137static inline void
138slv2_instance_run(SLV2Instance instance,
139 uint32_t sample_count)
140{
141 /*if (instance->lv2_descriptor->run)*/
142 instance->lv2_descriptor->run(instance->lv2_handle, sample_count);
143}
144
145
151static inline void
152slv2_instance_deactivate(SLV2Instance instance)
153{
154 if (instance->lv2_descriptor->deactivate)
155 instance->lv2_descriptor->deactivate(instance->lv2_handle);
156}
157
158
164static inline const void*
166 const char* uri)
167{
168 if (instance->lv2_descriptor->extension_data)
169 return instance->lv2_descriptor->extension_data(uri);
170 else
171 return NULL;
172}
173
174
182static inline const LV2_Descriptor*
183slv2_instance_get_descriptor(SLV2Instance instance)
184{
185 return instance->lv2_descriptor;
186}
187
188
196static inline LV2_Handle
197slv2_instance_get_handle(SLV2Instance instance)
198{
199 return instance->lv2_handle;
200}
201
202#endif /* LIBSLV2_SOURCE */
203
205
206#ifdef __cplusplus
207} /* extern "C" */
208#endif
209
210
211#endif /* __SLV2_PLUGININSTANCE_H__ */
212
static void slv2_instance_connect_port(SLV2Instance instance, uint32_t port_index, void *data_location)
Connect a port to a data location.
Definition plugininstance.h:109
static const char * slv2_instance_get_uri(SLV2Instance instance)
Get the URI of the plugin which instance is an instance of.
Definition plugininstance.h:97
static const LV2_Descriptor * slv2_instance_get_descriptor(SLV2Instance instance)
Get the LV2_Descriptor of the plugin instance.
Definition plugininstance.h:183
static const void * slv2_instance_get_extension_data(SLV2Instance instance, const char *uri)
Get extension data from the plugin instance.
Definition plugininstance.h:165
SLV2Instance slv2_plugin_instantiate(SLV2Plugin plugin, double sample_rate, const LV2_Feature *const *features)
Instantiate a plugin.
static void slv2_instance_run(SLV2Instance instance, uint32_t sample_count)
Run instance for sample_count frames.
Definition plugininstance.h:138
static void slv2_instance_deactivate(SLV2Instance instance)
Deactivate a plugin instance.
Definition plugininstance.h:152
void slv2_instance_free(SLV2Instance instance)
Free a plugin instance.
static LV2_Handle slv2_instance_get_handle(SLV2Instance instance)
Get the LV2_Handle of the plugin instance.
Definition plugininstance.h:197
static void slv2_instance_activate(SLV2Instance instance)
Activate a plugin instance.
Definition plugininstance.h:125

Generated for SLV2 by doxygen 1.13.2