First revision with working track import

git-svn-id: svn://localhost/ardour2/branches/3.0@4270 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sakari Bergen 2008-11-29 20:16:16 +00:00
parent 4af523ca38
commit a8cc30be5f
10 changed files with 60 additions and 15 deletions

View 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;

View 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;

View file

@ -54,6 +54,7 @@ class AudioTrackImporter : public ElementImporter
AudioTrackImportHandler & track_handler,
XMLNode const & node,
AudioPlaylistImportHandler & pl_handler);
~AudioTrackImporter ();
string get_info () const;

View 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

View 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 */

View file

@ -134,6 +134,11 @@ AudioPlaylistImporter::AudioPlaylistImporter (AudioPlaylistImporter const & othe
populate_region_list ();
}
AudioPlaylistImporter::~AudioPlaylistImporter ()
{
}
string
AudioPlaylistImporter::get_info () const
{

View 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
{

View 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

View 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);
}

View file

@ -51,7 +51,6 @@ ElementImporter::ElementImporter (XMLTree const & source, ARDOUR::Session & sess
ElementImporter::~ElementImporter ()
{
cancel_move ();
}
void