diff options
author | Robin Gareus <robin@gareus.org> | 2019-12-17 00:34:26 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-12-17 00:42:28 +0100 |
commit | 848831d844b8cdfe71bff611d7c0096361963f0c (patch) | |
tree | 72bbeaa2148ea9043571e2ea6e6caa1dd39a31d4 /libs/ardour | |
parent | c144e807effef3eef855fb4e24495f1d3801ae71 (diff) |
Convert Disksteam & Playlists from old 2.x sessions
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/session.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/session_playlists.h | 2 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 3 | ||||
-rw-r--r-- | libs/ardour/session_playlists.cc | 18 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 34 |
5 files changed, 54 insertions, 6 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index b4ecb87f59..14eecbae6a 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1817,6 +1817,9 @@ private: /* CURVES and AUTOMATION LISTS */ std::map<PBD::ID, AutomationList*> automation_lists; + /** load 2.X Sessions. Diskstream-ID to playlist-name mapping */ + std::map<PBD::ID, std::string> _diskstreams_2X; + /* DEFAULT FADE CURVES */ float default_fade_steepness; diff --git a/libs/ardour/ardour/session_playlists.h b/libs/ardour/ardour/session_playlists.h index 0cd9a61938..cd9c919e31 100644 --- a/libs/ardour/ardour/session_playlists.h +++ b/libs/ardour/ardour/session_playlists.h @@ -75,6 +75,8 @@ private: void track (bool, boost::weak_ptr<Playlist>); void update_tracking (); + void update_orig_2X (PBD::ID, PBD::ID); + void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result); void update_after_tempo_map_change (); void add_state (XMLNode*, bool save_template, bool include_unused); diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 893b67c4b5..f2249dcde9 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -2289,8 +2289,9 @@ Playlist::set_state (const XMLNode& node, int version) _set_sort_id (); } - /* XXX legacy session: fix up later */ + /* XXX legacy session: fix up later - :: update_orig_2X() */ node.get_property (X_("orig-diskstream-id"), _orig_track_id); + node.get_property (X_("orig_diskstream_id"), _orig_track_id); node.get_property (X_("orig-track-id"), _orig_track_id); node.get_property (X_("frozen"), _frozen); diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index 0201c3e71d..4bd47aa0eb 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -245,6 +245,24 @@ SessionPlaylists::unassigned (std::list<boost::shared_ptr<Playlist> > & list) } void +SessionPlaylists::update_orig_2X (PBD::ID old_orig, PBD::ID new_orig) +{ + Glib::Threads::Mutex::Lock lm (lock); + + for (List::iterator i = playlists.begin(); i != playlists.end(); ++i) { + if ((*i)->get_orig_track_id() == old_orig) { + (*i)->set_orig_track_id (new_orig); + } + } + + for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { + if ((*i)->get_orig_track_id() == old_orig) { + (*i)->set_orig_track_id (new_orig); + } + } +} + +void SessionPlaylists::get (vector<boost::shared_ptr<Playlist> >& s) const { Glib::Threads::Mutex::Lock lm (lock); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 605803d85f..9d56e4097b 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1685,6 +1685,20 @@ Session::set_state (const XMLNode& node, int version) _vca_manager->set_state (*child, version); } + if (version < 3000) { + if ((child = find_named_node (node, "DiskStreams"))) { + for (XMLNodeList::const_iterator n = child->children ().begin (); n != child->children ().end (); ++n) { + if ((*n)->name() == "AudioDiskstream" || (*n)->name() == "DiskStream") { + std::string diskstream_id; + std::string playlist_name; + if ((*n)->get_property ("playlist", playlist_name) && (*n)->get_property ("id", diskstream_id)) { + _diskstreams_2X [PBD::ID(diskstream_id)] = playlist_name; + } + } + } + } + } + if ((child = find_named_node (node, "Routes")) == 0) { error << _("Session: XML state has no routes section") << endmsg; goto out; @@ -1695,6 +1709,8 @@ Session::set_state (const XMLNode& node, int version) /* Now that we Tracks have been loaded and playlists are assigned */ _playlists->update_tracking (); + _diskstreams_2X.clear (); + /* Now that we have Routes and masters loaded, connect them if appropriate */ Slavable::Assign (_vca_manager); /* EMIT SIGNAL */ @@ -1941,12 +1957,15 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version) if (ds_prop) { - /* see comment in current ::set_state() regarding diskstream - * state and DiskReader/DiskWRiter. - */ + PBD::ID ds_id (ds_prop->value ()); + std::string playlist_name = _diskstreams_2X[ds_id]; + + boost::shared_ptr<Playlist> pl = playlists()->by_name (playlist_name); - error << _("Could not find diskstream for route") << endmsg; - return boost::shared_ptr<Route> (); + if (playlist_name.empty () || !pl) { + error << _("Could not find diskstream for route") << endmsg; + return boost::shared_ptr<Route> (); + } boost::shared_ptr<Track> track; @@ -1960,10 +1979,15 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version) return ret; } + track->use_playlist (DataType::AUDIO, pl); + if (track->set_state (node, version)) { return ret; } + pl->set_orig_track_id (track->id()); + playlists()->update_orig_2X (ds_id, track->id()); + BOOST_MARK_TRACK (track); ret = track; |