13
0

libtemporal: fix implementation of timepos_t::max() to avoid overflow for Beats time

This commit is contained in:
Paul Davis 2021-02-16 15:53:09 -07:00
parent b2510c0da2
commit 5b3c5d3782

View File

@ -211,7 +211,10 @@ class LIBTEMPORAL_API timepos_t : public int62_t {
bool string_to (std::string const & str);
std::string to_string () const;
static timepos_t max (TimeDomain td) { return timepos_t (td != AudioTime, int62_t::max); }
/* note that the value returned if the time domain is audio is larger
than can be represented in musical time (for any realistic tempos).
*/
static timepos_t max (TimeDomain td) { if (td == AudioTime) { return timepos_t (false, int62_t::max); } else { return timepos_t (std::numeric_limits<Beats>::max()); }}
static timepos_t smallest_step (TimeDomain td) { return timepos_t (td != AudioTime, 1); }
private: