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 <stdlib.h>
00028 #include "lv2.h"
00029 #include "slv2/plugin.h"
00030 #include "slv2/port.h"
00031
00032 typedef struct _InstanceImpl* SLV2InstanceImpl;
00033
00036
00037
00038
00039
00040
00041
00042
00043
00044 typedef struct _Instance {
00045 const LV2_Descriptor* lv2_descriptor;
00046 LV2_Handle lv2_handle;
00047 SLV2InstanceImpl pimpl;
00048 }* SLV2Instance;
00049
00077 SLV2Instance
00078 slv2_plugin_instantiate(SLV2Plugin plugin,
00079 double sample_rate,
00080 const LV2_Feature*const* features);
00081
00082
00087 void
00088 slv2_instance_free(SLV2Instance instance);
00089
00090 #ifndef LIBSLV2_SOURCE
00091
00096 static inline const char*
00097 slv2_instance_get_uri(SLV2Instance instance)
00098 {
00099 assert(instance);
00100 assert(instance->lv2_descriptor);
00101
00102 return instance->lv2_descriptor->URI;
00103 }
00104
00105
00111 static inline void
00112 slv2_instance_connect_port(SLV2Instance instance,
00113 uint32_t port_index,
00114 void* data_location)
00115 {
00116 assert(instance);
00117 assert(instance->lv2_descriptor);
00118 assert(instance->lv2_descriptor->connect_port);
00119
00120 instance->lv2_descriptor->connect_port
00121 (instance->lv2_handle, port_index, data_location);
00122 }
00123
00124
00131 static inline void
00132 slv2_instance_activate(SLV2Instance instance)
00133 {
00134 assert(instance);
00135 assert(instance->lv2_descriptor);
00136
00137 if (instance->lv2_descriptor->activate)
00138 instance->lv2_descriptor->activate(instance->lv2_handle);
00139 }
00140
00141
00147 static inline void
00148 slv2_instance_run(SLV2Instance instance,
00149 uint32_t sample_count)
00150 {
00151 assert(instance);
00152 assert(instance->lv2_descriptor);
00153 assert(instance->lv2_handle);
00154
00155
00156 instance->lv2_descriptor->run(instance->lv2_handle, sample_count);
00157 }
00158
00159
00165 static inline void
00166 slv2_instance_deactivate(SLV2Instance instance)
00167 {
00168 assert(instance);
00169 assert(instance->lv2_descriptor);
00170 assert(instance->lv2_handle);
00171
00172 if (instance->lv2_descriptor->deactivate)
00173 instance->lv2_descriptor->deactivate(instance->lv2_handle);
00174 }
00175
00176
00182 static inline const void*
00183 slv2_instance_get_extension_data(SLV2Instance instance,
00184 const char* uri)
00185 {
00186 assert(instance);
00187 assert(instance->lv2_descriptor);
00188
00189 if (instance->lv2_descriptor->extension_data)
00190 return instance->lv2_descriptor->extension_data(uri);
00191 else
00192 return NULL;
00193 }
00194
00195
00203 static inline const LV2_Descriptor*
00204 slv2_instance_get_descriptor(SLV2Instance instance)
00205 {
00206 assert(instance);
00207 assert(instance->lv2_descriptor);
00208
00209 return instance->lv2_descriptor;
00210 }
00211
00212
00220 static inline LV2_Handle
00221 slv2_instance_get_handle(SLV2Instance instance)
00222 {
00223 assert(instance);
00224 assert(instance->lv2_descriptor);
00225
00226 return instance->lv2_handle;
00227 }
00228
00229 #endif
00230
00233 #ifdef __cplusplus
00234 }
00235 #endif
00236
00237
00238 #endif
00239