SLV2 0.6.6

- Main Page
- Modules
- Files

- File List

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
23 extern "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
32 typedef struct _InstanceImpl* SLV2InstanceImpl;
33
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 */
44 typedef struct _Instance {
45 const LV2_Descriptor* lv2_descriptor;
46 LV2_Handle lv2_handle;
47 SLV2InstanceImpl pimpl;
48 }* SLV2Instance;
49
77 SLV2Instance
78 slv2_plugin_instantiate(SLV2Plugin plugin,
79 double sample_rate,
80 const LV2_Feature*const* features);
81
82
87 void
88 slv2_instance_free(SLV2Instance instance);
89
90 #ifndef LIBSLV2_SOURCE
91
96 static inline const char*
97 slv2_instance_get_uri(SLV2Instance instance)
98 {
99 return instance->lv2_descriptor->URI;
100 }
101
102
108 static inline void
109 slv2_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
124 static inline void
125 slv2_instance_activate(SLV2Instance instance)
126 {
127 if (instance->lv2_descriptor->activate)
128 instance->lv2_descriptor->activate(instance->lv2_handle);
129 }
130
131
137 static inline void
138 slv2_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
151 static inline void
152 slv2_instance_deactivate(SLV2Instance instance)
153 {
154 if (instance->lv2_descriptor->deactivate)
155 instance->lv2_descriptor->deactivate(instance->lv2_handle);
156 }
157
158
164 static inline const void*
165 slv2_instance_get_extension_data(SLV2Instance instance,
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
182 static inline const LV2_Descriptor*
183 slv2_instance_get_descriptor(SLV2Instance instance)
184 {
185 return instance->lv2_descriptor;
186 }
187
188
196 static inline LV2_Handle
197 slv2_instance_get_handle(SLV2Instance instance)
198 {
199 return instance->lv2_handle;
200 }
201
202 #endif /* LIBSLV2_SOURCE */
203
206 #ifdef __cplusplus
207 } /* extern "C" */
208 #endif
209
210
211 #endif /* __SLV2_PLUGININSTANCE_H__ */
212
slv2_instance_activate
static void slv2_instance_activate(SLV2Instance instance)
Activate a plugin instance.
Definition: plugininstance.h:125
slv2_instance_get_handle
static LV2_Handle slv2_instance_get_handle(SLV2Instance instance)
Get the LV2_Handle of the plugin instance.
Definition: plugininstance.h:197
slv2_instance_run
static void slv2_instance_run(SLV2Instance instance, uint32_t sample_count)
Run instance for sample_count frames.
Definition: plugininstance.h:138
slv2_instance_deactivate
static void slv2_instance_deactivate(SLV2Instance instance)
Deactivate a plugin instance.
Definition: plugininstance.h:152
slv2_instance_get_descriptor
static const LV2_Descriptor * slv2_instance_get_descriptor(SLV2Instance instance)
Get the LV2_Descriptor of the plugin instance.
Definition: plugininstance.h:183
slv2_instance_get_extension_data
static const void * slv2_instance_get_extension_data(SLV2Instance instance, const char *uri)
Get extension data from the plugin instance.
Definition: plugininstance.h:165
slv2_instance_free
void slv2_instance_free(SLV2Instance instance)
Free a plugin instance.
slv2_instance_connect_port
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
slv2_plugin_instantiate
SLV2Instance slv2_plugin_instantiate(SLV2Plugin plugin, double sample_rate, const LV2_Feature *const *features)
Instantiate a plugin.
slv2_instance_get_uri
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