diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 842c100302..8ca1665127 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -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 const &); }; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 0c0db14c97..2c3fb69a7d 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -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())); diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 514e2dca12..f66ae0f6ab 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -1074,6 +1074,30 @@ Session::process_event (SessionEvent* ev) } } +void +Session::handle_slots_empty_status (boost::weak_ptr const & wr) +{ + boost::shared_ptr 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 (); }