X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fplaylist_source.cc;h=ed8735b86530c06b866858baa8c4ae1af179a9c6;hb=677531addbefdc5dda4996c3920e2f847e137703;hp=7ac175959ca3ad1bb17af779f882af6a8d830f37;hpb=4b5bd4ca46fe00a473682bf21927a0d67ac1a3a4;p=ardour.git diff --git a/libs/ardour/playlist_source.cc b/libs/ardour/playlist_source.cc index 7ac175959c..ed8735b865 100644 --- a/libs/ardour/playlist_source.cc +++ b/libs/ardour/playlist_source.cc @@ -32,9 +32,7 @@ #include "ardour/playlist.h" #include "ardour/playlist_source.h" -#include "ardour/session.h" -#include "ardour/session_playlists.h" -#include "ardour/source_factory.h" +#include "ardour/playlist_factory.h" #include "i18n.h" @@ -42,10 +40,11 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -PlaylistSource::PlaylistSource (Session& s, const std::string& name, boost::shared_ptr p, DataType type, - frameoffset_t begin, framecnt_t len, Source::Flag flags) +PlaylistSource::PlaylistSource (Session& s, const ID& orig, const std::string& name, boost::shared_ptr p, DataType type, + frameoffset_t begin, framecnt_t len, Source::Flag /*flags*/) : Source (s, type, name) , _playlist (p) + , _original (orig) { /* PlaylistSources are never writable, renameable, removable or destructive */ _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); @@ -62,7 +61,7 @@ PlaylistSource::PlaylistSource (Session& s, const XMLNode& node) { /* PlaylistSources are never writable, renameable, removable or destructive */ _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); - + if (set_state (node, Stateful::loading_state_version)) { throw failed_constructor (); @@ -84,26 +83,39 @@ PlaylistSource::add_state (XMLNode& node) node.add_property ("offset", buf); snprintf (buf, sizeof (buf), "%" PRIu64, _playlist_length); node.add_property ("length", buf); + node.add_property ("original", id().to_s()); + + node.add_child_nocopy (_playlist->get_state()); } int -PlaylistSource::set_state (const XMLNode& node, int version) +PlaylistSource::set_state (const XMLNode& node, int /*version*/) { - /* get playlist ID */ + /* check that we have a playlist ID */ const XMLProperty *prop = node.property (X_("playlist")); if (!prop) { + error << _("No playlist ID in PlaylistSource XML!") << endmsg; throw failed_constructor (); } - PBD::ID id (prop->value()); + /* create playlist from child node */ - /* get playlist */ + XMLNodeList nlist; + XMLNodeConstIterator niter; - boost::shared_ptr p = _session.playlists->by_id (id); + nlist = node.children(); + + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { + if ((*niter)->name() == "Playlist") { + _playlist = PlaylistFactory::create (_session, **niter, true, false); + break; + } + } if (!_playlist) { + error << _("Could not construct playlist for PlaylistSource from session data!") << endmsg; throw failed_constructor (); } @@ -112,7 +124,7 @@ PlaylistSource::set_state (const XMLNode& node, int version) if ((prop = node.property (X_("name"))) == 0) { throw failed_constructor (); } - + set_name (prop->value()); if ((prop = node.property (X_("offset"))) == 0) { @@ -126,6 +138,16 @@ PlaylistSource::set_state (const XMLNode& node, int version) sscanf (prop->value().c_str(), "%" PRIu64, &_playlist_length); + /* XXX not quite sure why we set our ID back to the "original" one + here. october 2011, paul + */ + + if ((prop = node.property (X_("original"))) == 0) { + throw failed_constructor (); + } + + set_id (prop->value()); + _level = _playlist->max_source_level () + 1; return 0;