Ongoing work on latency compensation
[ardour.git] / libs / ardour / luaproc.cc
index 0e181dbb6b80734ee5f88f541bc3963ed41d578d..6617e8582f35831b64d3da6d9a07a69b1435f801 100644 (file)
@@ -163,7 +163,7 @@ LuaProc::init ()
        lua_setglobal (L, "self");
 
        // sandbox
-       lua.do_command ("io = nil os = nil loadfile = nil require = nil dofile = nil package = nil debug = nil");
+       lua.sandbox (true);
 #if 0
        lua.do_command ("for n in pairs(_G) do print(n) end print ('----')"); // print global env
 #endif
@@ -236,10 +236,9 @@ LuaProc::load_script ()
        luabridge::LuaRef lua_dsp_init = luabridge::getGlobal (L, "dsp_init");
        if (lua_dsp_init.type () == LUA_TFUNCTION) {
                try {
-                       lua_dsp_init (_session.nominal_frame_rate ());
+                       lua_dsp_init (_session.nominal_sample_rate ());
                } catch (luabridge::LuaException const& e) {
-                       ;
-               }
+               } catch (...) { }
        }
 
        _ctrl_params.clear ();
@@ -354,6 +353,8 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
                        }
                } catch (luabridge::LuaException const& e) {
                        _iotable = NULL;
+               } catch (...) {
+                       _iotable = NULL;
                }
        }
 
@@ -584,6 +585,8 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
                                std::cerr << "LuaException: " << e.what () << "\n";
 #endif
                                return false;
+                       } catch (...) {
+                               return false;
                        }
                }
        }
@@ -596,9 +599,9 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
 
 int
 LuaProc::connect_and_run (BufferSet& bufs,
-               framepos_t start, framepos_t end, double speed,
+               samplepos_t start, samplepos_t end, double speed,
                ChanMapping in, ChanMapping out,
-               pframes_t nframes, framecnt_t offset)
+               pframes_t nframes, samplecnt_t offset)
 {
        if (!_lua_dsp) {
                return 0;
@@ -670,7 +673,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
                                if (valid) {
                                        for (MidiBuffer::iterator m = bufs.get_midi(idx).begin();
                                                        m != bufs.get_midi(idx).end(); ++m, ++e) {
-                                               const Evoral::Event<framepos_t> ev(*m, false);
+                                               const Evoral::Event<samplepos_t> ev(*m, false);
                                                luabridge::LuaRef lua_midi_data (luabridge::newTable (L));
                                                const uint8_t* data = ev.buffer();
                                                for (uint32_t i = 0; i < ev.size(); ++i) {
@@ -713,7 +716,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
                                                if (!i.value ()["time"].isNumber ()) { continue; }
                                                if (!i.value ()["data"].isTable ()) { continue; }
                                                luabridge::LuaRef data_tbl (i.value ()["data"]);
-                                               framepos_t tme = i.value ()["time"];
+                                               samplepos_t tme = i.value ()["time"];
                                                if (tme < 1 || tme > nframes) { continue; }
                                                uint8_t data[64];
                                                size_t size = 0;
@@ -734,6 +737,8 @@ LuaProc::connect_and_run (BufferSet& bufs,
                std::cerr << "LuaException: " << e.what () << "\n";
 #endif
                return -1;
+       } catch (...) {
+               return -1;
        }
 #ifdef WITH_LUAPROC_STATS
        int64_t t1 = g_get_monotonic_time ();