From 256e6f97a2e5b3c3efb66cfd7929871a1d51d0eb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 26 Mar 2022 21:42:28 -0600 Subject: [PATCH] evoral: change how we specify a zero min_x_delta to rt_safe_earliest_event_linear_unlocked See comment in the code for more details. --- libs/evoral/ControlList.cc | 14 +++++++++++++- libs/evoral/evoral/ControlList.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/evoral/ControlList.cc b/libs/evoral/ControlList.cc index 79c7f2f4cf..2ea98d9d39 100644 --- a/libs/evoral/ControlList.cc +++ b/libs/evoral/ControlList.cc @@ -1652,7 +1652,19 @@ ControlList::rt_safe_earliest_event_linear_unlocked (Temporal::timepos_t const & { timepos_t start = start_time; - // cout << "earliest_event(start: " << start << ", x: " << x << ", y: " << y << ", inclusive: " << inclusive << ")" << endl; + /* the max value is given as an out-of-bounds default value, when the + true default is zero, but the time-domain is not known at compile + time. This allows us to reset it to zero with the correct time + domain (equality comparisons across time domains where the actual + scalar value is zero should always be cheap, but that's not true of + other operators such as >, < etc.) + */ + + if (min_x_delta == Temporal::timecnt_t::max()) { + min_x_delta = Temporal::timecnt_t (time_domain()); + } + + // cout << "earliest_event(start: " << start << ", x: " << x << ", y: " << y << ", inclusive: " << inclusive << ") mxd " << min_x_delta << endl; const_iterator length_check_iter = _events.begin(); if (_events.empty()) { // 0 events diff --git a/libs/evoral/evoral/ControlList.h b/libs/evoral/evoral/ControlList.h index 95c3ef72cb..f43c3fd570 100644 --- a/libs/evoral/evoral/ControlList.h +++ b/libs/evoral/evoral/ControlList.h @@ -308,7 +308,7 @@ public: double unlocked_eval (Temporal::timepos_t const & x) const; bool rt_safe_earliest_event_discrete_unlocked (Temporal::timepos_t const & start, Temporal::timepos_t & x, double& y, bool inclusive) const; - bool rt_safe_earliest_event_linear_unlocked (Temporal::timepos_t const & start, Temporal::timepos_t & x, double& y, bool inclusive, Temporal::timecnt_t min_x_delta = Temporal::timecnt_t ()) const; + bool rt_safe_earliest_event_linear_unlocked (Temporal::timepos_t const & start, Temporal::timepos_t & x, double& y, bool inclusive, Temporal::timecnt_t min_x_delta = Temporal::timecnt_t::max()) const; void create_curve(); void destroy_curve();