changes required by fixing ambiguities in timepos_t/timecnt_t API (libs edition)

This commit is contained in:
Paul Davis 2020-12-03 21:33:35 -07:00
parent c3d325b56a
commit 65aa619e58
6 changed files with 27 additions and 24 deletions

View file

@ -45,7 +45,8 @@ struct MidiCursor : public boost::noncopyable {
void invalidate(bool preserve_notes) { void invalidate(bool preserve_notes) {
iter.invalidate(preserve_notes ? &active_notes : NULL); 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<Temporal::Beats>::const_iterator iter; Evoral::Sequence<Temporal::Beats>::const_iterator iter;

View file

@ -400,7 +400,7 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
/* can't audition from a negative sync point */ /* can't audition from a negative sync point */
if (dir < 0) { if (dir < 0) {
offset = 0; offset = timecnt_t (Temporal::AudioTime);
} }
_disk_reader->seek (offset.samples(), true); _disk_reader->seek (offset.samples(), true);

View file

@ -641,7 +641,7 @@ Automatable::clear_controls ()
bool bool
Automatable::find_next_event (timepos_t const & start, timepos_t const & end, Evoral::ControlEvent& next_event, bool only_active) const 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<double>::max() : 0; next_event.when = start <= end ? timepos_t::max (start.time_domain()) : timepos_t (start.time_domain());
if (only_active) { if (only_active) {
boost::shared_ptr<ControlList> cl = _automated_controls.reader (); boost::shared_ptr<ControlList> cl = _automated_controls.reader ();

View file

@ -237,24 +237,24 @@ Playlist::Playlist (boost::shared_ptr<const Playlist> other, timepos_t const & s
case Temporal::OverlapInternal: case Temporal::OverlapInternal:
offset = region->position().distance (start); offset = region->position().distance (start);
position = 0; position = timepos_t (start.time_domain());
len = timecnt_t (cnt); len = timecnt_t (cnt);
break; break;
case Temporal::OverlapStart: case Temporal::OverlapStart:
offset = 0; offset = timecnt_t (start.time_domain());
position = region->source_position(); position = region->source_position();
len = region->position().distance (end); len = region->position().distance (end);
break; break;
case Temporal::OverlapEnd: case Temporal::OverlapEnd:
offset = region->position().distance (start); offset = region->position().distance (start);
position = 0; position = timepos_t (start.time_domain());
len = region->length() - offset; len = region->length() - offset;
break; break;
case Temporal::OverlapExternal: case Temporal::OverlapExternal:
offset = 0; offset = timecnt_t (start.time_domain());
position = region->source_position(); position = region->source_position();
len = region->length(); len = region->length();
break; break;
@ -340,9 +340,9 @@ Playlist::init (bool hide)
subcnt = 0; subcnt = 0;
_frozen = false; _frozen = false;
_capture_insertion_underway = false; _capture_insertion_underway = false;
_combine_ops = 0; _combine_ops = 0;
_end_space = 0; _end_space = timecnt_t (_type == DataType::AUDIO ? Temporal::AudioTime : Temporal::BeatTime);
_playlist_shift_active = false; _playlist_shift_active = false;
_session.history ().BeginUndoRedo.connect_same_thread (*this, boost::bind (&Playlist::begin_undo, this)); _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)); _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) { if ((*i)->position() >= at) {
timepos_t new_pos = (*i)->position() + distance; timepos_t new_pos = (*i)->position() + distance;
timepos_t limit = std::numeric_limits<timepos_t>::max().earlier ((*i)->length()); timepos_t limit = timepos_t::max (new_pos.time_domain()).earlier ((*i)->length());
if (new_pos < 0) { if (new_pos < 0) {
new_pos = 0; new_pos = timepos_t (new_pos.time_domain());
} else if (new_pos >= limit) { } else if (new_pos >= limit ) {
new_pos = limit; new_pos = limit;
} }
@ -2404,10 +2404,12 @@ Playlist::get_extent_with_endspace () const
pair<timepos_t, timepos_t> pair<timepos_t, timepos_t>
Playlist::_get_extent () const Playlist::_get_extent () const
{ {
pair<timepos_t, timepos_t> ext (std::numeric_limits<timepos_t>::max(), std::numeric_limits<timepos_t>::min()); #warning NUTEMPO domain should likely be a playlist property
Temporal::TimeDomain time_domain (_type == DataType::AUDIO ? Temporal::AudioTime : Temporal::BeatTime);
pair<timepos_t, timepos_t> ext (timepos_t::max (time_domain), timepos_t (time_domain));
if (regions.empty ()) { if (regions.empty()) {
ext.first = 0; ext.first = timepos_t (time_domain);
return ext; return ext;
} }
@ -2686,7 +2688,7 @@ Playlist::nudge_after (timepos_t const & start, timecnt_t const & distance, bool
if ((*i)->position() > distance) { if ((*i)->position() > distance) {
new_pos = (*i)->position().earlier (distance); new_pos = (*i)->position().earlier (distance);
} else { } else {
new_pos = 0; new_pos = timepos_t ((*i)->position().time_domain());;
} }
} }

View file

@ -745,7 +745,7 @@ Region::nudge_position (timecnt_t const & n)
} }
} else { } else {
if (position() < -n) { if (position() < -n) {
new_position = 0; new_position = timepos_t (_position.val().time_domain());
} else { } else {
new_position += n; new_position += n;
} }
@ -867,7 +867,7 @@ Region::modify_front (timepos_t const & new_position, bool reset_fade)
if (position() > start()) { if (position() > start()) {
source_zero = source_position (); source_zero = source_position ();
} else { } 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 */ 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) { if (pos > offset) {
p.shift_earlier (offset); p.shift_earlier (offset);
} else { } else {
p = 0; p = timepos_t (p.time_domain());
} }
} else { } else {
if (timepos_t::max (p.time_domain()).earlier (timecnt_t (p, p)) > offset) { 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 /* beats is an additional offset to the start point of the region, from
the effective start of the source on the timeline. the effective start of the source on the timeline.
*/ */
return source_position() + start () + beats; return source_position() + start () + timepos_t (beats);
} }
Temporal::timepos_t 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 the source. The start of the source is an implied position given by
region->position - region->start region->position - region->start
*/ */
return source_position() + beats; return source_position() + timepos_t (beats);
} }
Temporal::Beats Temporal::Beats

View file

@ -180,13 +180,13 @@ Source::set_state (const XMLNode& node, int version)
} }
if (node.get_property ("natural-position", ts)) { if (node.get_property ("natural-position", ts)) {
_natural_position = ts; _natural_position = timepos_t (ts);
_have_natural_position = true; _have_natural_position = true;
} else if (node.get_property ("timeline-position", ts)) { } else if (node.get_property ("timeline-position", ts)) {
/* some older versions of ardour might have stored this with /* some older versions of ardour might have stored this with
this property name. this property name.
*/ */
_natural_position = ts; _natural_position = timepos_t (ts);
_have_natural_position = true; _have_natural_position = true;
} }