only reconfigure lua DSP plugins if channelcount changes
[ardour.git] / libs / ardour / luaproc.cc
index fc899ba4add1cb5e2720cc575a1a0b4ffa1b92c6..03deea7114980c9fa1ef178a129e2c44138f24c1 100644 (file)
@@ -589,23 +589,29 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
 bool
 LuaProc::configure_io (ChanCount in, ChanCount out)
 {
-       _configured_in = in;
-       _configured_out = out;
-
-       _configured_in.set (DataType::MIDI, _has_midi_input ? 1 : 0);
-       _configured_out.set (DataType::MIDI, _has_midi_output ? 1 : 0);
+       in.set (DataType::MIDI, _has_midi_input ? 1 : 0);
+       out.set (DataType::MIDI, _has_midi_output ? 1 : 0);
 
        // configure the DSP if needed
-       lua_State* L = lua.getState ();
-       luabridge::LuaRef lua_dsp_configure = luabridge::getGlobal (L, "dsp_configure");
-       if (lua_dsp_configure.type () == LUA_TFUNCTION) {
-               try {
-                       lua_dsp_configure (&in, &out);
-               } catch (luabridge::LuaException const& e) {
-                       return false;
+       if (in != _configured_in || out != _configured_out) {
+               lua_State* L = lua.getState ();
+               luabridge::LuaRef lua_dsp_configure = luabridge::getGlobal (L, "dsp_configure");
+               if (lua_dsp_configure.type () == LUA_TFUNCTION) {
+                       try {
+                               lua_dsp_configure (&in, &out);
+                       } catch (luabridge::LuaException const& e) {
+                               PBD::error << "LuaException: " << e.what () << "\n";
+#ifndef NDEBUG
+                               std::cerr << "LuaException: " << e.what () << "\n";
+#endif
+                               return false;
+                       }
                }
        }
 
+       _configured_in = in;
+       _configured_out = out;
+
        _info->n_inputs = _configured_in;
        _info->n_outputs = _configured_out;
        return true;
@@ -613,6 +619,7 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
 
 int
 LuaProc::connect_and_run (BufferSet& bufs,
+               framepos_t start, framepos_t end, double speed,
                ChanMapping in, ChanMapping out,
                pframes_t nframes, framecnt_t offset)
 {
@@ -620,7 +627,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
                return 0;
        }
 
-       Plugin::connect_and_run (bufs, in, out, nframes, offset);
+       Plugin::connect_and_run (bufs, start, end, speed, in, out, nframes, offset);
 
        // This is needed for ARDOUR::Session requests :(
        if (! SessionEvent::has_per_thread_pool ()) {