summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-01-08 16:53:34 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-01-08 16:53:34 +0000
commit985946b1a1d80a51eddcdf0a739dcf65657b06f6 (patch)
tree656faf2175ad435c5ad58621a0b42223a1d19ae7
parent818aa2e2f0d2b178461ecfda996491ab17468817 (diff)
fix up a few zero-boundary condition errors in TempoMap
git-svn-id: svn://localhost/ardour2/branches/3.0@11196 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/tempo.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index c39b8d0757..d1458dba6d 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1106,6 +1106,15 @@ TempoMap::bbt_time (framepos_t frame, BBT_Time& bbt)
require_map_to (frame);
Glib::RWLock::ReaderLock lm (lock);
+
+ if (frame < 0) {
+ bbt.bars = 1;
+ bbt.beats = 1;
+ bbt.ticks = 0;
+ warning << string_compose (_("tempo map asked for BBT time at frame %1\n"), frame) << endmsg;
+ return;
+ }
+
return bbt_time (frame, bbt, bbt_before_or_at (frame));
}
@@ -1144,6 +1153,15 @@ TempoMap::bbt_time (framepos_t frame, BBT_Time& bbt, const BBTPointList::const_i
framepos_t
TempoMap::frame_time (const BBT_Time& bbt)
{
+ if (bbt.bars < 1) {
+ warning << string_compose (_("tempo map asked for frame time at bar < 1 (%1)\n"), bbt) << endmsg;
+ return 0;
+ }
+
+ if (bbt.beats < 1) {
+ throw std::logic_error ("beats are counted from one");
+ }
+
require_map_to (bbt);
Glib::RWLock::ReaderLock lm (lock);
@@ -2193,11 +2211,16 @@ TempoMap::bbt_before_or_at (framepos_t pos)
BBTPointList::const_iterator i;
+ if (pos < 0) {
+ /* not really correct, but we should catch pos < 0 at a higher
+ level
+ */
+ return _map.begin();
+ }
+
i = lower_bound (_map.begin(), _map.end(), pos);
assert (i != _map.end());
if ((*i).frame > pos) {
- cerr << "lower bound was found at " << (*i).frame << " for " << pos;
- dump (cerr);
assert (i != _map.begin());
--i;
}