13
0

substantial part of infrastructure required for track/bus duplication

This includes removing the removal of ID values in XML, and its replacement with
thread-local forcing of ID resets, implemented in a previous commit
This commit is contained in:
Paul Davis 2015-11-13 16:14:09 -05:00
parent f5e71fd817
commit b6925e274f
6 changed files with 47 additions and 19 deletions

View File

@ -101,7 +101,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
void set_comment (std::string str, void *src);
bool set_name (const std::string& str);
static void set_name_in_state (XMLNode &, const std::string &);
static void set_name_in_state (XMLNode &, const std::string &, bool rename_playlist = true);
uint32_t order_key () const;
bool has_order_key () const;

View File

@ -218,7 +218,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
std::string new_audio_source_path_for_embedded (const std::string& existing_path);
std::string new_audio_source_path (const std::string&, uint32_t nchans, uint32_t chan, bool destructive, bool take_required);
std::string new_midi_source_path (const std::string&);
RouteList new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name);
RouteList new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name, PlaylistDisposition pd = NewPlaylist);
RouteList new_route_from_template (uint32_t how_many, XMLNode&, const std::string& name, PlaylistDisposition pd = NewPlaylist);
std::vector<std::string> get_paths_for_new_sources (bool allow_replacing, const std::string& import_file_path, uint32_t channels);
int bring_all_sources_into_session (boost::function<void(uint32_t,uint32_t,std::string)> callback);

View File

@ -647,6 +647,12 @@ namespace ARDOUR {
RegionSelectionStart = 0x8,
};
enum PlaylistDisposition {
CopyPlaylist,
NewPlaylist,
SharePlaylist
};
} // namespace ARDOUR

View File

@ -864,4 +864,3 @@ Diskstream::get_buffering_presets (BufferingPreset bp,
return true;
}

View File

@ -4172,7 +4172,7 @@ Route::set_name (const string& str)
* @param name New name.
*/
void
Route::set_name_in_state (XMLNode& node, string const & name)
Route::set_name_in_state (XMLNode& node, string const & name, bool rename_playlist)
{
node.add_property (X_("name"), name);
@ -4192,7 +4192,9 @@ Route::set_name_in_state (XMLNode& node, string const & name)
} else if ((*i)->name() == X_("Diskstream")) {
if (rename_playlist) {
(*i)->add_property (X_("playlist"), string_compose ("%1.1", name).c_str());
}
(*i)->add_property (X_("name"), name);
}

View File

@ -3032,30 +3032,39 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
}
RouteList
Session::new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name_base)
Session::new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name_base, PlaylistDisposition pd)
{
XMLTree tree;
if (!tree.read (template_path.c_str())) {
return RouteList();
}
return new_route_from_template (how_many, *tree.root(), name_base, pd);
}
RouteList
Session::new_route_from_template (uint32_t how_many, XMLNode& node, const std::string& name_base, PlaylistDisposition pd)
{
RouteList ret;
uint32_t control_id;
XMLTree tree;
uint32_t number = 0;
const uint32_t being_added = how_many;
if (!tree.read (template_path.c_str())) {
return ret;
}
XMLNode* node = tree.root();
/* This will prevent the use of any existing XML-provided PBD::ID
values by Stateful.
*/
Stateful::ForceIDRegeneration force_ids;
IO::disable_connecting ();
control_id = next_control_id ();
while (how_many) {
XMLNode node_copy (*node);
/* We're going to modify the node contents a bit so take a
* copy. The node may be re-used when duplicating more than once.
*/
/* Remove IDs of everything so that new ones are used */
node_copy.remove_property_recursively (X_("id"));
XMLNode node_copy (node);
try {
string name;
@ -3084,7 +3093,18 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template
}
/* set this name in the XML description that we are about to use */
Route::set_name_in_state (node_copy, name);
bool rename_playlist;
switch (pd) {
case NewPlaylist:
case CopyPlaylist:
rename_playlist = true;
break;
case SharePlaylist:
rename_playlist = false;
}
Route::set_name_in_state (node_copy, name, rename_playlist);
/* trim bitslots from listen sends so that new ones are used */
XMLNodeList children = node_copy.children ();