ensure that Lua DSP scripts are configured (even with 0 channels)
[ardour.git] / libs / ardour / luaproc.cc
index e73b18ee21877e6ee533be202935bf0de6573d82..752aa8108fb5b32e34e4b8806a087c3ea5fc7c6b 100644 (file)
@@ -46,7 +46,7 @@ LuaProc::LuaProc (AudioEngine& engine,
                   Session& session,
                   const std::string &script)
        : Plugin (engine, session)
-       , _mempool ("LuaProc", 2097152)
+       , _mempool ("LuaProc", 3145728)
 #ifdef USE_TLSF
        , lua (lua_newstate (&PBD::TLSF::lalloc, &_mempool))
 #elif defined USE_MALLOC
@@ -61,6 +61,7 @@ LuaProc::LuaProc (AudioEngine& engine,
        , _designated_bypass_port (UINT32_MAX)
        , _control_data (0)
        , _shadow_data (0)
+       , _configured (false)
        , _has_midi_input (false)
        , _has_midi_output (false)
 {
@@ -76,7 +77,7 @@ LuaProc::LuaProc (AudioEngine& engine,
 
 LuaProc::LuaProc (const LuaProc &other)
        : Plugin (other)
-       , _mempool ("LuaProc", 2097152)
+       , _mempool ("LuaProc", 3145728)
 #ifdef USE_TLSF
        , lua (lua_newstate (&PBD::TLSF::lalloc, &_mempool))
 #elif defined USE_MALLOC
@@ -91,6 +92,7 @@ LuaProc::LuaProc (const LuaProc &other)
        , _designated_bypass_port (UINT32_MAX)
        , _control_data (0)
        , _shadow_data (0)
+       , _configured (false)
        , _has_midi_input (false)
        , _has_midi_output (false)
 {
@@ -495,8 +497,6 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
                                 * Really imprecise only if desired_in != audio_in */
                                FOUNDCFG_IMPRECISE (desired_in, possible_out);
                        }
-                       // ideally we'll also find the closest, best matching
-                       // input configuration with minimal output penalty...
                }
 
        }
@@ -528,7 +528,7 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
        _info->n_outputs = _selected_out;
 
        // configure the DSP if needed
-       if (in != _configured_in || out != _configured_out) {
+       if (in != _configured_in || out != _configured_out || !_configured) {
                lua_State* L = lua.getState ();
                luabridge::LuaRef lua_dsp_configure = luabridge::getGlobal (L, "dsp_configure");
                if (lua_dsp_configure.type () == LUA_TFUNCTION) {
@@ -565,6 +565,7 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
                                        _info->n_inputs = lin;
                                        _info->n_outputs = lout;
                                }
+                               _configured = true;
                        } catch (luabridge::LuaException const& e) {
                                PBD::error << "LuaException: " << e.what () << "\n";
 #ifndef NDEBUG
@@ -666,6 +667,8 @@ LuaProc::connect_and_run (BufferSet& bufs,
                                                luabridge::LuaRef lua_midi_event (luabridge::newTable (L));
                                                lua_midi_event["time"] = 1 + (*m).time();
                                                lua_midi_event["data"] = lua_midi_data;
+                                               lua_midi_event["bytes"] = data;
+                                               lua_midi_event["size"] = ev.size();
                                                lua_midi_src_tbl[e] = lua_midi_event;
                                        }
                                }
@@ -1035,7 +1038,7 @@ LuaProc::setup_lua_inline_gui (LuaState *lua_gui)
        luabridge::push <LuaProc *> (LG, this);
        lua_setglobal (LG, "self");
 
-       luabridge::push <float *> (LG, _shadow_data);
+       luabridge::push <float *> (LG, _control_data);
        lua_setglobal (LG, "CtrlPorts");
 }
 ////////////////////////////////////////////////////////////////////////////////