diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-05-26 12:24:04 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-05-26 12:24:04 +0000 |
commit | f38db9a4e350de376308d89059ba123a16719f1a (patch) | |
tree | 911e0a02baee2cf412ea675d8267e0a449f25603 /libs | |
parent | af02cbcafa96e7d88f1d06923ac00440be4d049b (diff) |
move session file storage of nested sources from playlist into region, and reload them within Session::XMLRegionFactory, just before we create the region that uses the nested source
git-svn-id: svn://localhost/ardour2/branches/3.0@9595 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/playlist.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 1 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 58 | ||||
-rw-r--r-- | libs/ardour/region.cc | 45 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 29 |
5 files changed, 60 insertions, 74 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index dfb16d79bc..69f4963359 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -379,7 +379,6 @@ public: void timestamp_layer_op (boost::shared_ptr<Region>); void _split_region (boost::shared_ptr<Region>, framepos_t position); - void load_nested_sources (const XMLNode& node); typedef std::pair<boost::shared_ptr<Region>, boost::shared_ptr<Region> > TwoRegions; virtual void copy_dependents (const std::vector<TwoRegions>&, boost::shared_ptr<Playlist>) { } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f1e73ed1fd..c1bd84ae46 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1500,6 +1500,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi framepos_t compute_stop_limit () const; boost::shared_ptr<Speakers> _speakers; + void load_nested_sources (const XMLNode& node); }; } // namespace ARDOUR diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 3c241cf846..814278f0e5 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -2191,26 +2191,6 @@ Playlist::update (const RegionListProperty::ChangeRecord& change) thaw (); } -void -Playlist::load_nested_sources (const XMLNode& node) -{ - XMLNodeList nlist; - XMLNodeConstIterator niter; - - nlist = node.children(); - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - if ((*niter)->name() == "Source") { - try { - SourceFactory::create (_session, **niter, true); - } - catch (failed_constructor& err) { - error << string_compose (_("Cannot reconstruct nested source for playlist %1"), name()) << endmsg; - } - } - } -} - int Playlist::set_state (const XMLNode& node, int version) { @@ -2256,19 +2236,6 @@ Playlist::set_state (const XMLNode& node, int version) nlist = node.children(); - /* find the "Nested" node, if any, and recreate the PlaylistSources - listed there - */ - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - child = *niter; - - if (child->name() == "Nested") { - load_nested_sources (*child); - break; - } - } - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { child = *niter; @@ -2354,36 +2321,11 @@ Playlist::state (bool full_state) if (full_state) { RegionLock rlock (this, false); - XMLNode* nested_node = 0; snprintf (buf, sizeof (buf), "%u", _combine_ops); node->add_property ("combine-ops", buf); for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - if ((*i)->max_source_level() > 0) { - - if (!nested_node) { - nested_node = new XMLNode (X_("Nested")); - } - - /* region is compound - get its playlist and - store that before we list the region that - needs it ... - */ - - const SourceList& sl ((*i)->sources()); - - for (SourceList::const_iterator s = sl.begin(); s != sl.end(); ++s) { - nested_node->add_child_nocopy ((*s)->get_state ()); - } - } - } - - if (nested_node) { - node->add_child_nocopy (*nested_node); - } - - for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { node->add_child_nocopy ((*i)->get_state()); } } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 3fbe288b7a..53c36ed5b5 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -37,6 +37,7 @@ #include "ardour/region_factory.h" #include "ardour/session.h" #include "ardour/source.h" +#include "ardour/source_factory.h" #include "ardour/tempo.h" #include "ardour/utils.h" @@ -1206,6 +1207,24 @@ Region::state () node->add_property (buf2, buf); } + if (max_source_level() > 0) { + + XMLNode* nested_node = new XMLNode (X_("NestedSource")); + + /* region is compound - get its playlist and + store that before we list the region that + needs it ... + */ + + for (SourceList::const_iterator s = _sources.begin(); s != _sources.end(); ++s) { + nested_node->add_child_nocopy ((*s)->get_state ()); + } + + if (nested_node) { + node->add_child_nocopy (*nested_node); + } + } + if (_extra_xml) { node->add_child_copy (*_extra_xml); } @@ -1230,6 +1249,17 @@ int Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_changed, bool send) { const XMLProperty* prop; + const XMLNodeList& nlist = node.children(); + + for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) { + + XMLNode *child = (*niter); + + if (child->name () == "Extra") { + delete _extra_xml; + _extra_xml = new XMLNode (*child); + } + } what_changed = set_values (node); @@ -1262,21 +1292,6 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c _shift = 1.0f; } - const XMLNodeList& nlist = node.children(); - - for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) { - - XMLNode *child; - - child = (*niter); - - if (child->name () == "Extra") { - delete _extra_xml; - _extra_xml = new XMLNode (*child); - break; - } - } - if (send) { send_change (what_changed); } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 3af2288b66..3c2496eba5 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1653,6 +1653,26 @@ Session::load_compounds (const XMLNode& node) return 0; } +void +Session::load_nested_sources (const XMLNode& node) +{ + XMLNodeList nlist; + XMLNodeConstIterator niter; + + nlist = node.children(); + + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { + if ((*niter)->name() == "Source") { + try { + SourceFactory::create (*this, **niter, true); + } + catch (failed_constructor& err) { + error << string_compose (_("Cannot reconstruct nested source for region %1"), name()) << endmsg; + } + } + } +} + boost::shared_ptr<Region> Session::XMLRegionFactory (const XMLNode& node, bool full) { @@ -1660,6 +1680,15 @@ Session::XMLRegionFactory (const XMLNode& node, bool full) try { + const XMLNodeList& nlist = node.children(); + + for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) { + XMLNode *child = (*niter); + if (child->name() == "NestedSource") { + load_nested_sources (*child); + } + } + if (!type || type->value() == "audio") { return boost::shared_ptr<Region>(XMLAudioRegionFactory (node, full)); } else if (type->value() == "midi") { |