diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index dac9abd903..bca14616b8 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -221,12 +221,12 @@ public: int set_current (Location *, bool want_lock = true); Location *current () const { return current_location; } - Location* mark_at (samplepos_t, samplecnt_t slop = 0) const; + Location* mark_at (timepos_t const &, timecnt_t const & slop = timecnt_t::zero (Temporal::AudioTime)) 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); + timepos_t first_mark_before (timepos_t const &, bool include_special_ranges = false); + timepos_t first_mark_after (timepos_t const &, bool include_special_ranges = false); void marks_either_side (timepos_t const &, timepos_t &, timepos_t &) const; diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 7a5921ba5d..f5dde17804 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -428,7 +428,7 @@ Location::set_is_clock_origin (bool yn, void*) void Location::set_skip (bool yn) { - if (is_range_marker() && length_samples() > 0) { + if (is_range_marker() && length().positive()) { if (set_flag_internal (yn, IsSkip)) { flags_changed (this); FlagsChanged (); @@ -439,7 +439,7 @@ Location::set_skip (bool yn) void Location::set_skipping (bool yn) { - if (is_range_marker() && is_skip() && length_samples() > 0) { + if (is_range_marker() && is_skip() && length().positive()) { if (set_flag_internal (yn, IsSkipping)) { flags_changed (this); FlagsChanged (); @@ -1189,7 +1189,7 @@ Locations::set_state (const XMLNode& node, int version) } -typedef std::pair LocationPair; +typedef std::pair LocationPair; struct LocationStartEarlierComparison { @@ -1205,8 +1205,8 @@ struct LocationStartLaterComparison } }; -samplepos_t -Locations::first_mark_before (samplepos_t sample, bool include_special_ranges) +timepos_t +Locations::first_mark_before (timepos_t const & pos, bool include_special_ranges) { vector locs; { @@ -1232,20 +1232,20 @@ Locations::first_mark_before (samplepos_t sample, bool include_special_ranges) if (!include_special_ranges && ((*i).second->is_auto_loop() || (*i).second->is_auto_punch())) { continue; } - if ((*i).first < sample) { + if ((*i).first < pos) { return (*i).first; } } - return -1; + return timepos_t::max (pos.time_domain()); } Location* -Locations::mark_at (samplepos_t pos, samplecnt_t slop) const +Locations::mark_at (timepos_t const & pos, timecnt_t const & slop) const { Location* closest = 0; - sampleoffset_t mindelta = max_samplepos; - sampleoffset_t delta; + timecnt_t mindelta = timecnt_t::max (pos.time_domain()); + timecnt_t delta; /* locations are not necessarily stored in linear time order so we have * to iterate across all of them to find the one closest to a give point. @@ -1255,13 +1255,13 @@ Locations::mark_at (samplepos_t pos, samplecnt_t slop) const for (LocationList::const_iterator i = locations.begin(); i != locations.end(); ++i) { if ((*i)->is_mark()) { - if (pos > (*i)->start_sample()) { - delta = pos - (*i)->start_sample(); + if (pos > (*i)->start()) { + delta = (*i)->start().distance (pos); } else { - delta = (*i)->start_sample() - pos; + delta = pos.distance ((*i)->start()); } - if (slop == 0 && delta == 0) { + if (slop.zero() && delta.zero()) { /* special case: no slop, and direct hit for position */ return *i; } @@ -1278,8 +1278,8 @@ Locations::mark_at (samplepos_t pos, samplecnt_t slop) const return closest; } -samplepos_t -Locations::first_mark_after (samplepos_t sample, bool include_special_ranges) +timepos_t +Locations::first_mark_after (timepos_t const & pos, bool include_special_ranges) { vector locs; @@ -1287,9 +1287,9 @@ Locations::first_mark_after (samplepos_t sample, bool include_special_ranges) Glib::Threads::RWLock::ReaderLock lm (_lock); for (LocationList::iterator i = locations.begin(); i != locations.end(); ++i) { - locs.push_back (make_pair ((*i)->start_sample(), (*i))); + locs.push_back (make_pair ((*i)->start(), (*i))); if (!(*i)->is_mark()) { - locs.push_back (make_pair ((*i)->end_sample(), (*i))); + locs.push_back (make_pair ((*i)->end(), (*i))); } } } @@ -1306,12 +1306,12 @@ Locations::first_mark_after (samplepos_t sample, bool include_special_ranges) if (!include_special_ranges && ((*i).second->is_auto_loop() || (*i).second->is_auto_punch())) { continue; } - if ((*i).first > sample) { + if ((*i).first > pos) { return (*i).first; } } - return -1; + return timepos_t::max (pos.time_domain()); } /** Look for the `marks' (either locations which are marks, or start/end points of range markers) either diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 899e3b95eb..36ef17b38e 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -535,7 +535,7 @@ MidiRegion::fix_negative_start () model()->insert_silence_at_start (-_start.val().beats()); - _start = timecnt_t::zero_at (_start.val().time_domain(), nt_position()); + _start = timecnt_t::zero (_start.val().time_domain()); } bool diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc index b0bad8cf7c..611ae4b339 100644 --- a/libs/ardour/midi_scene_changer.cc +++ b/libs/ardour/midi_scene_changer.cc @@ -302,7 +302,7 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program /* check for marker at current location */ - loc = locations->mark_at (time, Config->get_inter_scene_gap_samples()); + loc = locations->mark_at (timepos_t (time), timecnt_t (Config->get_inter_scene_gap_samples())); if (!loc) { /* create a new marker at the desired position */ diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 64df7aba62..28e6bddf41 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -399,7 +399,7 @@ SourceFactory::createFromPlaylist (DataType type, Session& s, boost::shared_ptr< if (copy) { ap.reset (new AudioPlaylist (ap, start, len, name, true)); - start = timecnt_t::zero_at (Temporal::AudioTime, timepos_t::zero (Temporal::AudioTime)); + start = timecnt_t::zero (Temporal::AudioTime); } Source* src = new AudioPlaylistSource (s, orig, name, ap, chn, start, len, Source::Flag (0));