substantial part of infrastructure required for track/bus duplication
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Nov 2015 21:14:09 +0000 (16:14 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Nov 2015 21:14:49 +0000 (16:14 -0500)
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

libs/ardour/ardour/route.h
libs/ardour/ardour/session.h
libs/ardour/ardour/types.h
libs/ardour/diskstream.cc
libs/ardour/route.cc
libs/ardour/session.cc

index 7e428ed6e2c3fc29edfa0a6b94ff47d7cc7f507c..31c8b09ceceebe57b414a22141ed19c08306c1d3 100644 (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;
index 0a2cb786ced68d9e4dd7d5f989fed4691f2f247e..ada8d1ab9cbb82275c31484cde269292b08217b6 100644 (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);
index 4ad1391abe209df46b1476fe1c02cde0923e6235..1a17c01f86c0ecb51cf23f918ba17788086db7af 100644 (file)
@@ -647,6 +647,12 @@ namespace ARDOUR {
                RegionSelectionStart = 0x8,
        };
 
+       enum PlaylistDisposition {
+               CopyPlaylist,
+               NewPlaylist,
+               SharePlaylist
+       };
+
 } // namespace ARDOUR
 
 
index fda55c29e93be8f76efe5e8413bee31eab7ed855..7f4214037d6a2bbe1b12450cedd1cd3eaee4d7b2 100644 (file)
@@ -864,4 +864,3 @@ Diskstream::get_buffering_presets (BufferingPreset bp,
 
        return true;
 }
-
index 65f4531ac88e7cd158c2538b322ffc5380eb2d5c..babec9ea741c394e441159b16f64f822fb8f0b4e 100644 (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")) {
 
-                       (*i)->add_property (X_("playlist"), string_compose ("%1.1", name).c_str());
+                       if (rename_playlist) {
+                               (*i)->add_property (X_("playlist"), string_compose ("%1.1", name).c_str());
+                       }
                        (*i)->add_property (X_("name"), name);
 
                }
index f57731b2454ce9bdc3cbd4c2ab758c4ad5213fcd..36e05e2f3eb5c7ebc1ca31dfc818d1d56b815a57 100644 (file)
@@ -180,7 +180,7 @@ Session::Session (AudioEngine &eng,
        , current_block_size (0)
        , _worst_output_latency (0)
        , _worst_input_latency (0)
-       , _worst_track_latency (0)
+       , _worst_track_latency (0)
        , _have_captured (false)
        , _non_soloed_outs_muted (false)
        , _listen_cnt (0)
@@ -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)
 {
-       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;
+               return RouteList();
        }
 
-       XMLNode* node = tree.root();
+       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;
+       uint32_t number = 0;
+       const uint32_t being_added = how_many;
+       /* 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 ();