fix logic of Session::audio_source_name_is_unique()

This commit is contained in:
Paul Davis 2015-02-20 14:12:12 -05:00
parent 7024232855
commit a2e4d6260c
2 changed files with 15 additions and 4 deletions

View 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);

View 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;
}