hotfix for concurrent lua interpreter calls
authorRobin Gareus <robin@gareus.org>
Sat, 19 Mar 2016 17:03:36 +0000 (18:03 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 19 Mar 2016 17:03:36 +0000 (18:03 +0100)
ToDo: localize parameter descriptor in init()

libs/ardour/ardour/luaproc.h
libs/ardour/luaproc.cc

index d0560e9953f40f72ec7697de045451f74d10a7d8..062aad9fff64f789dcfcf4f9832ead90b31717d2 100644 (file)
@@ -142,6 +142,9 @@ private:
        int64_t _stats_max[2];
        int64_t _stats_cnt;
 #endif
+
+       mutable Glib::Threads::Mutex debug_hack; // prevent concurrent calls to  _lua_dsp() and _lua_params() -- test/debug
+
 };
 
 class LIBARDOUR_API LuaPluginInfo : public PluginInfo
index a030691e9fe8b6b8cfb375878dc24ecd540ae2c2..2669f3a03fdf9afd53a5dd441b8e0b4fd37033e4 100644 (file)
@@ -531,6 +531,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
 
        try {
                if (_lua_does_channelmapping) {
+                       Glib::Threads::Mutex::Lock lm (debug_hack);
                        // run the DSP function
                        (*_lua_dsp)(&bufs, in, out, nframes, offset);
                } else {
@@ -594,6 +595,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
                        }
 
 
+                       Glib::Threads::Mutex::Lock lm (debug_hack);
                        // run the DSP function
                        (*_lua_dsp)(in_map, out_map, nframes);
                }
@@ -747,6 +749,7 @@ LuaProc::default_value (uint32_t port)
                return 0;
        }
        int lp = _ctrl_params[port].second;
+       Glib::Threads::Mutex::Lock lm (debug_hack);
        luabridge::LuaRef lr = (*_lua_params)[lp];
        return (lr["default"]).cast<float> ();
 }
@@ -778,6 +781,7 @@ LuaProc::get_parameter_descriptor (uint32_t port, ParameterDescriptor& desc) con
        assert (port <= parameter_count ());
        int lp = _ctrl_params[port].second;
 
+       Glib::Threads::Mutex::Lock lm (debug_hack);
        luabridge::LuaRef lr = (*_lua_params)[lp];
        desc.lower  = (lr["min"]).cast<float> ();
        desc.upper  = (lr["max"]).cast<float> ();
@@ -814,6 +818,7 @@ std::string
 LuaProc::get_parameter_docs (uint32_t port) const {
        assert (port <= parameter_count ());
        int lp = _ctrl_params[port].second;
+       Glib::Threads::Mutex::Lock lm (debug_hack);
        luabridge::LuaRef lr = (*_lua_params)[lp];
        luabridge::LuaRef doc = lr["doc"];
        if (doc.isString ()) {
@@ -864,6 +869,7 @@ LuaProc::describe_parameter (Evoral::Parameter param)
 {
        if (param.type () == PluginAutomation && param.id () < parameter_count ()) {
                int lp = _ctrl_params[param.id ()].second;
+               Glib::Threads::Mutex::Lock lm (debug_hack);
                luabridge::LuaRef lr = (*_lua_params)[lp];
                return (lr["name"]).cast<std::string> ();
        } else {
@@ -887,6 +893,7 @@ boost::shared_ptr<ScalePoints>
 LuaProc::get_scale_points (uint32_t port) const
 {
        int lp = _ctrl_params[port].second;
+       Glib::Threads::Mutex::Lock lm (debug_hack);
        luabridge::LuaRef lr = (*_lua_params)[lp];
 
        if (!lr["scalepoints"].isTable()) {