00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __SLV2_PLUGININSTANCE_H__
00020 #define __SLV2_PLUGININSTANCE_H__
00021
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025
00026 #include <assert.h>
00027 #include "lv2.h"
00028 #include "slv2/plugin.h"
00029 #include "slv2/port.h"
00030
00031 typedef struct _InstanceImpl* SLV2InstanceImpl;
00032
00035
00036
00037
00038
00039
00040
00041
00042
00043 typedef struct _Instance {
00044 const LV2_Descriptor* lv2_descriptor;
00045 LV2_Handle lv2_handle;
00046 SLV2InstanceImpl pimpl;
00047 }* SLV2Instance;
00048
00076 SLV2Instance
00077 slv2_plugin_instantiate(SLV2Plugin plugin,
00078 double sample_rate,
00079 const LV2_Feature*const* features);
00080
00081
00086 void
00087 slv2_instance_free(SLV2Instance instance);
00088
00089 #ifndef LIBSLV2_SOURCE
00090
00095 static inline const char*
00096 slv2_instance_get_uri(SLV2Instance instance)
00097 {
00098 assert(instance);
00099 assert(instance->lv2_descriptor);
00100
00101 return instance->lv2_descriptor->URI;
00102 }
00103
00104
00110 static inline void
00111 slv2_instance_connect_port(SLV2Instance instance,
00112 uint32_t port_index,
00113 void* data_location)
00114 {
00115 assert(instance);
00116 assert(instance->lv2_descriptor);
00117 assert(instance->lv2_descriptor->connect_port);
00118
00119 instance->lv2_descriptor->connect_port
00120 (instance->lv2_handle, port_index, data_location);
00121 }
00122
00123
00130 static inline void
00131 slv2_instance_activate(SLV2Instance instance)
00132 {
00133 assert(instance);
00134 assert(instance->lv2_descriptor);
00135
00136 if (instance->lv2_descriptor->activate)
00137 instance->lv2_descriptor->activate(instance->lv2_handle);
00138 }
00139
00140
00146 static inline void
00147 slv2_instance_run(SLV2Instance instance,
00148 uint32_t sample_count)
00149 {
00150 assert(instance);
00151 assert(instance->lv2_descriptor);
00152 assert(instance->lv2_handle);
00153
00154
00155 instance->lv2_descriptor->run(instance->lv2_handle, sample_count);
00156 }
00157
00158
00164 static inline void
00165 slv2_instance_deactivate(SLV2Instance instance)
00166 {
00167 assert(instance);
00168 assert(instance->lv2_descriptor);
00169 assert(instance->lv2_handle);
00170
00171 if (instance->lv2_descriptor->deactivate)
00172 instance->lv2_descriptor->deactivate(instance->lv2_handle);
00173 }
00174
00175
00181 static inline const void*
00182 slv2_instance_get_extension_data(SLV2Instance instance,
00183 const char* uri)
00184 {
00185 assert(instance);
00186 assert(instance->lv2_descriptor);
00187
00188 if (instance->lv2_descriptor->extension_data)
00189 return instance->lv2_descriptor->extension_data(uri);
00190 else
00191 return NULL;
00192 }
00193
00194
00202 static inline const LV2_Descriptor*
00203 slv2_instance_get_descriptor(SLV2Instance instance)
00204 {
00205 assert(instance);
00206 assert(instance->lv2_descriptor);
00207
00208 return instance->lv2_descriptor;
00209 }
00210
00211
00219 static inline LV2_Handle
00220 slv2_instance_get_handle(SLV2Instance instance)
00221 {
00222 assert(instance);
00223 assert(instance->lv2_descriptor);
00224
00225 return instance->lv2_handle;
00226 }
00227
00228 #endif
00229
00232 #ifdef __cplusplus
00233 }
00234 #endif
00235
00236
00237 #endif
00238