13
0

triggerbox: track empty slot status and ignore stop-at-session-end when appropriate

This commit is contained in:
Paul Davis 2022-03-14 12:18:20 -06:00
parent a435d4d18e
commit 00d8b08300
3 changed files with 39 additions and 0 deletions

View File

@ -2327,6 +2327,8 @@ private:
void maybe_find_pending_cue ();
void clear_active_cue ();
int tb_with_filled_slots;
void handle_slots_empty_status (boost::weak_ptr<Route> const &);
};

View File

@ -323,6 +323,7 @@ Session::Session (AudioEngine &eng,
, _had_destructive_tracks (false)
, _pending_cue (-1)
, _active_cue (-1)
, tb_with_filled_slots (0)
{
g_atomic_int_set (&_suspend_save, 0);
g_atomic_int_set (&_playback_load, 0);
@ -3244,6 +3245,10 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
}
}
if (r->triggerbox()) {
r->triggerbox()->EmptyStatusChanged.connect_same_thread (*this, boost::bind (&Session::handle_slots_empty_status, this, wpr));
}
if (!r->presentation_info().special (false)) {
DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("checking PI state for %1\n", r->name()));

View File

@ -1074,6 +1074,30 @@ Session::process_event (SessionEvent* ev)
}
}
void
Session::handle_slots_empty_status (boost::weak_ptr<Route> const & wr)
{
boost::shared_ptr<Route> r = wr.lock();
if (!r) {
return;
}
if (r->triggerbox()) {
if (r->triggerbox()->empty()) {
/* signal was emitted, and no slots are used now, so
there was change from >0 slots to 0 slots
*/
tb_with_filled_slots--;
} else {
/* signal was emitted, some slots are used now, so
there was a change from 0 slots to > 0
*/
tb_with_filled_slots++;
}
}
}
samplepos_t
Session::compute_stop_limit () const
{
@ -1099,6 +1123,14 @@ Session::compute_stop_limit () const
return max_samplepos;
}
/* if there are any triggerboxen with slots filled, we ignore the end
* marker
*/
if (tb_with_filled_slots) {
return max_samplepos;
}
return current_end_sample ();
}