Transfer Fn: skip phase calculation for silence and small signal levels
[ardour.git] / gtk2_ardour / luainstance.cc
index 490790233f04a653db2b3b7a49456a71246899af..0756d803be498092eac59fc7ca695dd929022455 100644 (file)
@@ -73,9 +73,9 @@ class ImageSurface {
                 * color or alpha channel belonging to format will be 0. The contents of bits
                 * within a pixel, but not belonging to the given format are undefined).
                 *
-                * @param format        format of pixels in the surface to create
-                * @param width         width of the surface, in pixels
-                * @param height        height of the surface, in pixels
+                * @param format  format of pixels in the surface to create
+                * @param width   width of the surface, in pixels
+                * @param height  height of the surface, in pixels
                 */
                ImageSurface (Cairo::Format format, int width, int height)
                        : _surface (Cairo::ImageSurface::create (format, width, height))
@@ -147,10 +147,10 @@ class ImageSurface {
 
                /** Marks a rectangular area of the given surface dirty.
                 *
-                * @param x      X coordinate of dirty rectangle
-                * @param y     Y coordinate of dirty rectangle
-                * @param width         width of dirty rectangle
-                * @param height        height of dirty rectangle
+                * @param x X coordinate of dirty rectangle
+                * @param y Y coordinate of dirty rectangle
+                * @param width width of dirty rectangle
+                * @param height height of dirty rectangle
                 */
                void mark_dirty (int x, int y, int width, int height) {
                        _surface->mark_dirty (x, y, width, height);
@@ -446,7 +446,7 @@ lua_actionlist (lua_State *L)
        vector<string> tooltips;
        vector<string> keys;
        vector<Glib::RefPtr<Gtk::Action> > actions;
-       Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions);
+       ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
 
        vector<string>::iterator p;
        vector<string>::iterator l;
@@ -472,24 +472,18 @@ lua_actionlist (lua_State *L)
                        continue;
                if (parts[1] == _("redirectmenu"))
                        continue;
-               if (parts[1] == _("Editor_menus"))
-                       continue;
                if (parts[1] == _("RegionList"))
                        continue;
                if (parts[1] == _("ProcessorMenu"))
                        continue;
 
-               /* strip <Actions>/ from the start */
-               string path = (*p);
-               path = path.substr (strlen ("<Actions>/"));
-
                if (!action_tbl[parts[1]].isTable()) {
                        action_tbl[parts[1]] = luabridge::newTable (L);
                }
                assert (action_tbl[parts[1]].isTable());
                luabridge::LuaRef tbl (action_tbl[parts[1]]);
                assert (tbl.isTable());
-               tbl[*l] = path;
+               tbl[*l] = *p;
        }
 
        luabridge::push (L, action_tbl);
@@ -512,6 +506,7 @@ lua_translate_order (RouteDialogs::InsertAt place)
 
 using namespace ARDOUR;
 
+PBD::Signal0<void> LuaInstance::LuaTimerS;
 PBD::Signal0<void> LuaInstance::LuaTimerDS;
 PBD::Signal0<void> LuaInstance::SetSession;
 
@@ -754,7 +749,7 @@ LuaInstance::register_classes (lua_State* L)
 
                .addFunction ("processor_selection", &LuaMixer::processor_selection)
 
-               .beginStdList <ArdourMarker*> ("ArdourMarkerList")
+               .beginStdCPtrList <ArdourMarker> ("ArdourMarkerList")
                .endClass ()
 
                .beginClass <ArdourMarker> ("ArdourMarker")
@@ -1095,8 +1090,6 @@ LuaInstance::LuaInstance ()
 {
        lua.Print.connect (&_lua_print);
        init ();
-
-       load_state ();
 }
 
 LuaInstance::~LuaInstance ()
@@ -1321,6 +1314,9 @@ LuaInstance::save_state ()
 void
 LuaInstance::set_dirty ()
 {
+       if (!_session || _session->deletion_in_progress()) {
+               return;
+       }
        save_state ();
        _session->set_dirty (); // XXX is this reasonable?
 }
@@ -1340,6 +1336,7 @@ void LuaInstance::set_session (Session* s)
        for (LuaCallbackMap::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i) {
                i->second->set_session (s);
        }
+       second_connection = Timers::rapid_connect (sigc::mem_fun(*this, & LuaInstance::every_second));
        point_one_second_connection = Timers::rapid_connect (sigc::mem_fun(*this, & LuaInstance::every_point_one_seconds));
        SetSession (); /* EMIT SIGNAL */
 }
@@ -1348,6 +1345,7 @@ void
 LuaInstance::session_going_away ()
 {
        ENSURE_GUI_THREAD (*this, &LuaInstance::session_going_away);
+       second_connection.disconnect ();
        point_one_second_connection.disconnect ();
 
        (*_lua_clear)();
@@ -1362,6 +1360,12 @@ LuaInstance::session_going_away ()
        lua.do_command ("collectgarbage();");
 }
 
+void
+LuaInstance::every_second ()
+{
+       LuaTimerS (); // emit signal
+}
+
 void
 LuaInstance::every_point_one_seconds ()
 {
@@ -1393,6 +1397,7 @@ LuaInstance::set_state (const XMLNode& node)
                }
        }
 
+       assert (_callbacks.empty());
        if ((child = find_named_node (node, "ActionHooks"))) {
                for (XMLNodeList::const_iterator n = child->children ().begin (); n != child->children ().end (); ++n) {
                        try {
@@ -1735,11 +1740,11 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri
                _callbacks.insert (std::make_pair(p->id(), p));
                p->drop_callback.connect (_slotcon, MISSING_INVALIDATOR, boost::bind (&LuaInstance::unregister_lua_slot, this, p->id()), gui_context());
                SlotChanged (p->id(), p->name(), p->signals()); /* EMIT SIGNAL */
+               set_dirty ();
                return true;
        } catch (luabridge::LuaException const& e) {
                cerr << "LuaException:" << e.what () << endl;
        } catch (...) { }
-       set_dirty ();
        return false;
 }
 
@@ -1750,9 +1755,9 @@ LuaInstance::unregister_lua_slot (const PBD::ID& id)
        if (i != _callbacks.end()) {
                SlotChanged (id, "", ActionHook()); /* EMIT SIGNAL */
                _callbacks.erase (i);
+               set_dirty ();
                return true;
        }
-       set_dirty ();
        return false;
 }