From 829c257f451a0495d5c5f5dee47560961ddd8183 Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 30 May 2016 11:03:45 +1000 Subject: [PATCH] Make TempoMap::framepos_plus_beats() & TempoMap::framepos_minus_beats() more correct. --- libs/ardour/tempo.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 6d83ebdc50..b38d73c001 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -3530,14 +3530,18 @@ TempoMap::remove_time (framepos_t where, framecnt_t amount) framepos_t TempoMap::framepos_plus_beats (framepos_t pos, Evoral::Beats beats) const { - return frame_at_beat (beat_at_frame (pos) + beats.to_double()); + Glib::Threads::RWLock::ReaderLock lm (lock); + + return frame_at_beat_locked (_metrics, beat_at_frame_locked (_metrics, pos) + beats.to_double()); } /** Subtract some (fractional) beats from a frame position, and return the result in frames */ framepos_t TempoMap::framepos_minus_beats (framepos_t pos, Evoral::Beats beats) const { - return frame_at_beat (beat_at_frame (pos) - beats.to_double()); + Glib::Threads::RWLock::ReaderLock lm (lock); + + return frame_at_beat_locked (_metrics, beat_at_frame_locked (_metrics, pos) - beats.to_double()); } /** Add the BBT interval op to pos and return the result */