, 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)
, 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)
LuaProc::~LuaProc () {
#ifdef WITH_LUAPROC_STATS
if (_info && _stats_cnt > 0) {
- printf ("LuaProc: '%s' run() avg: %.3f max: %.3f [ms]\n",
+ printf ("LuaProc: '%s' run() avg: %.3f max: %.3f [ms] p: %.1f\n",
_info->name.c_str (),
0.0001f * _stats_avg[0] / (float) _stats_cnt,
- 0.0001f * _stats_max[0]);
- printf ("LuaProc: '%s' gc() avg: %.3f max: %.3f [ms]\n",
+ 0.0001f * _stats_max[0],
+ _stats_max[0] * (float)_stats_cnt / _stats_avg[0]);
+ printf ("LuaProc: '%s' gc() avg: %.3f max: %.3f [ms] p: %.1f\n",
_info->name.c_str (),
0.0001f * _stats_avg[1] / (float) _stats_cnt,
- 0.0001f * _stats_max[1]);
+ 0.0001f * _stats_max[1],
+ _stats_max[1] * (float)_stats_cnt / _stats_avg[1]);
}
#endif
lua.do_command ("collectgarbage();");
delete (_lua_dsp);
+ delete (_lua_latency);
delete [] _control_data;
delete [] _shadow_data;
}
LuaProc::init ()
{
#ifdef WITH_LUAPROC_STATS
- _stats_avg[0] = _stats_avg[1] = _stats_max[0] = _stats_max[1] = _stats_cnt = 0;
+ _stats_avg[0] = _stats_avg[1] = _stats_max[0] = _stats_max[1] = 0;
+ _stats_cnt = -25;
#endif
- lua.tweak_rt_gc ();
lua.Print.connect (sigc::mem_fun (*this, &LuaProc::lua_print));
// register session object
lua_State* L = lua.getState ();
+ lua_mlock (L, 1);
LuaBindings::stddef (L);
LuaBindings::common (L);
LuaBindings::dsp (L);
.addFunction ("name", &LuaProc::name)
.endClass ()
.endNamespace ();
+ lua_mlock (L, 0);
// add session to global lua namespace
luabridge::push <Session *> (L, &_session);
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) {
}
}
}
+
+ if (_lua_latency) {
+ _signal_latency = (*_lua_latency)();
+ }
+
} catch (luabridge::LuaException const& e) {
PBD::error << "LuaException: " << e.what () << "\n";
#ifndef NDEBUG
int64_t t1 = g_get_monotonic_time ();
#endif
- lua.collect_garbage_step (100 /*kB*/);
+ lua.collect_garbage_step ();
#ifdef WITH_LUAPROC_STATS
- ++_stats_cnt;
- int64_t t2 = g_get_monotonic_time ();
- int64_t ela0 = t1 - t0;
- int64_t ela1 = t2 - t1;
- if (ela0 > _stats_max[0]) _stats_max[0] = ela0;
- if (ela1 > _stats_max[1]) _stats_max[1] = ela1;
- _stats_avg[0] += ela0;
- _stats_avg[1] += ela1;
+ if (++_stats_cnt > 0) {
+ int64_t t2 = g_get_monotonic_time ();
+ int64_t ela0 = t1 - t0;
+ int64_t ela1 = t2 - t1;
+ if (ela0 > _stats_max[0]) _stats_max[0] = ela0;
+ if (ela1 > _stats_max[1]) _stats_max[1] = ela1;
+ _stats_avg[0] += ela0;
+ _stats_avg[1] += ela1;
+ }
#endif
return 0;
}
n_outputs.set (DataType::AUDIO, 1);
type = Lua;
- _is_instrument = category == "Instrument";
}
PluginPtr
try {
script = Glib::file_get_contents (path);
- } catch (Glib::FileError err) {
+ } catch (Glib::FileError const& err) {
return PluginPtr ();
}