[SCM] calf/master: + LV2, LADSPA: fix more initialization order bugs

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:38:13 UTC 2013


The following commit has been merged in the master branch:
commit 0ed21a599e9d2e1fb9773c34b923bf7531169089
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sat Nov 1 14:52:28 2008 +0000

    + LV2, LADSPA: fix more initialization order bugs

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 91690ab..fa85026 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -49,6 +49,7 @@ enum {
     MAX_SAMPLE_RUN = 256
 };
     
+/// Values ORed together for flags field in parameter_properties
 enum parameter_flags
 {
   PF_TYPEMASK = 0x000F,
@@ -269,6 +270,7 @@ extern void get_all_small_plugins(plugin_list_info_iface *plii);
 
 extern std::string generate_ladspa_rdf(const ladspa_plugin_info &info, parameter_properties *params, const char *param_names[], unsigned int count, unsigned int ctl_ofs);
 
+/// A template implementing plugin_ctl_iface for a given plugin
 template<class Module>
 struct ladspa_instance: public Module, public plugin_ctl_iface
 {
@@ -359,6 +361,7 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
     }
 };
 
+/// A wrapper class for plugin class object (there is only one ladspa_wrapper for many instances of the same plugin)
 template<class Module>
 struct ladspa_wrapper
 {
@@ -372,37 +375,18 @@ struct ladspa_wrapper
     static std::vector<plugin_preset> *presets;
     static std::vector<DSSI_Program_Descriptor> *preset_descs;
 #endif
-    ladspa_plugin_info &info;
     
-    ladspa_wrapper(ladspa_plugin_info &i) 
-    : info(i)
-    {
-        init_descriptor(i);
-    }
-    
-    ~ladspa_wrapper()
-    {
-        delete []descriptor.PortNames;
-        delete []descriptor.PortDescriptors;
-        delete []descriptor.PortRangeHints;
-#if USE_DSSI
-        presets->clear();
-        preset_descs->clear();
-        delete presets;
-        delete preset_descs;
-#endif
-    }
-
-    void init_descriptor(ladspa_plugin_info &inf)
+    ladspa_wrapper() 
     {
         int ins = Module::in_count;
         int outs = Module::out_count;
         int params = Module::param_count;
-        descriptor.UniqueID = inf.unique_id;
-        descriptor.Label = inf.label;
-        descriptor.Name = inf.name;
-        descriptor.Maker = inf.maker;
-        descriptor.Copyright = inf.copyright;
+        ladspa_plugin_info &plugin_info = Module::plugin_info;
+        descriptor.UniqueID = plugin_info.unique_id;
+        descriptor.Label = plugin_info.label;
+        descriptor.Name = plugin_info.name;
+        descriptor.Maker = plugin_info.maker;
+        descriptor.Copyright = plugin_info.copyright;
         descriptor.Properties = Module::rt_capable ? LADSPA_PROPERTY_HARD_RT_CAPABLE : 0;
         descriptor.PortCount = ins + outs + params;
         descriptor.PortNames = new char *[descriptor.PortCount];
@@ -493,6 +477,19 @@ struct ladspa_wrapper
 #endif
     }
 
+    ~ladspa_wrapper()
+    {
+        delete []descriptor.PortNames;
+        delete []descriptor.PortDescriptors;
+        delete []descriptor.PortRangeHints;
+#if USE_DSSI
+        presets->clear();
+        preset_descs->clear();
+        delete presets;
+        delete preset_descs;
+#endif
+    }
+
     static LADSPA_Handle cb_instantiate(const struct _LADSPA_Descriptor * Descriptor, unsigned long sample_rate)
     {
         instance *mod = new instance();
@@ -645,6 +642,10 @@ struct ladspa_wrapper
         delete mod;
     }
     
+    static ladspa_wrapper &get() { 
+        static ladspa_wrapper instance;
+        return instance;
+    }
 };
 
 template<class Module>
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index 7711200..02abb45 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -133,8 +133,9 @@ struct lv2_wrapper
     static LV2_Descriptor descriptor;
     std::string uri;
     
-    lv2_wrapper(ladspa_plugin_info &info)
+    lv2_wrapper()
     {
+        ladspa_plugin_info &info = Module::plugin_info;
         uri = "http://calf.sourceforge.net/plugins/" + std::string(info.label);
         descriptor.URI = uri.c_str();
         descriptor.instantiate = cb_instantiate;
@@ -268,6 +269,10 @@ struct lv2_wrapper
     static const void *cb_ext_data(const char *URI) {
         return NULL;
     }
+    static lv2_wrapper &get() { 
+        static lv2_wrapper instance;
+        return instance;
+    }
 };
 
 template<class Module>
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 862c104..45d155b 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -25,23 +25,6 @@
 
 using namespace synth;
 
-#if USE_LADSPA
-#define LADSPA_WRAPPER(mod) static synth::ladspa_wrapper<mod##_audio_module> ladspa_##mod(mod##_audio_module::plugin_info);
-#else
-#define LADSPA_WRAPPER(mod)
-#endif
-
-#if USE_LV2
-#define LV2_WRAPPER(mod) static synth::lv2_wrapper<mod##_audio_module> lv2_##mod(mod##_audio_module::plugin_info);
-#else
-#define LV2_WRAPPER(...)
-#endif
-
-#define ALL_WRAPPERS(mod) LADSPA_WRAPPER(mod) LV2_WRAPPER(mod)
-
-#define PER_MODULE_ITEM(name, isSynth, jackname) ALL_WRAPPERS(name)
-#include <calf/modulelist.h>
-
 #if USE_LV2
 // instantiate descriptor templates
 template<class Module> LV2_Descriptor synth::lv2_wrapper<Module>::descriptor;
@@ -50,7 +33,7 @@ extern "C" {
 
 const LV2_Descriptor *lv2_descriptor(uint32_t index)
 {
-    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!(index--)) return &::lv2_##name.descriptor;
+    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!(index--)) return &synth::lv2_wrapper<name##_audio_module>::get().descriptor;
     #include <calf/modulelist.h>
 #ifdef ENABLE_EXPERIMENTAL
     return lv2_small_descriptor(index);
@@ -68,7 +51,7 @@ extern "C" {
 
 const LADSPA_Descriptor *ladspa_descriptor(unsigned long Index)
 {
-    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!isSynth && !(Index--)) return &::ladspa_##name.descriptor;
+    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!isSynth && !(Index--)) return &synth::ladspa_wrapper<name##_audio_module>::get().descriptor;
     #include <calf/modulelist.h>
     return NULL;
 }
@@ -80,7 +63,7 @@ extern "C" {
 
 const DSSI_Descriptor *dssi_descriptor(unsigned long Index)
 {
-    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!(Index--)) return &::ladspa_##name.dssi_descriptor;
+    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!(Index--)) return &synth::ladspa_wrapper<name##_audio_module>::get().dssi_descriptor;
     #include <calf/modulelist.h>
     return NULL;
 }

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list