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 <list>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -432,6 +433,8 @@ private:
|
|||||||
void coalesce_and_check_crossfades (std::list<Evoral::Range<samplepos_t> >);
|
void coalesce_and_check_crossfades (std::list<Evoral::Range<samplepos_t> >);
|
||||||
boost::shared_ptr<RegionList> find_regions_at (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
|
samplepos_t _end_space; //this is used when we are pasting a range with extra space at the end
|
||||||
bool _playlist_shift_active;
|
bool _playlist_shift_active;
|
||||||
};
|
};
|
||||||
|
@ -2238,6 +2238,8 @@ Playlist::find_next_region_boundary (samplepos_t sample, int dir)
|
|||||||
void
|
void
|
||||||
Playlist::mark_session_dirty ()
|
Playlist::mark_session_dirty ()
|
||||||
{
|
{
|
||||||
|
_cached_extent.reset ();
|
||||||
|
|
||||||
if (!in_set_state && !holding_state ()) {
|
if (!in_set_state && !holding_state ()) {
|
||||||
_session.set_dirty();
|
_session.set_dirty();
|
||||||
}
|
}
|
||||||
@ -2464,8 +2466,13 @@ Playlist::all_regions_empty() const
|
|||||||
pair<samplepos_t, samplepos_t>
|
pair<samplepos_t, samplepos_t>
|
||||||
Playlist::get_extent () const
|
Playlist::get_extent () const
|
||||||
{
|
{
|
||||||
|
if (_cached_extent) {
|
||||||
|
return _cached_extent.value ();
|
||||||
|
}
|
||||||
|
|
||||||
RegionReadLock rlock (const_cast<Playlist *>(this));
|
RegionReadLock rlock (const_cast<Playlist *>(this));
|
||||||
return _get_extent ();
|
_cached_extent = _get_extent ();
|
||||||
|
return _cached_extent.value ();
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<samplepos_t, samplepos_t>
|
pair<samplepos_t, samplepos_t>
|
||||||
|
Loading…
Reference in New Issue
Block a user