summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-01-17 03:00:32 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-01-17 03:00:32 +0000
commite2729c12a89e25cec7247ef92077f125d2909484 (patch)
tree5d11ad48fb0038962c6e814dc19d60649579e925 /libs/ardour/tempo.cc
parent28d5a263b484832ab7cbe0b402dcb95bb17a6f65 (diff)
fix bug with tempo computation where passed in positions or offsets are negative
git-svn-id: svn://localhost/ardour2/branches/3.0@11252 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r--libs/ardour/tempo.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 8b59b06de6..23310db4ff 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -2006,6 +2006,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const
const TempoSection* tempo;
const TempoSection* t;
double frames_per_beat;
+ framepos_t effective_pos = max (pos, (framepos_t) 0);
meter = &first_meter ();
tempo = &first_tempo ();
@@ -2017,7 +2018,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const
for (i = metrics.begin(); i != metrics.end(); ++i) {
- if ((*i)->frame() > pos) {
+ if ((*i)->frame() > effective_pos) {
break;
}
@@ -2138,8 +2139,9 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
{
Glib::RWLock::ReaderLock lm (lock);
Metrics::const_iterator next_tempo;
- const TempoSection* tempo;
-
+ const TempoSection* tempo = 0;
+ framepos_t effective_pos = max (pos, (framepos_t) 0);
+
/* Find the relevant initial tempo metric */
for (next_tempo = metrics.begin(); next_tempo != metrics.end(); ++next_tempo) {
@@ -2148,7 +2150,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
if ((t = dynamic_cast<const TempoSection*>(*next_tempo)) != 0) {
- if ((*next_tempo)->frame() > pos) {
+ if ((*next_tempo)->frame() > effective_pos) {
break;
}
@@ -2162,6 +2164,8 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
next_tempo -> the next tempo after "pos", possibly metrics.end()
*/
+ assert (tempo);
+
Evoral::MusicalTime beats = 0;
while (distance) {
@@ -2178,6 +2182,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
/* Update */
pos += sub;
distance -= sub;
+ assert (tempo);
beats += sub / tempo->frames_per_beat (_frame_rate);
/* Move on if there's anything to move to */
@@ -2199,6 +2204,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
}
}
}
+ assert (tempo);
}
return beats;