diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-11-09 22:18:52 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-11-09 22:18:52 +0000 |
commit | 84ddf22169c3aee19d3420b20c0e2f1b9bbdf02f (patch) | |
tree | bd0ea7e57c143d4d88abc957bafc3941a343d8a4 /libs | |
parent | 2575a3907b665e0ff3f151221e5c753c84d512ee (diff) |
handle multiple imports of the same file better (via better source naming); make session properties editor pretty much work for search paths
git-svn-id: svn://localhost/ardour2/branches/3.0@7989 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/session.h | 1 | ||||
-rw-r--r-- | libs/ardour/configuration.cc | 4 | ||||
-rw-r--r-- | libs/ardour/import.cc | 40 | ||||
-rw-r--r-- | libs/ardour/session.cc | 18 |
4 files changed, 49 insertions, 14 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 03e33a6446..91034cd034 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -541,6 +541,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi boost::shared_ptr<Source> source_by_id (const PBD::ID&); boost::shared_ptr<Source> source_by_path_and_channel (const std::string&, uint16_t); + uint32_t count_sources_by_origin (const std::string&); void add_playlist (boost::shared_ptr<Playlist>, bool unused = false); diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index d5ca426a74..dd863ee398 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -69,6 +69,9 @@ ConfigVariableBase::set_from_node (XMLNode const & node) if ((prop = child->property ("name")) != 0) { if (prop->value() == _name) { if ((prop = child->property ("value")) != 0) { + if (_name == "audio-search-path") { + sleep (1); + } set_from_string (prop->value()); return true; } @@ -94,6 +97,7 @@ ConfigVariableBase::set_from_node (XMLNode const & node) if (option->name() == _name) { if ((opt_prop = option->property ("val")) != 0) { + cerr << "Setting " << _name << " to " << opt_prop->value() << endl; set_from_string (opt_prop->value()); return true; } diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 4fc546ebd5..3dd2a99ee1 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -121,40 +121,52 @@ get_non_existent_filename (HeaderFormat hf, DataType type, const bool allow_repl { char buf[PATH_MAX+1]; bool goodfile = false; - string base(basename); + string base = basename; string ext = native_header_format_extension (hf, type); + uint32_t cnt = 1; do { if (type == DataType::AUDIO && channels == 2) { if (channel == 0) { - snprintf (buf, sizeof(buf), "%s-L%s", base.c_str(), ext.c_str()); + if (cnt == 1) { + snprintf (buf, sizeof(buf), "%s-L%s", base.c_str(), ext.c_str()); + } else { + snprintf (buf, sizeof(buf), "%s-%d-L%s", base.c_str(), cnt, ext.c_str()); + } } else { - snprintf (buf, sizeof(buf), "%s-R%s", base.c_str(), ext.c_str()); + if (cnt == 1) { + snprintf (buf, sizeof(buf), "%s-R%s", base.c_str(), ext.c_str()); + } else { + snprintf (buf, sizeof(buf), "%s-%d-R%s", base.c_str(), cnt, ext.c_str()); + } } } else if (channels > 1) { - snprintf (buf, sizeof(buf), "%s-c%d%s", base.c_str(), channel, ext.c_str()); + if (cnt == 1) { + snprintf (buf, sizeof(buf), "%s-c%d%s", base.c_str(), channel, ext.c_str()); + } else { + snprintf (buf, sizeof(buf), "%s-%d-c%d%s", base.c_str(), cnt, channel, ext.c_str()); + } } else { - snprintf (buf, sizeof(buf), "%s%s", base.c_str(), ext.c_str()); + if (cnt == 1) { + snprintf (buf, sizeof(buf), "%s%s", base.c_str(), ext.c_str()); + } else { + snprintf (buf, sizeof(buf), "%s-%d%s", base.c_str(), cnt, ext.c_str()); + } } - string tempname = destdir + "/" + buf; + if (!allow_replacing && Glib::file_test (tempname, Glib::FILE_TEST_EXISTS)) { - - /* if the file already exists, we must come up with - * a new name for it. for now we just keep appending - * _ to basename - */ - - base += "_"; + + cnt++; } else { goodfile = true; } - } while ( !goodfile); + } while (!goodfile); return buf; } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index c5aef9531c..7bc9b1ad12 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2741,6 +2741,24 @@ Session::source_by_path_and_channel (const string& path, uint16_t chn) return boost::shared_ptr<Source>(); } +uint32_t +Session::count_sources_by_origin (const string& path) +{ + uint32_t cnt = 0; + Glib::Mutex::Lock lm (source_lock); + + for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) { + boost::shared_ptr<FileSource> fs + = boost::dynamic_pointer_cast<FileSource>(i->second); + + if (fs && fs->origin() == path) { + ++cnt; + } + } + + return cnt; +} + string Session::change_source_path_by_name (string path, string oldname, string newname, bool destructive) |