summaryrefslogtreecommitdiff
path: root/libs/ardour/session.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-07-22 14:52:05 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-07-22 14:52:05 +0000
commit1c1b359ff21aac57bd71d291049d657f66cf31f5 (patch)
treeb05cc2756c2ec751fd0567d7b7ffb0baa8c1767f /libs/ardour/session.cc
parent5c17bd3df225b958c2f8510ff03d38bbb513c150 (diff)
second (and hopefully) final part of changes to respond to header format changes sensibly: lookup existing files correctly, and don't end up with gapped "take" numbers for successive files since we now remove ::removable() sources when switching to new ones (for audio)
git-svn-id: svn://localhost/ardour2/branches/3.0@7470 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r--libs/ardour/session.cc78
1 files changed, 44 insertions, 34 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index e939ffc694..8618580314 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -2746,17 +2746,18 @@ Session::change_source_path_by_name (string path, string oldname, string newname
snprintf (buf, sizeof(buf), "%s-%u%s", newname.c_str(), cnt, suffix.c_str());
- string p = Glib::build_filename (dir, buf);
-
- if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
- path = p;
+ if (!matching_unsuffixed_filename_exists_in (dir, buf)) {
+ path = Glib::build_filename (dir, buf);
break;
}
+
path = "";
}
- if (path == "") {
- error << "FATAL ERROR! Could not find a " << endl;
+ if (path.empty()) {
+ fatal << string_compose (_("FATAL ERROR! Could not find a suitable version of %1 for a rename"),
+ newname) << endl;
+ /*NOTREACHED*/
}
}
@@ -2800,7 +2801,6 @@ Session::peak_path (Glib::ustring base) const
string
Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t chan, bool destructive)
{
- string spath;
uint32_t cnt;
char buf[PATH_MAX+1];
const uint32_t limit = 10000;
@@ -2818,55 +2818,60 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
for (i = session_dirs.begin(); i != session_dirs.end(); ++i) {
- SessionDirectory sdir((*i).path);
-
- spath = sdir.sound_path().to_string();
-
if (destructive) {
if (nchan < 2) {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%s",
- spath.c_str(), cnt, legalized.c_str(), ext.c_str());
+ snprintf (buf, sizeof(buf), "T%04d-%s%s",
+ cnt, legalized.c_str(), ext.c_str());
} else if (nchan == 2) {
if (chan == 0) {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%%L%s",
- spath.c_str(), cnt, legalized.c_str(), ext.c_str());
+ snprintf (buf, sizeof(buf), "T%04d-%s%%L%s",
+ cnt, legalized.c_str(), ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%%R%s",
- spath.c_str(), cnt, legalized.c_str(), ext.c_str());
+ snprintf (buf, sizeof(buf), "T%04d-%s%%R%s",
+ cnt, legalized.c_str(), ext.c_str());
}
} else if (nchan < 26) {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%%%c%s",
- spath.c_str(), cnt, legalized.c_str(), 'a' + chan, ext.c_str());
+ snprintf (buf, sizeof(buf), "T%04d-%s%%%c%s",
+ cnt, legalized.c_str(), 'a' + chan, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%s",
- spath.c_str(), cnt, legalized.c_str(), ext.c_str());
+ snprintf (buf, sizeof(buf), "T%04d-%s%s",
+ cnt, legalized.c_str(), ext.c_str());
}
} else {
- spath += '/';
- spath += legalized;
-
if (nchan < 2) {
- snprintf (buf, sizeof(buf), "%s-%u%s", spath.c_str(), cnt, ext.c_str());
+ snprintf (buf, sizeof(buf), "%s-%u%s", legalized.c_str(), cnt, ext.c_str());
} else if (nchan == 2) {
if (chan == 0) {
- snprintf (buf, sizeof(buf), "%s-%u%%L%s", spath.c_str(), cnt, ext.c_str());
+ snprintf (buf, sizeof(buf), "%s-%u%%L%s", legalized.c_str(), cnt, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s-%u%%R%s", spath.c_str(), cnt, ext.c_str());
+ snprintf (buf, sizeof(buf), "%s-%u%%R%s", legalized.c_str(), cnt, ext.c_str());
}
} else if (nchan < 26) {
- snprintf (buf, sizeof(buf), "%s-%u%%%c%s", spath.c_str(), cnt, 'a' + chan, ext.c_str());
+ snprintf (buf, sizeof(buf), "%s-%u%%%c%s", legalized.c_str(), cnt, 'a' + chan, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s-%u%s", spath.c_str(), cnt, ext.c_str());
+ snprintf (buf, sizeof(buf), "%s-%u%s", legalized.c_str(), cnt, ext.c_str());
}
}
- if (sys::exists(buf)) {
- existing++;
- }
+ SessionDirectory sdir((*i).path);
+
+ string spath = sdir.sound_path().to_string();
+ string spath_stubs = sdir.sound_stub_path().to_string();
+ /* note that we search *without* the extension so that
+ we don't end up both "Audio 1-1.wav" and "Audio 1-1.caf"
+ in the event that this new name is required for
+ a file format change.
+ */
+
+ if (matching_unsuffixed_filename_exists_in (spath, buf) ||
+ matching_unsuffixed_filename_exists_in (spath_stubs, buf)) {
+ existing++;
+ break;
+ }
}
if (existing == 0) {
@@ -2881,8 +2886,8 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
throw failed_constructor();
}
}
-
- return Glib::path_get_basename(buf);
+
+ return Glib::path_get_basename (buf);
}
/** Create a new within-session audio source */
@@ -3398,7 +3403,12 @@ Session::reset_native_file_format ()
for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
if (tr) {
+ /* don't save state as we do this, there's no point
+ */
+
+ _state_of_the_state = StateOfTheState (_state_of_the_state|InCleanup);
tr->reset_write_sources (false);
+ _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup);
}
}
}