#include "pbd/failed_constructor.h"
#include "pbd/stateful_diff_command.h"
#include "pbd/xml++.h"
+#include "pbd/stacktrace.h"
#include "ardour/debug.h"
#include "ardour/playlist.h"
RegionLock rlock (const_cast<Playlist *> (this));
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- newlist.push_back (RegionFactory::RegionFactory::create (*i));
+ newlist.push_back (RegionFactory::RegionFactory::create (*i, true));
}
}
/* the length change might not be true, but we have to act
as though it could be.
*/
-
+
if (holding_state()) {
pending_adds.insert (r);
pending_contents_change = true;
*/
for (int i = 0; i < itimes; ++i) {
- boost::shared_ptr<Region> copy = RegionFactory::create (region);
+ boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
add_region_internal (copy, pos);
pos += region->length();
}
while (itimes--) {
for (RegionList::iterator i = other->regions.begin(); i != other->regions.end(); ++i) {
- boost::shared_ptr<Region> copy_of_region = RegionFactory::create (*i);
+ boost::shared_ptr<Region> copy_of_region = RegionFactory::create (*i, true);
/* put these new regions on top of all existing ones, but preserve
the ordering they had in the original playlist.
*/
copy_of_region->set_layer (copy_of_region->layer() + top_layer);
- add_region_internal (copy_of_region, copy_of_region->position() + pos);
+ add_region_internal (copy_of_region, (*i)->position() + pos);
}
pos += shift;
}
framepos_t pos = position + 1;
while (itimes--) {
- boost::shared_ptr<Region> copy = RegionFactory::create (region);
+ boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
add_region_internal (copy, pos);
pos += region->length();
}
return regions.size();
}
-pair<framecnt_t, framecnt_t>
+pair<framepos_t, framepos_t>
Playlist::get_extent () const
{
RegionLock rlock (const_cast<Playlist *>(this), false);
return _get_extent ();
}
-pair<framecnt_t, framecnt_t>
+pair<framepos_t, framepos_t>
Playlist::_get_extent () const
{
- pair<framecnt_t, framecnt_t> ext (max_framepos, 0);
+ pair<framepos_t, framepos_t> ext (max_framepos, 0);
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- pair<framecnt_t, framecnt_t> const e ((*i)->position(), (*i)->position() + (*i)->length());
+ pair<framepos_t, framepos_t> const e ((*i)->position(), (*i)->position() + (*i)->length());
if (e.first < ext.first) {
ext.first = e.first;
}
return boost::shared_ptr<Region> ();
}
+uint32_t
+Playlist::region_use_count (boost::shared_ptr<Region> r) const
+{
+ RegionLock rlock (const_cast<Playlist*> (this));
+ uint32_t cnt = 0;
+
+ for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
+ if ((*i) == r) {
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+
boost::shared_ptr<Region>
Playlist::region_by_id (const ID& id) const
{
i = j;
}
}
+
+/** Look from a session frame time and find the start time of the next region
+ * which is on the top layer of this playlist.
+ * @param t Time to look from.
+ * @return Position of next top-layered region, or max_framepos if there isn't one.
+ */
+framepos_t
+Playlist::find_next_top_layer_position (framepos_t t) const
+{
+ RegionLock rlock (const_cast<Playlist *> (this));
+
+ layer_t const top = top_layer ();
+
+ RegionList copy = regions.rlist ();
+ copy.sort (RegionSortByPosition ());
+
+ for (RegionList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
+ if ((*i)->position() >= t && (*i)->layer() == top) {
+ return (*i)->position();
+ }
+ }
+
+ return max_framepos;
+}