use new event loop callback to ensure that all surface/control protocol threads have tempo map ptr set

This commit is contained in:
Paul Davis
2022-05-16 15:24:27 -06:00
parent 968533cc23
commit 9758e6280f
15 changed files with 58 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
#include "pbd/convert.h"
#include "pbd/error.h"
#include "pbd/pthread_utils.h"
#include "temporal/superclock.h"
#include "temporal/tempo.h"
@@ -65,6 +66,7 @@ const std::string ControlProtocol::state_node_name ("Protocol");
ControlProtocol::ControlProtocol (Session& s, string str)
: BasicUI (s)
, _name (str)
, glib_event_callback (boost::bind (&ControlProtocol::event_loop_precall, this))
, _active (false)
{
if (!selection_connected) {
@@ -78,6 +80,19 @@ ControlProtocol::~ControlProtocol ()
{
}
void
ControlProtocol::event_loop_precall ()
{
/* reload the thread-local ptr to the tempo map */
Temporal::TempoMap::fetch ();
}
void
ControlProtocol::install_precall_handler (Glib::RefPtr<Glib::MainContext> context)
{
glib_event_callback.attach (context);
}
int
ControlProtocol::set_active (bool yn)
{

View File

@@ -30,6 +30,7 @@
#include "pbd/signals.h"
#include "pbd/stateful.h"
#include "pbd/glib_event_source.h"
#include "control_protocol/basic_ui.h"
#include "control_protocol/types.h"
@@ -147,6 +148,9 @@ protected:
std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
std::string _name;
GlibEventLoopCallback glib_event_callback;
virtual void event_loop_precall ();
void install_precall_handler (Glib::RefPtr<Glib::MainContext>);
private:
LIBCONTROLCP_LOCAL ControlProtocol (const ControlProtocol&); /* noncopyable */
@@ -184,4 +188,17 @@ public:
}
}
/* this is where the strange inheritance pattern hits the wall. A control
protocol thread/event loop is inherited from AbstractUI, but the precall
handler is inherited from ControlProtocol. When the AbstractUI sets up the
event loop, it will call attach_request_source() which will in turn pass a
Glib::MainContext to maybe_install_precall_handler(). We override the
definition of that method here to make it actuall install the
ControlProtocol's handler.
*/
#define CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL() \
void maybe_install_precall_handler (Glib::RefPtr<Glib::MainContext> ctxt) { install_precall_handler (ctxt); }
#endif // ardour_control_protocols_h