From 433a9ebe48567508d0f846018da62aa574e3f2ce Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Feb 2021 22:21:43 -0700 Subject: [PATCH] libtemporal: catch attempts to convert max audio time values into beats, early --- libs/temporal/timeline.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libs/temporal/timeline.cc b/libs/temporal/timeline.cc index 7164d57a7b..73dea22143 100644 --- a/libs/temporal/timeline.cc +++ b/libs/temporal/timeline.cc @@ -453,24 +453,34 @@ timepos_t::operator>= (timecnt_t const & t) const superclock_t timepos_t::_superclocks () const { + assert (time_domain() == BeatTime); stats.beats_to_audio++; - TempoMap::SharedPtr tm (TempoMap::use()); - return tm->superclock_at (beats ()); + return TempoMap::use()->superclock_at (beats ()); } Temporal::Beats timepos_t::_beats () const { + assert (time_domain() == AudioTime); stats.audio_to_beats++; - TempoMap::SharedPtr tm (TempoMap::use()); - return tm->quarters_at_superclock (v); + /* see notes in Temporal::TempoPoint::quarters_at_superclock() for + * more. Basically, specially case "max-superclocks" and return + * "max-beats" + */ + + if (val() == int62_t::max) { + return std::numeric_limits::max (); + } + + return TempoMap::use()->quarters_at_superclock (v); } int64_t timepos_t::_ticks () const { + assert (time_domain() == AudioTime); return _beats().to_ticks(); }