Fix potential deadlock on session-load
[ardour.git] / libs / ardour / ardour / luaproc.h
index 39afb72c96ce6469cfa2e59573983b61e805ab50..423a960feb22336af6f6ece25175aa7b09cb0ce9 100644 (file)
     675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+/* print runtime and garbage-collection timing statistics */
+//#define WITH_LUAPROC_STATS
+
+/* memory allocation system, default: ReallocPool */
+//#define USE_TLSF // use TLSF instead of ReallocPool
+//#define USE_MALLOC // or plain OS provided realloc (no mlock) -- if USE_TLSF isn't defined
+
 #ifndef __ardour_luaproc_h__
 #define __ardour_luaproc_h__
 
 #include <vector>
 #include <string>
 
-#include "pbd/reallocpool.h"
+#ifdef USE_TLSF
+#  include "pbd/tlsf.h"
+#else
+#  include "pbd/reallocpool.h"
+#endif
+
 #include "pbd/stateful.h"
 
 #include "ardour/types.h"
@@ -89,6 +101,10 @@ public:
        bool parameter_is_input (uint32_t) const;
        bool parameter_is_output (uint32_t) const;
 
+       uint32_t designated_bypass_port () {
+               return _designated_bypass_port;
+       }
+
        std::string state_node_name() const { return "luaproc"; }
        void add_state (XMLNode *) const;
        int set_state (const XMLNode&, int version);
@@ -109,6 +125,9 @@ public:
        bool has_inline_display () { return _lua_has_inline_display; }
        void setup_lua_inline_gui (LuaState *lua_gui);
 
+       DSP::DspShm* instance_shm () { return &lshm; }
+       LuaTableRef* instance_ref () { return &lref; }
+
 private:
        void find_presets ();
 
@@ -117,7 +136,11 @@ protected:
        const std::string& script() const { return _script; }
 
 private:
+#ifdef USE_TLSF
+       PBD::TLSF _mempool;
+#else
        PBD::ReallocPool _mempool;
+#endif
        LuaState lua;
        luabridge::LuaRef * _lua_dsp;
        std::string _script;
@@ -126,12 +149,12 @@ private:
        bool _lua_has_inline_display;
 
        void queue_draw () { QueueDraw(); /* EMIT SIGNAL */ }
-       DSP::DspShm* instance_shm () { return &lshm; }
        DSP::DspShm lshm;
 
-       LuaTableRef* instance_ref () { return &lref; }
        LuaTableRef lref;
 
+       boost::weak_ptr<Route> route () const;
+
        void init ();
        bool load_script ();
        void lua_print (std::string s);
@@ -145,12 +168,19 @@ private:
        std::vector<std::pair<bool, int> > _ctrl_params;
        std::map<int, ARDOUR::ParameterDescriptor> _param_desc;
        std::map<int, std::string> _param_doc;
+       uint32_t _designated_bypass_port;
 
        float* _control_data;
        float* _shadow_data;
 
        ChanCount _configured_in;
        ChanCount _configured_out;
+
+       bool      _configured;
+
+       ChanCount _selected_in;
+       ChanCount _selected_out;
+
        PluginOutputConfiguration _output_configs;
 
        bool _has_midi_input;