First revision with working track import
authorSakari Bergen <sakari.bergen@beatwaves.net>
Sat, 29 Nov 2008 20:16:16 +0000 (20:16 +0000)
committerSakari Bergen <sakari.bergen@beatwaves.net>
Sat, 29 Nov 2008 20:16:16 +0000 (20:16 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4270 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audio_playlist_importer.h
libs/ardour/ardour/audio_region_importer.h
libs/ardour/ardour/audio_track_importer.h
libs/ardour/ardour/element_import_handler.h
libs/ardour/ardour/session.h
libs/ardour/audio_playlist_importer.cc
libs/ardour/audio_region_importer.cc
libs/ardour/audio_track_importer.cc
libs/ardour/element_import_handler.cc
libs/ardour/element_importer.cc

index b94523128f53f7b70f2a0d84d93d30901a61c459..3a543674959316259c2e840b9b1574b8fe176cbf 100644 (file)
@@ -72,6 +72,7 @@ class AudioPlaylistImporter : public ElementImporter
   public:
        AudioPlaylistImporter (XMLTree const & source, Session & session, AudioPlaylistImportHandler & handler, XMLNode const & node);
        AudioPlaylistImporter (AudioPlaylistImporter const & other);
+       ~AudioPlaylistImporter ();
 
        string get_info () const;
        
index 8123f89e4206e4eff8e04b7181be4e0251418ae6..c968fc812918cc443c23f404172f5ef67e2524d8 100644 (file)
@@ -72,6 +72,7 @@ class AudioRegionImporter : public ElementImporter
 {
   public:
        AudioRegionImporter (XMLTree const & source, Session & session, AudioRegionImportHandler & handler, XMLNode const & node);
+       ~AudioRegionImporter ();
 
        // Interface implementation
        string get_info () const;
index 6beee4a408dc9cf43e6641e83826257f6173038a..87b3b25177ef31e0ae86ad74207792dff343b17b 100644 (file)
@@ -54,6 +54,7 @@ class AudioTrackImporter : public ElementImporter
                            AudioTrackImportHandler & track_handler,
                            XMLNode const & node,
                            AudioPlaylistImportHandler & pl_handler);
+       ~AudioTrackImporter ();
 
        string get_info () const;
 
index 9393c315595855b86bb32e308fe697281e48a9cf..f56d3ce76d7cdfd0c7eade25b35ae6ebdf0a40a1 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <string>
 #include <list>
+#include <set>
 
 #include <boost/shared_ptr.hpp>
 
@@ -101,8 +102,8 @@ class ElementImportHandler
        static bool _errors;
        
   private:
-       /// List of names for duplicate checking
-       std::list<string> names;
+       /// Set of names for duplicate checking
+       std::set<string> names;
 };
 
 } // namespace ARDOUR
index 14e8c6d84170279a07746cda871e16df22e7e031..a5245b73f840abc0390a9dcf2880f3d9680a5e84 100644 (file)
@@ -307,6 +307,7 @@ class Session : public PBD::StatefulDestructible
        typedef std::list<boost::shared_ptr<Diskstream> > DiskstreamList;
        typedef std::list<boost::shared_ptr<Route> >      RouteList;
 
+       int load_routes (const XMLNode&);
        boost::shared_ptr<RouteList> get_routes() const {
                return routes.reader ();
        }
@@ -1446,7 +1447,6 @@ class Session : public PBD::StatefulDestructible
        void   add_routes (RouteList&, bool save);
        uint32_t destructive_index;
 
-       int load_routes (const XMLNode&);
        boost::shared_ptr<Route> XMLRouteFactory (const XMLNode&);
 
        /* mixer stuff */
index 0318a4ed540d571fbc52b4d1e025910cc99fe609..50aa6f222580c3e175e3738a5ac889d9e1ef777d 100644 (file)
@@ -134,6 +134,11 @@ AudioPlaylistImporter::AudioPlaylistImporter (AudioPlaylistImporter const & othe
        populate_region_list ();
 }
 
