diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 3e703fd3d4..0cbea5c356 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -69,6 +69,7 @@ public: IsXrun = 0x400, IsCueMarker = 0x800, IsSection = 0x1000, + IsScene = 0x2000 }; Location (Session &); @@ -125,6 +126,7 @@ public: bool is_skipping() const { return (_flags & IsSkip) && (_flags & IsSkipping); } bool is_xrun() const { return _flags & IsXrun; } bool is_section() const { return _flags & IsSection; } + bool is_scene() const { return (bool) _scene_change && _flags & IsScene; } bool matches (Flags f) const { return _flags & f; } /* any range with start < end -- not a marker */ @@ -274,6 +276,7 @@ public: bool clear_ranges (); bool clear_cue_markers (samplepos_t start, samplepos_t end); + bool clear_scene_markers (samplepos_t start, samplepos_t end); void cut_copy_section (timepos_t const& start, timepos_t const& end, timepos_t const& to, SectionOperation const op); diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index ec7764a498..84f872f8ce 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -612,6 +612,7 @@ setup_enum_writer () REGISTER_CLASS_ENUM (Location, IsXrun); REGISTER_CLASS_ENUM (Location, IsCueMarker); REGISTER_CLASS_ENUM (Location, IsSection); + REGISTER_CLASS_ENUM (Location, IsScene); REGISTER_BITS (_Location_Flags); REGISTER_CLASS_ENUM (Track, NoFreeze); diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 7e1404e27d..f05585c84c 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -801,6 +801,11 @@ Location::set_scene_change (std::shared_ptr sc) { if (_scene_change != sc) { _scene_change = sc; + if (_scene_change) { + _flags = Flags (_flags | IsScene); + } else { + _flags = Flags (_flags & ~IsScene); + } _session.set_dirty (); emit_signal (Scene); /* EMIT SIGNAL */ } @@ -2046,6 +2051,60 @@ Locations::clear_cue_markers (samplepos_t start, samplepos_t end) return removed_at_least_one; } +bool +Locations::clear_scene_markers (samplepos_t start, samplepos_t end) +{ + TempoMap::SharedPtr tmap (TempoMap::use()); + Temporal::Beats sb; + Temporal::Beats eb; + bool have_beats = false; + vector r; + bool removed_at_least_one = false; + + { + Glib::Threads::RWLock::WriterLock lm (_lock); + + for (LocationList::iterator i = locations.begin(); i != locations.end(); ) { + + if ((*i)->is_scene()) { + 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; + } + } + removed_at_least_one = true; + } + + ++i; + } + } /* end lock scope */ + + for (auto & l : r) { + removed (l); /* EMIT SIGNAL */ + delete l; + } + + return removed_at_least_one; +} + void Locations::start_domain_bounce (Temporal::DomainBounceInfo& cmd) {