From ce7ea4ec36d6b6f1d51c2b42e305691d2e3d3cfc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 29 Nov 2020 12:46:53 -0700 Subject: [PATCH] Use glib event callback in Mackie Control support to set thread-local variables --- libs/surfaces/control_protocol/control_protocol.cc | 11 +++++++++++ .../control_protocol/control_protocol.h | 2 ++ libs/surfaces/mackie/mackie_control_protocol.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index 292c2f3a51..2895c33e9e 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -22,6 +22,9 @@ #include "pbd/convert.h" #include "pbd/error.h" +#include "temporal/superclock.h" +#include "temporal/tempo.h" + #include "ardour/control_protocol_manager.h" #include "ardour/gain_control.h" #include "ardour/session.h" @@ -376,3 +379,11 @@ ControlProtocol::notify_stripable_selection_changed (StripableNotificationListPt { _last_selected = *sp; } + +void +ControlProtocol::event_loop_precall () +{ + Temporal::set_thread_sample_rate (session->sample_rate()); + Temporal::TempoMap::fetch (); +} + diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index 8f86235c83..9f0432f403 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -141,6 +141,8 @@ public: static StripableNotificationList const& last_selected () { return _last_selected; } static void notify_stripable_selection_changed (StripableNotificationListPtr); + void event_loop_precall (); + protected: void next_track (uint32_t initial_id); void prev_track (uint32_t initial_id); diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index e2028b7f4e..a0326a790e 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -276,6 +276,8 @@ class MackieControlProtocol bool stripable_is_locked_to_strip (boost::shared_ptr) const; + void event_loop_precall () { ControlProtocol::event_loop_precall(); } + private: struct ButtonHandlers {