13
0

Cache playlist extents

Calculating the extents iterates over all regions which
can be expensive. Ardour's GUI calls this periodically to
calculate session_gui_extents().
This commit is contained in:
Robin Gareus 2021-01-06 00:13:41 +01:00
parent 4769c387f3
commit ba123dfe87
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 11 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/optional.hpp>
#include <boost/utility.hpp>
#include <sys/stat.h>
@ -432,6 +433,8 @@ private:
void coalesce_and_check_crossfades (std::list<Evoral::Range<samplepos_t> >);
boost::shared_ptr<RegionList> find_regions_at (samplepos_t);
mutable boost::optional<std::pair<samplepos_t, samplepos_t> > _cached_extent;
samplepos_t _end_space; //this is used when we are pasting a range with extra space at the end
bool _playlist_shift_active;
};

View File

@ -2238,6 +2238,8 @@ Playlist::find_next_region_boundary (samplepos_t sample, int dir)
void
Playlist::mark_session_dirty ()
{
_cached_extent.reset ();
if (!in_set_state && !holding_state ()) {
_session.set_dirty();
}
@ -2464,8 +2466,13 @@ Playlist::all_regions_empty() const
pair<samplepos_t, samplepos_t>
Playlist::get_extent () const
{
if (_cached_extent) {
return _cached_extent.value ();
}
RegionReadLock rlock (const_cast<Playlist *>(this));
return _get_extent ();
_cached_extent = _get_extent ();
return _cached_extent.value ();
}
pair<samplepos_t, samplepos_t>