fix logic of Session::audio_source_name_is_unique()
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 20 Feb 2015 19:12:12 +0000 (14:12 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 20 Feb 2015 19:12:40 +0000 (14:12 -0500)
libs/ardour/ardour/session.h
libs/ardour/session.cc

index ef0d5d94f490709e7604f20d963e0e0c489b40f2..50c4c229ea20a32f1613bafadc7e7bef0a317e39 100644 (file)
@@ -193,7 +193,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        std::string peak_path (std::string) const;
 
        std::string peak_path_from_audio_path (std::string) const;
-       bool audio_source_name_is_unique (const std::string& name, uint32_t chan);
+       bool audio_source_name_is_unique (const std::string& name);
        std::string format_audio_source_name (const std::string& legalized_base, uint32_t nchan, uint32_t chan, bool destructive, bool take_required, uint32_t cnt, bool related_exists);
        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);
index 3bdee5d6a115a22393a55620e95caaab5b27167f..a54afa6293468539e4b4f95f252b4ea41264dbb7 100644 (file)
@@ -3638,8 +3638,19 @@ Session::new_audio_source_path_for_embedded (const std::string& path)
        return newpath;
 }
 
+/** Return true if there are no audio file sources that use @param name as 
+ * the filename component of their path. 
+ *
+ * Return false otherwise.
+ *
+ * This method MUST ONLY be used to check in-session, mono files since it 
+ * hard-codes the channel of the audio file source we are looking for as zero.
+ * 
+ * If/when Ardour supports native files in non-mono formats, the logic here
+ * will need to be revisited.
+ */
 bool
-Session::audio_source_name_is_unique (const string& name, uint32_t chan)
+Session::audio_source_name_is_unique (const string& name)
 {
        std::vector<string> sdirs = source_search_path (DataType::AUDIO);
        vector<space_and_path>::iterator i;
@@ -3672,7 +3683,7 @@ Session::audio_source_name_is_unique (const string& name, uint32_t chan)
                
                string possible_path = Glib::build_filename (spath, name);
 
-               if (audio_source_by_path_and_channel (possible_path, chan)) {
+               if (audio_source_by_path_and_channel (possible_path, 0)) {
                        existing++;
                        break;
                }
@@ -3740,7 +3751,7 @@ Session::new_audio_source_path (const string& base, uint32_t nchan, uint32_t cha
 
                possible_name = format_audio_source_name (legalized, nchan, chan, destructive, take_required, cnt, some_related_source_name_exists);
                
-               if (audio_source_name_is_unique (possible_name, chan)) {
+               if (audio_source_name_is_unique (possible_name)) {
                        break;
                }