From 3bfcfe178ddcbc27722ce821fafc02ea8d41fb1f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 19 Feb 2022 08:53:30 -0700 Subject: [PATCH] triggerbox: some work towards keeping GUI state in sync with "Play Cues" This still needs some mechanism to request a fast-forward when "Play Cues" is enabled in a (G)UI thread --- libs/ardour/ardour/triggerbox.h | 3 ++ libs/ardour/triggerbox.cc | 62 +++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 718c854689..602c125dfc 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -780,6 +780,7 @@ class LIBARDOUR_API TriggerBox : public Processor int32_t _active_slots; bool _ignore_patch_changes; bool _locate_armed; + bool _cancel_locate_armed; bool _fast_fowarding; boost::shared_ptr _sidechain; @@ -840,6 +841,8 @@ class LIBARDOUR_API TriggerBox : public Processor void reload (BufferSet& bufs, int32_t slot, void* ptr); + void cancel_locate_armed (); + PBD::ScopedConnection stop_all_connection; static void init_pool(); diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 5bc2ba18fa..3846ff45db 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2627,6 +2627,7 @@ TriggerBox::TriggerBox (Session& s, DataType dt) , _active_slots (0) , _ignore_patch_changes (false) , _locate_armed (false) + , _cancel_locate_armed (false) , _fast_fowarding (false) , requests (1024) @@ -2672,14 +2673,54 @@ TriggerBox::set_ignore_patch_changes (bool yn) } } +void +TriggerBox::parameter_changed (std::string const & param) +{ + if (param == X_("default-trigger-input-port")) { + + reconnect_to_default (); + + } else if (param == "cue-behavior") { + bool follow = (Config->get_cue_behavior() & FollowCues); + if (follow) { + + /* XXX this is all wrong. We have to do the + * fast_forward() call from something like the butler + * thread, as we do when a locate happens (and we are + * following cues). + * + * FIX ME. + */ + + if (!_session.transport_state_rolling()) { + fast_forward (_session.cue_events(), _session.transport_sample()); + } + } else { + cancel_locate_armed (); + } + } +} + +void +TriggerBox::cancel_locate_armed () +{ + _cancel_locate_armed = true; +} + void TriggerBox::fast_forward (CueEvents const & cues, samplepos_t transport_position) { DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1: ffwd to %2\n", order(), transport_position)); - if (cues.empty() || !(Config->get_cue_behavior() & FollowCues) || (cues.front().time > transport_position)) { + + if (!(Config->get_cue_behavior() & FollowCues)) { + /* do absolutely nothing */ + return; + } + + if (cues.empty() || (cues.front().time > transport_position)) { DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1: nothing to be done, cp = %2\n", order(), _currently_playing)); _locate_armed = false; - _currently_playing = 0; + cancel_locate_armed (); if (tracker) { tracker->reset (); } @@ -3459,6 +3500,15 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp stop_all (); } + if (_locate_armed && _cancel_locate_armed) { + if (_currently_playing) { + _currently_playing->shutdown (bufs, 0); + _currently_playing = 0; + PropertyChanged (Properties::currently_playing); + } + _cancel_locate_armed = false; + } + /* STEP TEN: nothing to do? */ @@ -3928,14 +3978,6 @@ TriggerBox::set_state (const XMLNode& node, int version) return 0; } -void -TriggerBox::parameter_changed (std::string const & param) -{ - if (param == X_("default-trigger-input-port")) { - reconnect_to_default (); - } -} - void TriggerBox::reconnect_to_default () {