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:
parent
4769c387f3
commit
ba123dfe87
@ -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;
|
||||
};
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user