diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 7569094a31..5d1b5bed90 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -195,7 +195,7 @@ public: * * @return New location object */ - Location* add_range (samplepos_t start, samplepos_t end); + Location* add_range (timepos_t const & start, timepos_t const & end); void remove (Location *); bool clear (); @@ -237,7 +237,7 @@ public: * * @return Location object or nil */ - Location* range_starts_at(samplepos_t, samplecnt_t slop = 0, bool incl = false) const; + Location* range_starts_at (timepos_t const &, timecnt_t const & slop = timecnt_t (Temporal::AudioTime), bool incl = false) const; void find_all_between (timepos_t const & start, timepos_t const & end, LocationList&, Location::Flags); diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index d68dc24247..206b1e639b 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -982,7 +982,7 @@ Locations::add (Location *loc, bool make_current) } Location* -Locations::add_range(samplepos_t start, samplepos_t end) +Locations::add_range (timepos_t const & start, timepos_t const & end) { string name; next_available_name(name, _("range")); @@ -1482,10 +1482,10 @@ Locations::find_all_between (timepos_t const & start, timepos_t const & end, Loc } Location * -Locations::range_starts_at(samplepos_t pos, samplecnt_t slop, bool incl) const +Locations::range_starts_at (timepos_t const & pos, timecnt_t const & slop, bool incl) const { Location *closest = 0; - sampleoffset_t mindelta = max_samplepos; + timecnt_t mindelta = timecnt_t (pos.time_domain()); Glib::Threads::RWLock::ReaderLock lm (_lock); for (LocationList::const_iterator i = locations.begin(); i != locations.end(); ++i) { @@ -1497,9 +1497,9 @@ Locations::range_starts_at(samplepos_t pos, samplecnt_t slop, bool incl) const continue; } - sampleoffset_t delta = std::abs((double)(pos - (*i)->start())); + timecnt_t delta = (*i)->start().distance (pos).abs (); - if (delta == 0) { + if (delta.zero()) { return *i; }