From 52f1b88749800aea2199ac3727231f5caec28981 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 11 Jul 2023 13:43:01 -0600 Subject: [PATCH] temporal: remove ill-conceived lookup tables from tempo map (never publically visible) These were not thread safe, and could not be: to be useful, a thread looking up a time conversion could cache the result, but it would be using the global (shared) copy of the map (because lookup is read-only, and so no write-copy is required). But inserting into the lookup table wasn't lock protected (and shouldn't be because otherwise that defeats the point of RCU). So just drop it. --- libs/temporal/tempo.cc | 83 ---------------------------------- libs/temporal/temporal/tempo.h | 24 ---------- 2 files changed, 107 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index c139948256..13648586f6 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -4128,89 +4128,6 @@ TempoMap::write_copy() return _map_mgr.write_copy(); } -void -TempoMap::drop_lookup_table (){ - - superclock_beat_lookup_table.clear (); - beat_superclock_lookup_table.clear (); - beat_bbt_lookup_table.clear (); - superclock_bbt_lookup_table.clear (); -} - -Temporal::Beats -TempoMap::beat_lookup (superclock_t sc, bool& found) const -{ - LookupTable::const_iterator i = superclock_beat_lookup_table.find (sc); - if (i == superclock_beat_lookup_table.end()) { - found = false; - return Beats();; - } - found = true; - return Temporal::Beats::ticks (i->second); -} - -superclock_t -TempoMap::superclock_lookup (Temporal::Beats const & b, bool& found) const -{ - LookupTable::const_iterator i = beat_superclock_lookup_table.find (b.to_ticks()); - if (i == beat_superclock_lookup_table.end()) { - found = false; - return 0; - } - found = true; - return i->second; -} - -BBT_Time -TempoMap::bbt_lookup (Temporal::Beats const & b, bool& found) const -{ - LookupTable::const_iterator i = beat_bbt_lookup_table.find (b.to_ticks()); - if (i == beat_bbt_lookup_table.end()) { - found = false; - return BBT_Time (); - } - found = true; - return BBT_Time::from_integer (i->second); -} - -BBT_Time -TempoMap::bbt_lookup (superclock_t sc, bool& found) const -{ - LookupTable::const_iterator i = superclock_bbt_lookup_table.find (sc); - if (i == superclock_bbt_lookup_table.end()) { - found = false; - return BBT_Time (); - } - found = true; - return BBT_Time::from_integer (i->second); -} - -/* see tempo.h comments about why this is const */ -void -TempoMap::superclock_to_beat_store (superclock_t sc, Temporal::Beats const & b) const -{ - superclock_beat_lookup_table[sc] = b.to_ticks(); -} - -/* see tempo.h comments about why this is const */ -void -TempoMap::beat_to_superclock_store (Temporal::Beats const & b, superclock_t sc) const -{ - beat_superclock_lookup_table[b.to_ticks()] = sc; -} - -void -TempoMap::superclock_to_bbt_store (superclock_t sc, BBT_Time const & bbt) const -{ - superclock_bbt_lookup_table[sc] = bbt.as_integer (); -} - -void -TempoMap::beat_to_bbt_store (Temporal::Beats const & b, BBT_Time const & bbt) const -{ - beat_bbt_lookup_table[b.to_ticks()] = bbt.as_integer (); -} - int TempoMap::update (TempoMap::WritableSharedPtr m) { diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index d60211060b..823d2b1cec 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -1101,21 +1101,9 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible int parse_meter_state_3x (const XMLNode& node, LegacyMeterState& lts); int set_state_3x (XMLNode const &); - typedef std::unordered_map LookupTable; - - mutable LookupTable superclock_beat_lookup_table; - mutable LookupTable beat_superclock_lookup_table; - mutable LookupTable beat_bbt_lookup_table; - mutable LookupTable superclock_bbt_lookup_table; - friend class TempoPoint; friend class MeterPoint; friend class TempoMetric; - Temporal::Beats beat_lookup (superclock_t, bool& found) const; - superclock_t superclock_lookup (Temporal::Beats const &, bool& found) const; - - Temporal::BBT_Time bbt_lookup (superclock_t, bool & found) const; - Temporal::BBT_Time bbt_lookup (Temporal::Beats const & b, bool & found) const; bool solve_ramped_twist (TempoPoint&, TempoPoint&); /* this is implemented by iteration, and it might fail. */ bool solve_constant_twist (TempoPoint&, TempoPoint&); //TODO: currently also done by iteration; should be possible to calculate directly @@ -1127,18 +1115,6 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible void reset_section (Points::iterator& begin, Points::iterator& end, superclock_t, TempoMetric& metric); TempoMapCutBuffer* cut_copy (timepos_t const & start, timepos_t const & end, bool copy, bool ripple); - - /* These are not really const, but the lookup tables are marked mutable - * to allow time domain conversions to store their results while being - * marked const (which is more semantically correct). - */ - - void superclock_to_beat_store (superclock_t, Temporal::Beats const &) const; - void beat_to_superclock_store (Temporal::Beats const &, superclock_t) const;; - void beat_to_bbt_store (Temporal::Beats const &, Temporal::BBT_Time const &) const;; - void superclock_to_bbt_store (superclock_t, Temporal::BBT_Time const &) const;; - - void drop_lookup_table (); }; class LIBTEMPORAL_API TempoMapCutBuffer