diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 826834b208..0db7e705e2 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -212,6 +212,8 @@ public: bool clear_xrun_markers (); bool clear_ranges (); + void clear_cue_markers (samplepos_t start, samplepos_t end); + void ripple (timepos_t const & at, timecnt_t const & distance, bool include_locked, bool notify); XMLNode& get_state (void); diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index e6313d3ebb..b73f0bf2ad 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -1622,3 +1622,54 @@ Locations::ripple (timepos_t const & at, timecnt_t const & distance, bool includ changed(); /* EMIT SIGNAL */ } } + +void +Locations::clear_cue_markers (samplepos_t start, samplepos_t end) +{ + TempoMap::SharedPtr tmap (TempoMap::use()); + Temporal::Beats sb; + Temporal::Beats eb; + bool have_beats = false; + vector r; + + + { + Glib::Threads::RWLock::WriterLock lm (_lock); + + for (LocationList::iterator i = locations.begin(); i != locations.end(); ) { + + if ((*i)->is_cue_marker()) { + Location* l (*i); + + if (l->start().time_domain() == AudioTime) { + samplepos_t when = l->start().samples(); + if (when >= start && when < end) { + i = locations.erase (i); + r.push_back (l); + continue; + } + } else { + if (!have_beats) { + sb = tmap->quarters_at (timepos_t (start)); + eb = tmap->quarters_at (timepos_t (end)); + have_beats = true; + } + + Temporal::Beats when = l->start().beats(); + if (when >= sb && when < eb) { + r.push_back (l); + i = locations.erase (i); + continue; + } + } + } + + ++i; + } + } /* end lock scope */ + + for (auto & l : r) { + removed (l); /* EMIT SIGNAL */ + delete l; + } +} diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index dad51ea53c..d3452a2b5a 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -1355,6 +1355,11 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) auditioner->cancel_audition (); } + /* This must be called while _transport_sample still reflects where we stopped + */ + + flush_cue_recording (); + if (did_record) { begin_reversible_command (Operations::capture); _have_captured = true; @@ -1476,7 +1481,6 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) clear_clicks(); unset_preroll_record_trim (); - flush_cue_recording (); /* do this before seeking, because otherwise the tracks will do the wrong thing in seamless loop mode. */ @@ -2084,9 +2088,15 @@ Session::actual_speed() const void Session::flush_cue_recording () { + if (!TriggerBox::cue_records.read_space()) { + return; + } + CueRecord cr; TempoMap::SharedPtr tmap (TempoMap::use()); + _locations->clear_cue_markers (_last_roll_location, _transport_sample); + while (TriggerBox::cue_records.read (&cr, 1) == 1) { BBT_Time bbt = tmap->bbt_at (timepos_t (cr.when)); bbt = bbt.round_up_to_bar ();