+AudioPlaylistImporter::~AudioPlaylistImporter ()
+{
+       
+}
+
 string
 AudioPlaylistImporter::get_info () const
 {
index 142b96bcad6c9cd92044671f17a983752604e0dd..714446bfe2fc718a3fff76b5313ac2d0d5d79b1b 100644 (file)
@@ -118,6 +118,10 @@ AudioRegionImporter::AudioRegionImporter (XMLTree const & source, Session & sess
        handler.register_id (old_id, id);
 }
 
+AudioRegionImporter::~AudioRegionImporter ()
+{
+}
+
 string
 AudioRegionImporter::get_info () const
 {
index 016f133bb00b3211c19f45e15d7e808840ecbf76..0f17323dc684a04c5c20107b0766ea6a4e01edf2 100644 (file)
@@ -21,6 +21,7 @@
 #include <ardour/audio_track_importer.h>
 
 #include <ardour/audio_playlist_importer.h>
+#include <ardour/audio_diskstream.h>
 #include <ardour/session.h>
 
 #include <pbd/failed_constructor.h>
@@ -70,7 +71,7 @@ AudioTrackImportHandler::get_info () const
 
 AudioTrackImporter::AudioTrackImporter (XMLTree const & source,
                                         Session & session,
-                                        AudioTrackImportHandler & handler,
+                                        AudioTrackImportHandler & track_handler,
                                         XMLNode const & node,
                                         AudioPlaylistImportHandler & pl_handler) :
   ElementImporter (source, session),
@@ -102,6 +103,11 @@ AudioTrackImporter::AudioTrackImporter (XMLTree const & source,
        xml_track.remove_nodes_and_delete ("extra");
 }
 
+AudioTrackImporter::~AudioTrackImporter ()
+{
+       playlists.clear ();
+}
+
 bool
 AudioTrackImporter::parse_route_xml ()
 {
@@ -148,6 +154,10 @@ AudioTrackImporter::parse_io ()
                return false;
        }
        
+       // TODO
+       io->remove_property ("inputs");
+       io->remove_property ("outputs");
+       
        XMLPropertyList const & props = io->properties();
 
        for (XMLPropertyList::const_iterator it = props.begin(); it != props.end(); ++it) {
@@ -232,7 +242,6 @@ AudioTrackImporter::_prepare_move ()
        xml_track.child ("IO")->property ("name")->set_value (name);
        track_handler.add_name (name);
        
-       // TODO
        return true;
 }
 
@@ -241,13 +250,40 @@ AudioTrackImporter::_cancel_move ()
 {
        track_handler.remove_name (name);
        playlists.clear ();
-       // TODO
 }
 
 void
 AudioTrackImporter::_move ()
-{
-       // TODO
+{      
+       /* Add diskstream */
+       
+       boost::shared_ptr<XMLSharedNodeList> ds_node_list;
+       string xpath = "/Session/DiskStreams/AudioDiskstream[@id='" + old_ds_id.to_s() + "']";
+       ds_node_list = source.root()->find (xpath);
+       
+       if (ds_node_list->size() != 1) {
+               error << string_compose (_("Error Importing Audio track %1"), name) << endmsg;
+               return;
+       }
+       
+       boost::shared_ptr<XMLNode> ds_node = ds_node_list->front();
+       ds_node->property ("id")->set_value (new_ds_id.to_s());
+       
+       boost::shared_ptr<Diskstream> new_ds (new AudioDiskstream (session, *ds_node));
+       new_ds->set_name (name);
+       session.add_diskstream (new_ds);
+
+       /* Import playlists */
+
+       for (PlaylistList::const_iterator it = playlists.begin(); it != playlists.end(); ++it) {
+               (*it)->move ();
+       }
+
+       /* Import track */
+
+       XMLNode routes ("Routes");
+       routes.add_child_copy (xml_track);
+       session.load_routes (routes);
 }
 
 bool
index 013dd3fe4489609553523e553d6d0b28a82f0457..3169da436e7cb113e11886439cf6642b8bf01ce9 100644 (file)
@@ -36,20 +36,17 @@ ElementImportHandler::~ElementImportHandler ()
 bool
 ElementImportHandler::check_name (const string & name) const
 {
-       return std::find (names.begin(), names.end(), name) == names.end();
+       return !names.count (name);
 }
 
 void
 ElementImportHandler::add_name (string name)
 {
-       names.push_back (name);
+       names.insert (name);
 }
 
 void
 ElementImportHandler::remove_name (const string & name)
 {
-       std::list<string>::iterator it = std::find (names.begin(), names.end(), name);
-       if (it != names.end()) {
-               names.erase(it);
-       }
+       names.erase (name);
 }
index af8dd770dadfbf9812a836ce3869327902b9d469..580c2876ad52c5335519a380468cf586436d65a5 100644 (file)
@@ -51,7 +51,6 @@ ElementImporter::ElementImporter (XMLTree const & source, ARDOUR::Session & sess
 
 ElementImporter::~ElementImporter ()
 {
-       cancel_move ();
 }
 
 void