From a2e4d6260ccff17c36a288fb60811062f4bc16dd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 20 Feb 2015 14:12:12 -0500 Subject: [PATCH] fix logic of Session::audio_source_name_is_unique() --- libs/ardour/ardour/session.h | 2 +- libs/ardour/session.cc | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ef0d5d94f4..50c4c229ea 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -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); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 3bdee5d6a1..a54afa6293 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -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 sdirs = source_search_path (DataType::AUDIO); vector::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; }