summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-06-23 08:42:55 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-06-23 08:42:55 -0400
commitdece3c20cabb7ce0a9851891ea9aacaf8042ce36 (patch)
treefaf1bdd0644f0a8656c30d5e91fd5991152b8dd0
parentb808ca897ba8e431c474e94dc3f0ff3aaa4df234 (diff)
create sortable, linear list for cache clearing on demand, rather than trying to maintain it in parallel with the cache map
-rw-r--r--libs/canvas/canvas/wave_view.h1
-rw-r--r--libs/canvas/wave_view.cc13
2 files changed, 10 insertions, 4 deletions
diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h
index b5cbf9bf57..dc3fe4e13c 100644
--- a/libs/canvas/canvas/wave_view.h
+++ b/libs/canvas/canvas/wave_view.h
@@ -164,7 +164,6 @@ class LIBCANVAS_API WaveViewCache
*/
typedef std::pair<boost::shared_ptr<ARDOUR::AudioSource>,boost::shared_ptr<Entry> > ListEntry;
typedef std::vector<ListEntry> CacheList;
- CacheList cache_list;
struct SortByTimestamp {
bool operator() (const WaveViewCache::ListEntry& a, const WaveViewCache::ListEntry& b) {
diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc
index b57d4217be..3a04961d12 100644
--- a/libs/canvas/wave_view.cc
+++ b/libs/canvas/wave_view.cc
@@ -1704,7 +1704,6 @@ WaveViewCache::add (boost::shared_ptr<ARDOUR::AudioSource> src, boost::shared_pt
ce->timestamp = g_get_monotonic_time ();
cache_map[src].push_back (ce);
- cache_list.push_back (make_pair (src, ce));
}
uint64_t
@@ -1730,10 +1729,18 @@ WaveViewCache::cache_full()
void
WaveViewCache::cache_flush ()
{
- SortByTimestamp sorter;
+ /* Build a sortable list of all cache entries */
+
+ CacheList cache_list;
+ for (ImageCache::const_iterator cm = cache_map.begin(); cm != cache_map.end(); ++cm) {
+ for (CacheLine::const_iterator cl = cm->second.begin(); cl != cm->second.end(); ++cl) {
+ cache_list.push_back (make_pair (cm->first, *cl));
+ }
+ }
+
/* sort list in LRU order */
-
+ SortByTimestamp sorter;
sort (cache_list.begin(), cache_list.end(), sorter);
while (image_cache_size > _image_cache_threshold && !cache_map.empty() && !cache_list.empty()) {