From 7373e3ac148aedc2d0c707443e5ea6b6c208ed7a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 8 Jan 2020 22:18:18 -0700 Subject: add concept of an owner region (by ID) to PlaylistSource --- libs/ardour/ardour/playlist_source.h | 4 ++++ libs/ardour/playlist.cc | 4 ++++ libs/ardour/playlist_source.cc | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) (limited to 'libs') diff --git a/libs/ardour/ardour/playlist_source.h b/libs/ardour/ardour/playlist_source.h index d78cf0804e..001c8f97a7 100644 --- a/libs/ardour/ardour/playlist_source.h +++ b/libs/ardour/ardour/playlist_source.h @@ -37,10 +37,14 @@ public: int set_state (const XMLNode&, int version); boost::shared_ptr 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; PBD::ID _original; + PBD::ID _owner; sampleoffset_t _playlist_offset; samplecnt_t _playlist_length; diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index f2249dcde9..6462ee2dca 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -3177,6 +3177,10 @@ Playlist::combine (const RegionList& r) boost::shared_ptr compound_region = RegionFactory::create (parent_region, plist, true); + for (SourceList::iterator s = sources.begin(); s != sources.end(); ++s) { + boost::dynamic_pointer_cast(*s)->set_owner (compound_region->id()); + } + /* remove all the selected regions from the current playlist */ freeze (); diff --git a/libs/ardour/playlist_source.cc b/libs/ardour/playlist_source.cc index dc03bbeb2d..0922d2e959 100644 --- a/libs/ardour/playlist_source.cc +++ b/libs/ardour/playlist_source.cc @@ -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; -- cgit v1.2.3