X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fplaylist_source.cc;h=0b76a3c3a92ba87523b2d16829465cbc15bdde70;hb=3c7dea43af9d9e5b2563aee81ac5253fb2ee7858;hp=a1597a76d2335d4d53c83afdc4e103796d4ee439;hpb=99aa8c6338e47b41143f799fdcb35d1699548076;p=ardour.git diff --git a/libs/ardour/playlist_source.cc b/libs/ardour/playlist_source.cc index a1597a76d2..0b76a3c3a9 100644 --- a/libs/ardour/playlist_source.cc +++ b/libs/ardour/playlist_source.cc @@ -27,26 +27,24 @@ #include #include "pbd/error.h" -#include "pbd/convert.h" +#include "pbd/types_convert.h" #include "pbd/enumwriter.h" #include "ardour/playlist.h" #include "ardour/playlist_source.h" #include "ardour/playlist_factory.h" -#include "ardour/session.h" -#include "ardour/session_playlists.h" -#include "ardour/source_factory.h" -#include "i18n.h" +#include "pbd/i18n.h" 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, + sampleoffset_t begin, samplecnt_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)); @@ -63,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 (); @@ -77,24 +75,20 @@ PlaylistSource::~PlaylistSource () void PlaylistSource::add_state (XMLNode& node) { - char buf[64]; - - _playlist->id().print (buf, sizeof (buf)); - node.add_property ("playlist", buf); - snprintf (buf, sizeof (buf), "%" PRIi64, _playlist_offset); - node.add_property ("offset", buf); - snprintf (buf, sizeof (buf), "%" PRIu64, _playlist_length); - node.add_property ("length", buf); - + node.set_property ("playlist", _playlist->id ()); + node.set_property ("offset", _playlist_offset); + node.set_property ("length", _playlist_length); + node.set_property ("original", id()); + node.add_child_nocopy (_playlist->get_state()); } int -PlaylistSource::set_state (const XMLNode& node, int version) +PlaylistSource::set_state (const XMLNode& node, int /*version*/) { /* check that we have a playlist ID */ - const XMLProperty *prop = node.property (X_("playlist")); + XMLProperty const * prop = node.property (X_("playlist")); if (!prop) { error << _("No playlist ID in PlaylistSource XML!") << endmsg; @@ -116,28 +110,37 @@ PlaylistSource::set_state (const XMLNode& node, int version) } if (!_playlist) { - error << _("No playlist node in PlaylistSource XML!") << endmsg; + error << _("Could not construct playlist for PlaylistSource from session data!") << endmsg; throw failed_constructor (); } /* other properties */ - if ((prop = node.property (X_("name"))) == 0) { + std::string name; + if (!node.get_property (X_("name"), name)) { throw failed_constructor (); } - - set_name (prop->value()); - if ((prop = node.property (X_("offset"))) == 0) { + set_name (name); + + if (!node.get_property (X_("offset"), _playlist_offset)) { throw failed_constructor (); } - sscanf (prop->value().c_str(), "%" PRIi64, &_playlist_offset); - if ((prop = node.property (X_("length"))) == 0) { + if (!node.get_property (X_("length"), _playlist_length)) { + throw failed_constructor (); + } + + /* XXX not quite sure why we set our ID back to the "original" one + here. october 2011, paul + */ + + std::string str; + if (!node.get_property (X_("original"), str)) { throw failed_constructor (); } - sscanf (prop->value().c_str(), "%" PRIu64, &_playlist_length); + set_id (str); _level = _playlist->max_source_level () + 1;