Non-layered MIDI recording
[ardour.git] / libs / ardour / session_state.cc
index 0bf09f76c696e7a0c48c3f55b20a91a591aadd69..19bfc4c41c44a54c6e2fd9e4f52883f202610019 100644 (file)
@@ -78,7 +78,6 @@
 
 #include "ardour/amp.h"
 #include "ardour/async_midi_port.h"
-#include "ardour/audio_diskstream.h"
 #include "ardour/audio_track.h"
 #include "ardour/audioengine.h"
 #include "ardour/audiofilesource.h"
@@ -90,6 +89,7 @@
 #include "ardour/controllable_descriptor.h"
 #include "ardour/control_protocol_manager.h"
 #include "ardour/directory_names.h"
+#include "ardour/disk_reader.h"
 #include "ardour/filename_extensions.h"
 #include "ardour/graph.h"
 #include "ardour/location.h"
@@ -286,7 +286,7 @@ Session::post_engine_init ()
                _engine.GraphReordered.connect_same_thread (*this, boost::bind (&Session::graph_reordered, this));
                _engine.MidiSelectionPortsChanged.connect_same_thread (*this, boost::bind (&Session::rewire_midi_selection_ports, this));
 
-               AudioDiskstream::allocate_working_buffers();
+               DiskReader::allocate_working_buffers();
                refresh_disk_space ();
 
                /* we're finally ready to call set_state() ... all objects have
@@ -408,7 +408,7 @@ Session::post_engine_init ()
        boost::shared_ptr<RouteList> rl = routes.reader();
        for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
                boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<Track> (*r);
-               if (trk && !trk->hidden()) {
+               if (trk && !trk->is_private_route()) {
                        trk->seek (_transport_frame, true);
                }
        }
@@ -1610,15 +1610,6 @@ Session::set_state (const XMLNode& node, int version)
                }
        }
 
-       if (version < 3000) {
-               if ((child = find_named_node (node, X_("DiskStreams"))) == 0) {
-                       error << _("Session: XML state has no diskstreams section") << endmsg;
-                       goto out;
-               } else if (load_diskstreams_2X (*child, version)) {
-                       goto out;
-               }
-       }
-
        if ((child = find_named_node (node, VCAManager::xml_node_name)) != 0) {
                _vca_manager->set_state (*child, version);
        }
@@ -1634,9 +1625,6 @@ Session::set_state (const XMLNode& node, int version)
 
        Slavable::Assign (_vca_manager); /* EMIT SIGNAL */
 
-       /* our diskstreams list is no longer needed as they are now all owned by their Route */
-       _diskstreams_2X.clear ();
-
        if (version >= 3000) {
 
                if ((child = find_named_node (node, "RouteGroups")) == 0) {
@@ -1757,14 +1745,20 @@ Session::XMLRouteFactory (const XMLNode& node, int version)
                return ret;
        }
 
-       XMLNode* ds_child = find_named_node (node, X_("Diskstream"));
+       XMLProperty const * pl_prop = node.property (X_("audio-playlist"));
+
+       if (!pl_prop) {
+               pl_prop = node.property (X_("midi-playlist"));
+       }
 
        DataType type = DataType::AUDIO;
        node.get_property("default-type", type);
 
        assert (type != DataType::NIL);
 
-       if (ds_child) {
+       if (pl_prop) {
+
+               /* has at least 1 playlist, therefore a track ... */
 
                boost::shared_ptr<Track> track;
 
@@ -1819,15 +1813,12 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version)
 
        if (ds_prop) {
 
-               list<boost::shared_ptr<Diskstream> >::iterator i = _diskstreams_2X.begin ();
-               while (i != _diskstreams_2X.end() && (*i)->id() != ds_prop->value()) {
-                       ++i;
-               }
+               /* see comment in current ::set_state() regarding diskstream
+                * state and DiskReader/DiskWRiter.
+                */
 
-               if (i == _diskstreams_2X.end()) {
-                       error << _("Could not find diskstream for route") << endmsg;
-                       return boost::shared_ptr<Route> ();
-               }
+               error << _("Could not find diskstream for route") << endmsg;
+               return boost::shared_ptr<Route> ();
 
                boost::shared_ptr<Track> track;
 
@@ -1845,8 +1836,6 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version)
                        return ret;
                }
 
-               track->set_diskstream (*i);
-
                BOOST_MARK_TRACK (track);
                ret = track;
 
@@ -2414,12 +2403,14 @@ Session::save_template (const string& template_name, const string& description,
        XMLNode* root;
        {
                PBD::Unwinder<std::string> uw (_template_state_dir, template_dir_path);
-               root = &get_template();
+               root = &get_template ();
        }
 
+       root->remove_nodes_and_delete (X_("description"));
+
        if (!description.empty()) {
-               XMLNode* desc = new XMLNode(X_("description"));
-               XMLNode* desc_cont = new XMLNode(X_("content"), description);
+               XMLNode* desc = new XMLNode (X_("description"));
+               XMLNode* desc_cont = new XMLNode (X_("content"), description);
                desc->add_child_nocopy (*desc_cont);
 
                root->add_child_nocopy (*desc);
@@ -4178,35 +4169,6 @@ Session::set_history_depth (uint32_t d)
        _history.set_depth (d);
 }
 
-int
-Session::load_diskstreams_2X (XMLNode const & node, int)
-{
-       XMLNodeList          clist;
-       XMLNodeConstIterator citer;
-
-       clist = node.children();
-
-       for (citer = clist.begin(); citer != clist.end(); ++citer) {
-
-               try {
-                       /* diskstreams added automatically by DiskstreamCreated handler */
-                       if ((*citer)->name() == "AudioDiskstream" || (*citer)->name() == "DiskStream") {
-                               boost::shared_ptr<AudioDiskstream> dsp (new AudioDiskstream (*this, **citer));
-                               _diskstreams_2X.push_back (dsp);
-                       } else {
-                               error << _("Session: unknown diskstream type in XML") << endmsg;
-                       }
-               }
-
-               catch (failed_constructor& err) {
-                       error << _("Session: could not load diskstream via XML state") << endmsg;
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
 /** Connect things to the MMC object */
 void
 Session::setup_midi_machine_control ()