summaryrefslogtreecommitdiff
path: root/libs/ardour/luaproc.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-10-19 18:10:19 +0200
committerRobin Gareus <robin@gareus.org>2018-10-20 00:24:38 +0200
commitc6955d4994e7b699e69227b17d8b74aefe0f5028 (patch)
tree0642155c00dccdbee1591e0e77c8d529451a1485 /libs/ardour/luaproc.cc
parent777fe3c68fef42d8fee79432830787bcebdfcb59 (diff)
Allow Lua DSP processors to report latency
Diffstat (limited to 'libs/ardour/luaproc.cc')
-rw-r--r--libs/ardour/luaproc.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc
index 4e2b32c838..ec13efb1bf 100644
--- a/libs/ardour/luaproc.cc
+++ b/libs/ardour/luaproc.cc
@@ -54,10 +54,12 @@ LuaProc::LuaProc (AudioEngine& engine,
, lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
#endif
, _lua_dsp (0)
+ , _lua_latency (0)
, _script (script)
, _lua_does_channelmapping (false)
, _lua_has_inline_display (false)
, _designated_bypass_port (UINT32_MAX)
+ , _signal_latency (0)
, _control_data (0)
, _shadow_data (0)
, _configured (false)
@@ -85,11 +87,13 @@ LuaProc::LuaProc (const LuaProc &other)
, lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
#endif
, _lua_dsp (0)
+ , _lua_latency (0)
, _script (other.script ())
, _origin (other._origin)
, _lua_does_channelmapping (false)
, _lua_has_inline_display (false)
, _designated_bypass_port (UINT32_MAX)
+ , _signal_latency (0)
, _control_data (0)
, _shadow_data (0)
, _configured (false)
@@ -125,6 +129,7 @@ LuaProc::~LuaProc () {
#endif
lua.do_command ("collectgarbage();");
delete (_lua_dsp);
+ delete (_lua_latency);
delete [] _control_data;
delete [] _shadow_data;
}
@@ -236,6 +241,11 @@ LuaProc::load_script ()
assert (0);
}
+ luabridge::LuaRef lua_dsp_latency = luabridge::getGlobal (L, "dsp_latency");
+ if (lua_dsp_latency.type () == LUA_TFUNCTION) {
+ _lua_latency = new luabridge::LuaRef (lua_dsp_latency);
+ }
+
// initialize the DSP if needed
luabridge::LuaRef lua_dsp_init = luabridge::getGlobal (L, "dsp_init");
if (lua_dsp_init.type () == LUA_TFUNCTION) {
@@ -735,6 +745,11 @@ LuaProc::connect_and_run (BufferSet& bufs,
}
}
}
+
+ if (_lua_latency) {
+ _signal_latency = (*_lua_latency)();
+ }
+
} catch (luabridge::LuaException const& e) {
PBD::error << "LuaException: " << e.what () << "\n";
#ifndef NDEBUG