From 2858b0474e4bedf3ab67a539a7f0d12380ac7bda Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 4 Jan 2012 17:55:42 +0000 Subject: fix (?) tricky locking issues in the tempo map by adding a second lock and independently locking the metrics and the map itself git-svn-id: svn://localhost/ardour2/branches/3.0@11157 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/tempo.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'libs/ardour/ardour/tempo.h') diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 3f4b783de7..f0a63be05f 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -223,16 +223,14 @@ class TempoMap : public PBD::StatefulDestructible typedef std::vector BBTPointList; template void apply_with_metrics (T& obj, void (T::*method)(const Metrics&)) { - Glib::RWLock::ReaderLock lm (lock); + Glib::RWLock::ReaderLock lm (metrics_lock); (obj.*method)(*metrics); } - const BBTPointList& map() const { return _map ; } - void map (BBTPointList::const_iterator&, BBTPointList::const_iterator&, framepos_t start, framepos_t end); - void bbt_time (framepos_t when, Timecode::BBT_Time&); + void bbt_time (framepos_t when, Timecode::BBT_Time&); framecnt_t frame_time (const Timecode::BBT_Time&); framecnt_t bbt_duration_at (framepos_t, const Timecode::BBT_Time&, int dir); @@ -299,31 +297,32 @@ class TempoMap : public PBD::StatefulDestructible framepos_t last_bbt_when; bool last_bbt_valid; Timecode::BBT_Time last_bbt; - mutable Glib::RWLock lock; - BBTPointList _map; + mutable Glib::RWLock metrics_lock; + mutable Glib::RWLock map_lock; + BBTPointList* _map; void recompute_map (bool reassign_tempo_bbt, framepos_t end = -1); void require_map_to (framepos_t pos); void require_map_to (const Timecode::BBT_Time&); - BBTPointList::const_iterator bbt_before_or_at (framepos_t); - BBTPointList::const_iterator bbt_after_or_at (framepos_t); - BBTPointList::const_iterator bbt_point_for (const Timecode::BBT_Time&); - + BBTPointList::const_iterator bbt_before_or_at (framepos_t); + BBTPointList::const_iterator bbt_after_or_at (framepos_t); + BBTPointList::const_iterator bbt_point_for (const Timecode::BBT_Time&); + void timestamp_metrics_from_audio_time (); - + framepos_t round_to_type (framepos_t fr, int dir, BBTPointType); - + void bbt_time_unlocked (framepos_t, Timecode::BBT_Time&, const BBTPointList::const_iterator&); - - framecnt_t bbt_duration_at_unlocked (const Timecode::BBT_Time& when, const Timecode::BBT_Time& bbt, int dir); - + + framecnt_t bbt_duration_at_unlocked (const Timecode::BBT_Time& when, const Timecode::BBT_Time& bbt, int dir); + const MeterSection& first_meter() const; const TempoSection& first_tempo() const; - + int move_metric_section (MetricSection&, const Timecode::BBT_Time& to); void do_insert (MetricSection* section); - + Timecode::BBT_Time bbt_add (const Timecode::BBT_Time&, const Timecode::BBT_Time&, const TempoMetric&) const; Timecode::BBT_Time bbt_add (const Timecode::BBT_Time& a, const Timecode::BBT_Time& b) const; Timecode::BBT_Time bbt_subtract (const Timecode::BBT_Time&, const Timecode::BBT_Time&) const; -- cgit v1.2.3