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

@ -162,6 +162,8 @@ class CC121 : public ARDOUR::ControlProtocol, public AbstractUI<CC121Request> {
std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
boost::shared_ptr<ARDOUR::Stripable> _current_stripable;
boost::weak_ptr<ARDOUR::Stripable> pre_master_stripable;

View file

@ -128,6 +128,8 @@ public:
PBD::Signal1<void, unsigned short> ButtonPress;
PBD::Signal1<void, unsigned short> ButtonRelease;
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
void do_request (ContourDesignControlUIRequest*);
void start ();

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

View file

@ -162,6 +162,8 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
boost::shared_ptr<ARDOUR::Stripable> _current_stripable;
boost::weak_ptr<ARDOUR::Stripable> pre_master_stripable;

View file

@ -108,6 +108,8 @@ public:
size_t tx_midi (std::vector<uint8_t> const&) const;
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
void close ();

View file

@ -128,6 +128,8 @@ public:
PBD::Signal0<void> ConnectionChange;
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
boost::shared_ptr<ARDOUR::Bundle> _input_bundle;
boost::shared_ptr<ARDOUR::Bundle> _output_bundle;

View file

@ -411,6 +411,8 @@ public:
void send_bank_switch(bool up);
int send_bank_base () const { return _send_bank_base; }
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
bool in_use;
TrackMode _track_mode;

View file

@ -276,6 +276,8 @@ class MackieControlProtocol
bool stripable_is_locked_to_strip (boost::shared_ptr<ARDOUR::Stripable>) const;
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
struct ButtonHandlers {

View file

@ -85,6 +85,8 @@ class Maschine2: public ARDOUR::ControlProtocol, public AbstractUI<Maschine2Requ
Studio
} Maschine2Type;
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
void do_request (Maschine2Request*);

View file

@ -262,6 +262,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
std::string get_remote_port () { return remote_port; }
void set_remote_port (std::string pt) { remote_port = pt; }
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
protected:
void thread_init ();
void do_request (OSCUIRequest*);

View file

@ -362,6 +362,8 @@ class Push2 : public ARDOUR::ControlProtocol
libusb_device_handle* usb_handle() const { return handle; }
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
private:
libusb_device_handle *handle;
bool in_use;

View file

@ -216,6 +216,8 @@ class US2400Protocol
int get_sends_bank ();
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
protected:
// shut down the surface
void close();

View file

@ -85,6 +85,8 @@ public:
/* ControlProtocol */
void stripable_selection_changed () {}
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
protected:
/* BaseUI */
void thread_init ();

View file

@ -55,6 +55,8 @@ public:
void stripable_selection_changed () {}
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
protected:
void do_request (WiimoteControlUIRequest*);
int start ();