*/
-#include <ardour/audio_track_importer.h>
+#include "ardour/audio_track_importer.h"
-#include <ardour/audio_playlist_importer.h>
-#include <ardour/session.h>
+#include "ardour/audio_playlist_importer.h"
+#include "ardour/audio_diskstream.h"
+#include "ardour/session.h"
-#include <pbd/failed_constructor.h>
-#include <pbd/convert.h>
+#include "pbd/failed_constructor.h"
+#include "pbd/convert.h"
#include <sstream>
+#include <algorithm>
#include "i18n.h"
AudioTrackImporter::AudioTrackImporter (XMLTree const & source,
Session & session,
- AudioTrackImportHandler & handler,
+ AudioTrackImportHandler & track_handler,
XMLNode const & node,
AudioPlaylistImportHandler & pl_handler) :
ElementImporter (source, session),
throw failed_constructor();
}
- XMLNodeList const & controllables = node.children ("controllable");
+ XMLNodeList const & controllables = node.children ("Controllable");
for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
parse_controllable (**it);
}
- XMLNode * remote_control = xml_track.child ("remote_control");
+ XMLNode * remote_control = xml_track.child ("RemoteControl");
if (remote_control && (prop = remote_control->property ("id"))) {
uint32_t control_id = session.ntracks() + session.nbusses() + 1;
prop->set_value (to_string (control_id, std::dec));
}
- xml_track.remove_nodes_and_delete ("extra");
+ xml_track.remove_nodes_and_delete ("Extra");
+}
+
+AudioTrackImporter::~AudioTrackImporter ()
+{
+ playlists.clear ();
}
bool
(*it)->set_value (id.to_s());
id_ok = true;
} else if (!prop.compare("inputs")) {
- // TODO Let the IO class do it's thing for now...
+ // TODO Handle this properly!
+ /* Input and output ports are counted and added empty, so that no in/output connecting function fails. */
+ uint32_t num_inputs = std::count ((*it)->value().begin(), (*it)->value().end(), '{');
+ std::string value;
+ for (uint32_t i = 0; i < num_inputs; i++) { value += "{}"; }
+ (*it)->set_value (value);
} else if (!prop.compare("outputs")) {
- // TODO Let the IO class do it's thing for now...
+ // TODO See comments above
+ uint32_t num_outputs = std::count ((*it)->value().begin(), (*it)->value().end(), '{');
+ std::string value;
+ for (uint32_t i = 0; i < num_outputs; i++) { value += "{}"; }
+ (*it)->set_value (value);
} else {
std::cerr << string_compose (X_("AudioTrackImporter: did not recognise XML-property \"%1\""), prop) << endmsg;
}
return false;
}
- XMLNodeList const & controllables = io->children ("controllable");
+ XMLNodeList const & controllables = io->children ("Controllable");
for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
parse_controllable (**it);
}
xml_track.child ("IO")->property ("name")->set_value (name);
track_handler.add_name (name);
- // TODO
return true;
}
{
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