13
0

add a lua timer callback signal

This commit is contained in:
Robin Gareus 2016-07-22 14:42:38 +02:00
parent 299709cbbc
commit bcee4e1518
4 changed files with 21 additions and 1 deletions

View File

@ -40,6 +40,7 @@
#include "time_axis_view.h" #include "time_axis_view.h"
#include "selection.h" #include "selection.h"
#include "script_selector.h" #include "script_selector.h"
#include "timers.h"
#include "utils_videotl.h" #include "utils_videotl.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -355,6 +356,8 @@ const char *luasignalstr[] = {
using namespace ARDOUR; using namespace ARDOUR;
PBD::Signal0<void> LuaInstance::LuaTimerDS;
void void
LuaInstance::register_hooks (lua_State* L) LuaInstance::register_hooks (lua_State* L)
{ {
@ -986,12 +989,15 @@ 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);
} }
point_one_second_connection = Timers::rapid_connect (sigc::mem_fun(*this, & LuaInstance::every_point_one_seconds));
} }
void 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);
point_one_second_connection.disconnect ();
(*_lua_clear)(); (*_lua_clear)();
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
ActionChanged (i, ""); /* EMIT SIGNAL */ ActionChanged (i, ""); /* EMIT SIGNAL */
@ -1004,6 +1010,12 @@ LuaInstance::session_going_away ()
lua.do_command ("collectgarbage();"); lua.do_command ("collectgarbage();");
} }
void
LuaInstance::every_point_one_seconds ()
{
LuaTimerDS (); // emit signal
}
int int
LuaInstance::set_state (const XMLNode& node) LuaInstance::set_state (const XMLNode& node)
{ {

View File

@ -112,6 +112,8 @@ 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> LuaTimerDS; // deci-seconds (Timer every .1s)
private: private:
LuaInstance(); LuaInstance();
static LuaInstance* _instance; static LuaInstance* _instance;
@ -132,6 +134,9 @@ private:
LuaCallbackMap _callbacks; LuaCallbackMap _callbacks;
PBD::ScopedConnectionList _slotcon; PBD::ScopedConnectionList _slotcon;
void every_point_one_seconds ();
sigc::connection point_one_second_connection;
}; };
#endif #endif

View File

@ -83,6 +83,9 @@ STATIC(DiskUnderrun, &ARDOUR::Diskstream::DiskUnderrun, 0)
// Region static // Region static
STATIC(RegionPropertyChanged, &ARDOUR::Region::RegionPropertyChanged, 2) STATIC(RegionPropertyChanged, &ARDOUR::Region::RegionPropertyChanged, 2)
// Timers
STATIC(LuaTimerDS, &LuaInstance::LuaTimerDS, 0)
// TODO per track/route signals, // TODO per track/route signals,
// TODO per plugin actions / controllables // TODO per plugin actions / controllables
// TODO per region actions // TODO per region actions

View File

@ -155,7 +155,7 @@ namespace Cairo {
CLASSKEYS(Cairo::Context); CLASSKEYS(Cairo::Context);
CLASSKEYS(std::vector<double>); CLASSKEYS(std::vector<double>);
CLASSKEYS(std::list<ArdourMarker*>); CLASSKEYS(std::list<ArdourMarker*>);
CLASSKEYS(std::bitset<46ul>); // LuaSignal::LAST_SIGNAL CLASSKEYS(std::bitset<47ul>); // LuaSignal::LAST_SIGNAL
CLASSKEYS(ArdourMarker*); CLASSKEYS(ArdourMarker*);
CLASSKEYS(ARDOUR::RouteGroup); CLASSKEYS(ARDOUR::RouteGroup);
CLASSKEYS(ARDOUR::LuaProc); CLASSKEYS(ARDOUR::LuaProc);