From 65aa619e583ca00af9f02226e34b3ffabfecd6ea Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Dec 2020 21:33:35 -0700 Subject: [PATCH] changes required by fixing ambiguities in timepos_t/timecnt_t API (libs edition) --- libs/ardour/ardour/midi_cursor.h | 3 ++- libs/ardour/auditioner.cc | 2 +- libs/ardour/automatable.cc | 2 +- libs/ardour/playlist.cc | 30 ++++++++++++++++-------------- libs/ardour/region.cc | 10 +++++----- libs/ardour/source.cc | 4 ++-- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/libs/ardour/ardour/midi_cursor.h b/libs/ardour/ardour/midi_cursor.h index b8c0534b0e..31de33e690 100644 --- a/libs/ardour/ardour/midi_cursor.h +++ b/libs/ardour/ardour/midi_cursor.h @@ -45,7 +45,8 @@ struct MidiCursor : public boost::noncopyable { void invalidate(bool preserve_notes) { iter.invalidate(preserve_notes ? &active_notes : NULL); - last_read_end = 0; +#warning NUTEMPO this locks last_read_end to BeatTime which may not be good + last_read_end = Temporal::timepos_t (Temporal::BeatTime); } Evoral::Sequence::const_iterator iter; diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index fb713d8a75..ad6ba96a6e 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -400,7 +400,7 @@ Auditioner::audition_region (boost::shared_ptr region) /* can't audition from a negative sync point */ if (dir < 0) { - offset = 0; + offset = timecnt_t (Temporal::AudioTime); } _disk_reader->seek (offset.samples(), true); diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index 741261d5d7..cdb7ee5c52 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -641,7 +641,7 @@ Automatable::clear_controls () bool Automatable::find_next_event (timepos_t const & start, timepos_t const & end, Evoral::ControlEvent& next_event, bool only_active) const { - next_event.when = start <= end ? std::numeric_limits::max() : 0; + next_event.when = start <= end ? timepos_t::max (start.time_domain()) : timepos_t (start.time_domain()); if (only_active) { boost::shared_ptr cl = _automated_controls.reader (); diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 772eb93838..fa55174dff 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -237,24 +237,24 @@ Playlist::Playlist (boost::shared_ptr other, timepos_t const & s case Temporal::OverlapInternal: offset = region->position().distance (start); - position = 0; + position = timepos_t (start.time_domain()); len = timecnt_t (cnt); break; case Temporal::OverlapStart: - offset = 0; + offset = timecnt_t (start.time_domain()); position = region->source_position(); len = region->position().distance (end); break; case Temporal::OverlapEnd: offset = region->position().distance (start); - position = 0; + position = timepos_t (start.time_domain()); len = region->length() - offset; break; case Temporal::OverlapExternal: - offset = 0; + offset = timecnt_t (start.time_domain()); position = region->source_position(); len = region->length(); break; @@ -340,9 +340,9 @@ Playlist::init (bool hide) subcnt = 0; _frozen = false; _capture_insertion_underway = false; - _combine_ops = 0; - _end_space = 0; - _playlist_shift_active = false; + _combine_ops = 0; + _end_space = timecnt_t (_type == DataType::AUDIO ? Temporal::AudioTime : Temporal::BeatTime); + _playlist_shift_active = false; _session.history ().BeginUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::begin_undo, this)); _session.history ().EndUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::end_undo, this)); @@ -1577,10 +1577,10 @@ Playlist::ripple_unlocked (samplepos_t at, samplecnt_t distance, RegionList* exc if ((*i)->position() >= at) { timepos_t new_pos = (*i)->position() + distance; - timepos_t limit = std::numeric_limits::max().earlier ((*i)->length()); + timepos_t limit = timepos_t::max (new_pos.time_domain()).earlier ((*i)->length()); if (new_pos < 0) { - new_pos = 0; - } else if (new_pos >= limit) { + new_pos = timepos_t (new_pos.time_domain()); + } else if (new_pos >= limit ) { new_pos = limit; } @@ -2404,10 +2404,12 @@ Playlist::get_extent_with_endspace () const pair Playlist::_get_extent () const { - pair ext (std::numeric_limits::max(), std::numeric_limits::min()); +#warning NUTEMPO domain should likely be a playlist property + Temporal::TimeDomain time_domain (_type == DataType::AUDIO ? Temporal::AudioTime : Temporal::BeatTime); + pair ext (timepos_t::max (time_domain), timepos_t (time_domain)); - if (regions.empty ()) { - ext.first = 0; + if (regions.empty()) { + ext.first = timepos_t (time_domain); return ext; } @@ -2686,7 +2688,7 @@ Playlist::nudge_after (timepos_t const & start, timecnt_t const & distance, bool if ((*i)->position() > distance) { new_pos = (*i)->position().earlier (distance); } else { - new_pos = 0; + new_pos = timepos_t ((*i)->position().time_domain());; } } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index c2263677b0..da24c00872 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -745,7 +745,7 @@ Region::nudge_position (timecnt_t const & n) } } else { if (position() < -n) { - new_position = 0; + new_position = timepos_t (_position.val().time_domain()); } else { new_position += n; } @@ -867,7 +867,7 @@ Region::modify_front (timepos_t const & new_position, bool reset_fade) if (position() > start()) { source_zero = source_position (); } else { - source_zero = 0; // its actually negative, but this will work for us + source_zero = timepos_t (source_position().time_domain()); // its actually negative, but this will work for us } if (new_position < last) { /* can't trim it zero or negative length */ @@ -1159,7 +1159,7 @@ Region::adjust_to_sync (timepos_t const & pos) const if (pos > offset) { p.shift_earlier (offset); } else { - p = 0; + p = timepos_t (p.time_domain()); } } else { if (timepos_t::max (p.time_domain()).earlier (timecnt_t (p, p)) > offset) { @@ -2011,7 +2011,7 @@ Region::region_beats_to_absolute_time (Temporal::Beats beats) const /* beats is an additional offset to the start point of the region, from the effective start of the source on the timeline. */ - return source_position() + start () + beats; + return source_position() + start () + timepos_t (beats); } Temporal::timepos_t @@ -2021,7 +2021,7 @@ Region::source_beats_to_absolute_time (Temporal::Beats beats) const the source. The start of the source is an implied position given by region->position - region->start */ - return source_position() + beats; + return source_position() + timepos_t (beats); } Temporal::Beats diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index f2e6c34064..2036f8f6d2 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -180,13 +180,13 @@ Source::set_state (const XMLNode& node, int version) } if (node.get_property ("natural-position", ts)) { - _natural_position = ts; + _natural_position = timepos_t (ts); _have_natural_position = true; } else if (node.get_property ("timeline-position", ts)) { /* some older versions of ardour might have stored this with this property name. */ - _natural_position = ts; + _natural_position = timepos_t (ts); _have_natural_position = true; }