_path += '/';
}
+ set_history_depth (Config->get_history_depth());
+
+
/* these two are just provisional settings. set_state()
will likely override them.
*/
return -1;
}
- dir = automation_dir ();
-
- if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session automation dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
- return -1;
- }
-
dir = export_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
return 0;
}
+void
+Session::maybe_write_autosave()
+{
+ if (dirty() && record_status() != Recording) {
+ save_state("", true);
+ }
+}
+
void
Session::remove_pending_capture_state ()
{
tmp_path += snapshot_name;
tmp_path += ".tmp";
- cerr << "actually writing state\n";
+ // cerr << "actually writing state to " << xml_path << endl;
if (!tree.write (tmp_path)) {
error << string_compose (_("state could not be saved to %1"), tmp_path) << endmsg;
xmlpath += snapshot_name;
xmlpath += _pending_suffix;
- if (!access (xmlpath.c_str(), F_OK)) {
+ if (Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
/* there is pending state from a crashed capture attempt */
xmlpath += snapshot_name;
xmlpath += _statefile_suffix;
}
-
- if (access (xmlpath.c_str(), F_OK)) {
+
+ if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
error << string_compose(_("%1: session state information file \"%2\" doesn't exist!"), _name, xmlpath) << endmsg;
return 1;
}
if (is_old) {
string backup_path;
- backup_path = xmlpath;
- backup_path += ".1";
-
- info << string_compose (_("Copying old session file %1 to %2\nUse %2 with Ardour versions before 2.0 from now on"),
- xmlpath, backup_path)
- << endmsg;
+ backup_path = _path;
+ backup_path += snapshot_name;
+ backup_path += "-1";
+ backup_path += _statefile_suffix;
- copy_file (xmlpath, backup_path);
+ /* don't make another copy if it already exists */
- /* if it fails, don't worry. right? */
+ if (!Glib::file_test (backup_path, Glib::FILE_TEST_EXISTS)) {
+ info << string_compose (_("Copying old session file %1 to %2\nUse %2 with Ardour versions before 2.0 from now on"),
+ xmlpath, backup_path)
+ << endmsg;
+
+ copy_file (xmlpath, backup_path);
+
+ /* if it fails, don't worry. right? */
+ }
}
return 0;
// store libardour version, just in case
char buf[16];
snprintf(buf, sizeof(buf)-1, "%d.%d.%d",
- libardour_major_version, libardour_minor_version, libardour_micro_version);
+ libardour2_major_version, libardour2_minor_version, libardour2_micro_version);
node->add_property("version", string(buf));
/* store configuration settings */
snprintf (buf, sizeof(buf), "%s/%s-%" PRIu32 ".wav", dir.c_str(), name.c_str(), n);
}
- if (!g_file_test (buf, G_FILE_TEST_EXISTS)) {
+ if (!Glib::file_test (buf, Glib::FILE_TEST_EXISTS)) {
return buf;
}
}
}
}
+ char tmppath1[PATH_MAX+1];
+ char tmppath2[PATH_MAX+1];
+
for (vector<string*>::iterator x = soundfiles->begin(); x != soundfiles->end(); ++x) {
used = false;
for (set<string>::iterator i = all_sources.begin(); i != all_sources.end(); ++i) {
- if (strcmp(canonicalize_file_name(spath.c_str()), canonicalize_file_name( (*i).c_str())) == 0) {
+ realpath(spath.c_str(), tmppath1);
+ realpath((*i).c_str(), tmppath2);
+
+ if (strcmp(tmppath1, tmppath2) == 0) {
used = true;
break;
}
Config->add_instant_xml (node, get_user_ardour_path());
}
-
int
Session::save_history (string snapshot_name)
{
string xml_path;
string bak_path;
- tree.set_root (&_history.get_state (Config->get_saved_history_depth()));
-
if (snapshot_name.empty()) {
snapshot_name = _current_snapshot_name;
}
bak_path = xml_path + ".bak";
- if ((access (xml_path.c_str(), F_OK) == 0) &&
- (rename (xml_path.c_str(), bak_path.c_str())))
- {
+ if (Glib::file_test (xml_path, Glib::FILE_TEST_EXISTS) && ::rename (xml_path.c_str(), bak_path.c_str())) {
error << _("could not backup old history file, current history not saved.") << endmsg;
return -1;
}
+ if (!Config->get_save_history() || Config->get_saved_history_depth() < 0) {
+ return 0;
+ }
+
+ tree.set_root (&_history.get_state (Config->get_saved_history_depth()));
+
if (!tree.write (xml_path))
{
error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg;
xmlpath = _path + snapshot_name + ".history";
cerr << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg;
- if (access (xmlpath.c_str(), F_OK)) {
- info << string_compose (_("%1: no history file \"%2\" for this session."), _name, xmlpath) << endmsg;
+ if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
return 1;
}
} else if (PARAM_IS ("use-video-sync")) {
- if (transport_stopped()) {
- if (Config->get_use_video_sync()) {
- waiting_for_sync_offset = true;
- }
- }
+ waiting_for_sync_offset = Config->get_use_video_sync();
} else if (PARAM_IS ("mmc-control")) {
poke_midi_thread ();
- } else if (PARAM_IS ("mmc-device-id")) {
+ } else if (PARAM_IS ("mmc-device-id") || PARAM_IS ("mmc-receive-device-id")) {
- if (mmc) {
- mmc->set_device_id (Config->get_mmc_device_id());
- }
+ set_mmc_receive_device_id (Config->get_mmc_receive_device_id());
+
+ } else if (PARAM_IS ("mmc-send-device-id")) {
+
+ set_mmc_send_device_id (Config->get_mmc_send_device_id());
} else if (PARAM_IS ("midi-control")) {
set_slave_source (Config->get_slave_source());
} else if (PARAM_IS ("remote-model")) {
set_remote_control_ids ();
+ } else if (PARAM_IS ("denormal-model")) {
+ setup_fpu ();
+ } else if (PARAM_IS ("history-depth")) {
+ set_history_depth (Config->get_history_depth());
+ } else if (PARAM_IS ("sync-all-route-ordering")) {
+ sync_order_keys ();
}
set_dirty ();
#undef PARAM_IS
}
+
+void
+Session::set_history_depth (uint32_t d)
+{
+ _history.set_depth (d);
+}