SLV2 0.6.6
plugininstance.h
00001 /* SLV2
00002  * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net>
00003  *
00004  * This library is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License as published by the Free
00006  * Software Foundation; either version 2 of the License, or (at your option)
00007  * any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00012  * for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License along
00015  * with this program; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef __SLV2_PLUGININSTANCE_H__
00020 #define __SLV2_PLUGININSTANCE_H__
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 #include <stddef.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 /* Instance of a plugin.
00037  *
00038  * The LV2 descriptor and handle of this are exposed to allow inlining of
00039  * performance critical functions like slv2_instance_run (which are exposed
00040  * in lv2.h anyway).  This is for performance only, this struct is not
00041  * documented and should not be used directly.  The remaining implementation
00042  * details are in the opaque pimpl member.
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     return instance->lv2_descriptor->URI;
00100 }
00101 
00102 
00108 static inline void
00109 slv2_instance_connect_port(SLV2Instance instance,
00110                            uint32_t     port_index,
00111                            void*        data_location)
00112 {
00113     instance->lv2_descriptor->connect_port
00114         (instance->lv2_handle, port_index, data_location);
00115 }
00116 
00117 
00124 static inline void
00125 slv2_instance_activate(SLV2Instance instance)
00126 {
00127     if (instance->lv2_descriptor->activate)
00128         instance->lv2_descriptor->activate(instance->lv2_handle);
00129 }
00130 
00131 
00137 static inline void
00138 slv2_instance_run(SLV2Instance instance,
00139                   uint32_t     sample_count)
00140 {
00141     /*if (instance->lv2_descriptor->run)*/
00142         instance->lv2_descriptor->run(instance->lv2_handle, sample_count);
00143 }
00144 
00145 
00151 static inline void
00152 slv2_instance_deactivate(SLV2Instance instance)
00153 {
00154     if (instance->lv2_descriptor->deactivate)
00155         instance->lv2_descriptor->deactivate(instance->lv2_handle);
00156 }
00157 
00158 
00164 static inline const void*
00165 slv2_instance_get_extension_data(SLV2Instance instance,
00166                                  const char*  uri)
00167 {
00168     if (instance->lv2_descriptor->extension_data)
00169         return instance->lv2_descriptor->extension_data(uri);
00170     else
00171         return NULL;
00172 }
00173 
00174 
00182 static inline const LV2_Descriptor*
00183 slv2_instance_get_descriptor(SLV2Instance instance)
00184 {
00185     return instance->lv2_descriptor;
00186 }
00187 
00188 
00196 static inline LV2_Handle
00197 slv2_instance_get_handle(SLV2Instance instance)
00198 {
00199     return instance->lv2_handle;
00200 }
00201 
00202 #endif /* LIBSLV2_SOURCE */
00203 
00206 #ifdef __cplusplus
00207 } /* extern "C" */
00208 #endif
00209 
00210 
00211 #endif /* __SLV2_PLUGININSTANCE_H__ */
00212 

Generated for SLV2 by doxygen 1.7.4