add concept of an owner region (by ID) to PlaylistSource
This commit is contained in:
@@ -37,10 +37,14 @@ public:
|
||||
int set_state (const XMLNode&, int version);
|
||||
boost::shared_ptr<const Playlist> playlist() const { return _playlist; }
|
||||
const PBD::ID& original() const { return _original; }
|
||||
const PBD::ID& owner() const { return _owner; }
|
||||
|
||||
void set_owner (PBD::ID const & id);
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<Playlist> _playlist;
|
||||
PBD::ID _original;
|
||||
PBD::ID _owner;
|
||||
sampleoffset_t _playlist_offset;
|
||||
samplecnt_t _playlist_length;
|
||||
|
||||
|
||||
@@ -3177,6 +3177,10 @@ Playlist::combine (const RegionList& r)
|
||||
|
||||
boost::shared_ptr<Region> compound_region = RegionFactory::create (parent_region, plist, true);
|
||||
|
||||
for (SourceList::iterator s = sources.begin(); s != sources.end(); ++s) {
|
||||
boost::dynamic_pointer_cast<PlaylistSource>(*s)->set_owner (compound_region->id());
|
||||
}
|
||||
|
||||
/* remove all the selected regions from the current playlist */
|
||||
|
||||
freeze ();
|
||||
|
||||
@@ -47,6 +47,7 @@ PlaylistSource::PlaylistSource (Session& s, const ID& orig, const std::string& n
|
||||
: Source (s, type, name)
|
||||
, _playlist (p)
|
||||
, _original (orig)
|
||||
, _owner (0) /* zero is never a legal ID for an object */
|
||||
{
|
||||
/* PlaylistSources are never writable, renameable, removable or destructive */
|
||||
_flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive));
|
||||
@@ -76,6 +77,14 @@ PlaylistSource::~PlaylistSource ()
|
||||
_playlist->release ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistSource::set_owner (PBD::ID const &id)
|
||||
{
|
||||
if (_owner == 0) {
|
||||
_owner = id;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistSource::add_state (XMLNode& node)
|
||||
{
|
||||
@@ -84,6 +93,10 @@ PlaylistSource::add_state (XMLNode& node)
|
||||
node.set_property ("length", _playlist_length);
|
||||
node.set_property ("original", _original);
|
||||
|
||||
if (_owner != 0) {
|
||||
node.set_property ("owner", _owner);
|
||||
}
|
||||
|
||||
node.add_child_nocopy (_playlist->get_state());
|
||||
}
|
||||
|
||||
@@ -139,6 +152,12 @@ PlaylistSource::set_state (const XMLNode& node, int /*version*/)
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
/* this is allowed to fail. It either means an older session file
|
||||
format, or a PlaylistSource that wasn't created for a combined
|
||||
region (whose ID would be stored in _owner).
|
||||
*/
|
||||
node.get_property (X_("owner"), _owner);
|
||||
|
||||
_level = _playlist->max_source_level () + 1;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user