diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 7015047b77..e6f65fc389 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -55,6 +55,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest IsSessionRange = 0x40, IsSkip = 0x80, IsSkipping = 0x100, /* skipping is active (or not) */ + IsClockOrigin = 0x200, }; Location (Session &); @@ -87,6 +88,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest void set_hidden (bool yn, void *src); void set_cd (bool yn, void *src); void set_is_range_marker (bool yn, void* src); + void set_is_clock_origin (bool yn, void* src); void set_skip (bool yn); void set_skipping (bool yn); @@ -98,6 +100,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest bool is_session_range () const { return _flags & IsSessionRange; } bool is_range_marker() const { return _flags & IsRangeMarker; } bool is_skip() const { return _flags & IsSkip; } + bool is_clock_origin() const { return _flags & IsClockOrigin; } bool is_skipping() const { return (_flags & IsSkip) && (_flags & IsSkipping); } bool matches (Flags f) const { return _flags & f; } @@ -189,6 +192,7 @@ class LIBARDOUR_API Locations : public SessionHandleRef, public PBD::StatefulDes Location* auto_loop_location () const; Location* auto_punch_location () const; Location* session_range_location() const; + Location* clock_origin_location() const; int next_available_name(std::string& result,std::string base); uint32_t num_range_markers() const; @@ -198,6 +202,8 @@ class LIBARDOUR_API Locations : public SessionHandleRef, public PBD::StatefulDes Location* mark_at (samplepos_t, samplecnt_t slop = 0) const; + void set_clock_origin (Location*, void *src); + samplepos_t first_mark_before (samplepos_t, bool include_special_ranges = false); samplepos_t first_mark_after (samplepos_t, bool include_special_ranges = false); diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index 09ae6db6b7..7899f8f15f 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -530,6 +530,7 @@ setup_enum_writer () REGISTER_CLASS_ENUM (Location, IsSessionRange); REGISTER_CLASS_ENUM (Location, IsRangeMarker); REGISTER_CLASS_ENUM (Location, IsSkip); + REGISTER_CLASS_ENUM (Location, IsClockOrigin); REGISTER_BITS (_Location_Flags); REGISTER_CLASS_ENUM (TempoSection, Ramp); diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 04e36589ee..24774c5fec 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -478,6 +478,15 @@ Location::set_is_range_marker (bool yn, void*) } } +void +Location::set_is_clock_origin (bool yn, void*) +{ + if (set_flag_internal (yn, IsClockOrigin)) { + flags_changed (this); + FlagsChanged (); /* EMIT SIGNAL */ + } +} + void Location::set_skip (bool yn) { @@ -800,6 +809,20 @@ Locations::set_current (Location *loc, bool want_lock) return ret; } +void +Locations::set_clock_origin (Location* loc, void *src) +{ + LocationList::iterator i; + for (i = locations.begin(); i != locations.end(); ++i) { + if ((*i)->is_clock_origin ()) { + (*i)->set_is_clock_origin (false, src); + } + if (*i == loc) { + (*i)->set_is_clock_origin (true, src); + } + } +} + int Locations::next_available_name(string& result,string base) { @@ -1401,6 +1424,17 @@ Locations::auto_punch_location () const return 0; } +Location* +Locations::clock_origin_location () const +{ + for (LocationList::const_iterator i = locations.begin(); i != locations.end(); ++i) { + if ((*i)->is_clock_origin()) { + return const_cast (*i); + } + } + return session_range_location (); +} + uint32_t Locations::num_range_markers () const {