triggerbox: use regular transport request mechanism to get transport started

if a slot becomes active, and the transport is not rolling, it still
asks the transport to roll. however, (1) there's only 1 request across
all triggerboxen (2) the request will not be handled till the next
process cycle (3) the triggerbox returns after the request i.e. it
waits until the transport is rolling
This commit is contained in:
Paul Davis 2022-06-10 11:59:12 -06:00
parent 52047e108d
commit 6bef80ae60
5 changed files with 28 additions and 13 deletions

View File

@ -489,8 +489,6 @@ public:
double default_play_speed ();
void reset_transport_speed (TransportRequestSource origin = TRS_UI);
void start_transport_from_trigger ();
void stop_all_triggers (bool now = true);
void request_transport_speed (double speed, TransportRequestSource origin = TRS_UI);

View File

@ -793,6 +793,7 @@ class LIBARDOUR_API TriggerBox : public Processor
static void set_first_midi_note (int n);
static void init ();
static void begin_process_cycle ();
static TriggerBoxThread* worker;
@ -895,6 +896,8 @@ class LIBARDOUR_API TriggerBox : public Processor
static std::atomic<int> active_trigger_boxes;
static std::atomic<bool> _cue_recording;
static bool roll_requested;
static void maybe_request_roll (Session&);
};
class TriggerReference

View File

@ -401,6 +401,7 @@ Session::process_with_events (pframes_t nframes)
immediate_events.pop_front ();
process_event (ev);
}
/* only count-in when going to roll at speed 1.0 */
if (_transport_fsm->transport_speed() != 1.0 && _count_in_samples > 0) {
_count_in_samples = 0;
@ -413,6 +414,7 @@ Session::process_with_events (pframes_t nframes)
// DEBUG_TRACE (DEBUG::Transport, string_compose ("Running count in/latency preroll of %1 & %2\n", _count_in_samples, _remaining_latency_preroll));
TriggerBox::begin_process_cycle();
maybe_find_pending_cue ();
while (_count_in_samples > 0 || _remaining_latency_preroll > 0) {
@ -720,6 +722,7 @@ Session::process_without_events (pframes_t nframes)
click (_transport_sample, nframes);
TriggerBox::begin_process_cycle();
maybe_find_pending_cue ();
if (process_routes (nframes, session_needs_butler)) {
@ -1721,6 +1724,7 @@ void
Session::cue_bang (int32_t cue)
{
_pending_cue.store (cue);
request_transport_speed (1.0);
}
void

View File

@ -462,14 +462,6 @@ Session::stop_transport (bool abort, bool clear_state)
realtime_stop (abort, clear_state);
}
/** Called from the process thread */
void
Session::start_transport_from_trigger ()
{
ENSURE_PROCESS_THREAD;
TFSM_ROLL();
}
/** Called from the process thread */
void
Session::start_transport (bool after_loop)

View File

@ -2854,6 +2854,7 @@ TriggerBoxThread* TriggerBox::worker = 0;
CueRecords TriggerBox::cue_records (256);
std::atomic<bool> TriggerBox::_cue_recording (false);
PBD::Signal0<void> TriggerBox::CueRecordingChanged;
bool TriggerBox::roll_requested = false;
typedef std::map <boost::shared_ptr<Region>, boost::shared_ptr<Trigger::UIState>> RegionStateMap;
RegionStateMap enqueued_state_map;
@ -3603,6 +3604,21 @@ TriggerBox::process_midi_trigger_requests (BufferSet& bufs)
}
}
void
TriggerBox::maybe_request_roll (Session& s)
{
if (!roll_requested) {
s.request_roll ();
}
}
void
TriggerBox::begin_process_cycle ()
{
roll_requested = false;
}
void
TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required)
{
@ -3672,11 +3688,11 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
_currently_playing->unbang ();
}
_locate_armed = 0;
_locate_armed = false;
} else if (cue_bang >= 0) {
_active_scene = cue_bang;
_locate_armed = 0;
_locate_armed = false;
}
}
@ -3797,7 +3813,9 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
if (!_locate_armed) {
if (!_session.transport_state_rolling() && !allstop) {
_session.start_transport_from_trigger ();
assert (_currently_playing->state() == Trigger::WaitingToStart);
maybe_request_roll (_session);
return;
}
} else {