13
0

Add a 1Hz Lua Callback Signal

This commit is contained in:
Robin Gareus 2018-11-17 00:12:10 +01:00
parent 9b3fd34b6b
commit 821ab4aae2
3 changed files with 14 additions and 1 deletions

View File

@ -512,6 +512,7 @@ lua_translate_order (RouteDialogs::InsertAt place)
using namespace ARDOUR; using namespace ARDOUR;
PBD::Signal0<void> LuaInstance::LuaTimerS;
PBD::Signal0<void> LuaInstance::LuaTimerDS; PBD::Signal0<void> LuaInstance::LuaTimerDS;
PBD::Signal0<void> LuaInstance::SetSession; PBD::Signal0<void> LuaInstance::SetSession;
@ -1341,6 +1342,7 @@ void LuaInstance::set_session (Session* s)
for (LuaCallbackMap::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i) { for (LuaCallbackMap::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i) {
i->second->set_session (s); 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)); point_one_second_connection = Timers::rapid_connect (sigc::mem_fun(*this, & LuaInstance::every_point_one_seconds));
SetSession (); /* EMIT SIGNAL */ SetSession (); /* EMIT SIGNAL */
} }
@ -1349,6 +1351,7 @@ void
LuaInstance::session_going_away () LuaInstance::session_going_away ()
{ {
ENSURE_GUI_THREAD (*this, &LuaInstance::session_going_away); ENSURE_GUI_THREAD (*this, &LuaInstance::session_going_away);
second_connection.disconnect ();
point_one_second_connection.disconnect (); point_one_second_connection.disconnect ();
(*_lua_clear)(); (*_lua_clear)();
@ -1363,6 +1366,12 @@ LuaInstance::session_going_away ()
lua.do_command ("collectgarbage();"); lua.do_command ("collectgarbage();");
} }
void
LuaInstance::every_second ()
{
LuaTimerS (); // emit signal
}
void void
LuaInstance::every_point_one_seconds () LuaInstance::every_point_one_seconds ()
{ {

View File

@ -126,6 +126,7 @@ public:
bool lua_slot (const PBD::ID&, std::string&, std::string&, ActionHook&, ARDOUR::LuaScriptParamList&); bool lua_slot (const PBD::ID&, std::string&, std::string&, ActionHook&, ARDOUR::LuaScriptParamList&);
sigc::signal<void,PBD::ID,std::string,ActionHook> SlotChanged; sigc::signal<void,PBD::ID,std::string,ActionHook> SlotChanged;
static PBD::Signal0<void> LuaTimerS; // deci-seconds (Timer every 1s)
static PBD::Signal0<void> LuaTimerDS; // deci-seconds (Timer every .1s) static PBD::Signal0<void> LuaTimerDS; // deci-seconds (Timer every .1s)
static PBD::Signal0<void> SetSession; // emitted when a session is loaded static PBD::Signal0<void> SetSession; // emitted when a session is loaded
@ -152,6 +153,9 @@ private:
LuaCallbackMap _callbacks; LuaCallbackMap _callbacks;
PBD::ScopedConnectionList _slotcon; PBD::ScopedConnectionList _slotcon;
void every_second ();
sigc::connection second_connection;
void every_point_one_seconds (); void every_point_one_seconds ();
sigc::connection point_one_second_connection; sigc::connection point_one_second_connection;
}; };

View File

@ -21,7 +21,6 @@
STATIC(SessionLoad, &, 0) STATIC(SessionLoad, &, 0)
STATIC(SessionClose, &, 0) STATIC(SessionClose, &, 0)
#endif #endif
//STATIC(EverySecond, get_timers().second, 0) // XXX
STATIC(ConfigChanged, &ARDOUR::Config->ParameterChanged, 1) STATIC(ConfigChanged, &ARDOUR::Config->ParameterChanged, 1)
// engine instance // engine instance
@ -85,6 +84,7 @@ STATIC(DiskUnderrun, &ARDOUR::DiskReader::Underrun, 0)
STATIC(RegionPropertyChanged, &ARDOUR::Region::RegionPropertyChanged, 2) STATIC(RegionPropertyChanged, &ARDOUR::Region::RegionPropertyChanged, 2)
// Timers // Timers
STATIC(LuaTimerS, &LuaInstance::LuaTimerS, 0)
STATIC(LuaTimerDS, &LuaInstance::LuaTimerDS, 0) STATIC(LuaTimerDS, &LuaInstance::LuaTimerDS, 0)
// Session load // Session load