#endif
#include <glibmm.h>
+#include <glibmm/thread.h>
#include <midi++/mmc.h>
#include <midi++/port.h>
-#include <pbd/error.h>
-#include <glibmm/thread.h>
+#include <pbd/error.h>
#include <pbd/pathscanner.h>
#include <pbd/pthread_utils.h>
#include <pbd/strsplit.h>
_path += '/';
}
+ if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS) && ::access (_path.c_str(), W_OK)) {
+ cerr << "Session non-writable based on " << _path << endl;
+ _writable = false;
+ } else {
+ cerr << "Session writable based on " << _path << endl;
+ _writable = true;
+ }
+
+ set_history_depth (Config->get_history_depth());
+
+
/* these two are just provisional settings. set_state()
will likely override them.
*/
_name = _current_snapshot_name = snapshot_name;
_current_frame_rate = _engine.frame_rate ();
+ _nominal_frame_rate = _current_frame_rate;
+ _base_frame_rate = _current_frame_rate;
+
_tempo_map = new TempoMap (_current_frame_rate);
_tempo_map->StateChanged.connect (mem_fun (*this, &Session::tempo_map_changed));
g_atomic_int_set (&processing_prohibited, 0);
+ post_transport_work = PostTransportWork (0);
insert_cnt = 0;
_transport_speed = 0;
_last_transport_speed = 0;
transport_sub_state = 0;
_transport_frame = 0;
last_stop_frame = 0;
+ _requested_return_frame = -1;
end_location = new Location (0, 0, _("end"), Location::Flags ((Location::IsMark|Location::IsEnd)));
start_location = new Location (0, 0, _("start"), Location::Flags ((Location::IsMark|Location::IsStart)));
_end_location_is_free = true;
g_atomic_int_set (&_record_status, Disabled);
loop_changing = false;
play_loop = false;
+ have_looped = false;
_last_roll_location = 0;
_last_record_location = 0;
pending_locate_frame = 0;
pending_locate_roll = false;
pending_locate_flush = false;
dstream_buffer_size = 0;
- state_tree = 0;
state_was_pending = false;
set_next_event ();
outbound_mtc_smpte_frame = 0;
current_block_size = 0;
solo_update_disabled = false;
currently_soloing = false;
+ _was_seamless = Config->get_seamless_loop ();
_have_captured = false;
_worst_output_latency = 0;
_worst_input_latency = 0;
_worst_track_latency = 0;
- _state_of_the_state = StateOfTheState(CannotSave|InitialConnecting|Loading|Deletion);
+ _state_of_the_state = StateOfTheState(CannotSave|InitialConnecting|Loading);
+
_slave = 0;
- butler_mixdown_buffer = 0;
- butler_gain_buffer = 0;
- mmc = 0;
+ _silent = false;
session_send_mmc = false;
session_send_mtc = false;
post_transport_work = PostTransportWork (0);
g_atomic_int_set (&_playback_load_min, 100);
g_atomic_int_set (&_capture_load_min, 100);
_play_range = false;
- waiting_to_start = false;
_exporting = false;
_gain_automation_buffer = 0;
_pan_automation_buffer = 0;
_npan_buffers = 0;
pending_abort = false;
+ pending_clear_substate = false;
destructive_index = 0;
current_trans = 0;
first_file_data_format_reset = true;
first_file_header_format_reset = true;
butler_thread = (pthread_t) 0;
- midi_thread = (pthread_t) 0;
AudioDiskstream::allocate_working_buffers();
waveforms for clicks.
*/
- click_data = 0;
- click_emphasis_data = 0;
click_length = 0;
click_emphasis_length = 0;
_clicking = false;
waiting_for_sync_offset = false;
}
- _current_frame_rate = 48000;
- _base_frame_rate = 48000;
-
last_smpte_when = 0;
_smpte_offset = 0;
_smpte_offset_negative = true;
/* slave stuff */
- average_slave_delta = 1800;
+ average_slave_delta = 1800; // !!! why 1800 ????
have_first_delta_accumulator = false;
delta_accumulator_cnt = 0;
slave_state = Stopped;
// set_state() will call setup_raid_path(), but if it's a new session we need
// to call setup_raid_path() here.
+
if (state_tree) {
if (set_state (*state_tree->root())) {
return -1;
_state_of_the_state = StateOfTheState (_state_of_the_state|CannotSave|Loading);
- // set_auto_input (true);
+
_locations.changed.connect (mem_fun (this, &Session::locations_changed));
_locations.added.connect (mem_fun (this, &Session::locations_added));
setup_click_sounds (0);
}
/* handle this one in a different way than all others, so that its clear what happened */
-
+
catch (AudioEngine::PortRegistrationFailure& err) {
- error << _("Unable to create all required ports")
- << endmsg;
- return -1;
+ destroy ();
+ throw;
}
catch (...) {
return -1;
}
+ BootMessage (_("Reset Remote Controls"));
+
send_full_time_code ();
_engine.transport_locate (0);
deliver_mmc (MIDI::MachineControl::cmdMmcReset, 0);
deliver_mmc (MIDI::MachineControl::cmdLocate, 0);
+ /* initial program change will be delivered later; see ::config_changed() */
+
+ BootMessage (_("Reset Control Protocols"));
+
ControlProtocolManager::instance().set_session (*this);
if (new_session) {
} else {
_end_location_is_free = false;
}
+
+ _state_of_the_state = Clean;
+
+ DirtyChanged (); /* EMIT SIGNAL */
+
+ if (state_was_pending) {
+ save_state (_current_snapshot_name);
+ remove_pending_capture_state ();
+ state_was_pending = false;
+ }
+ BootMessage (_("Session loading complete"));
+
return 0;
}
sp.path = path;
sp.blocks = 0;
session_dirs.push_back (sp);
-
- string fspath;
-
/* sounds dir */
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
-
- fspath += sound_dir (false);
-
- AudioFileSource::set_search_path (fspath);
-
+ AudioFileSource::set_search_path (Glib::build_filename(sp.path, sound_dir (false)));
return;
}
/* add sounds to file search path */
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += sound_dir (false);
+ fspath += Glib::build_filename(sp.path, sound_dir (false));
fspath += ':';
remaining = remaining.substr (colon+1);
sp.path = remaining;
fspath += ':';
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += sound_dir (false);
+ fspath += Glib::build_filename(sp.path, sound_dir (false));
fspath += ':';
session_dirs.push_back (sp);
}
int
-Session::create (bool& new_session, string* mix_template, nframes_t initial_length)
+Session::ensure_subdirs ()
{
string dir;
- if (g_mkdir_with_parents (_path.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session dir \"%1\" (%2)"), _path, strerror (errno)) << endmsg;
- return -1;
- }
-
dir = peak_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session peakfile dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
dir = sound_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ error << string_compose(_("Session: cannot create session sounds folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
}
dir = dead_sound_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session dead sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ error << string_compose(_("Session: cannot create session dead sounds folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
- dir = automation_dir ();
+ dir = export_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;
+ error << string_compose(_("Session: cannot create session export folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
- dir = export_dir ();
+ dir = analysis_dir ();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session export dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ error << string_compose(_("Session: cannot create session analysis folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+Session::create (bool& new_session, const string& mix_template, nframes_t initial_length)
+{
+
+ if (g_mkdir_with_parents (_path.c_str(), 0755) < 0) {
+ error << string_compose(_("Session: cannot create session folder \"%1\" (%2)"), _path, strerror (errno)) << endmsg;
return -1;
}
+ if (ensure_subdirs ()) {
+ return -1;
+ }
/* check new_session so we don't overwrite an existing one */
- if (mix_template) {
- std::string in_path = *mix_template;
+ if (!mix_template.empty()) {
+ std::string in_path = mix_template;
ifstream in(in_path.c_str());
_state_of_the_state = Clean;
- if (save_state (_current_snapshot_name)) {
- return -1;
- }
+ save_state ("");
return 0;
}
return 0;
}
+void
+Session::maybe_write_autosave()
+{
+ if (dirty() && record_status() != Recording) {
+ save_state("", true);
+ }
+}
+
void
Session::remove_pending_capture_state ()
{
string xml_path;
string bak_path;
- if (_state_of_the_state & CannotSave) {
+ if (!_writable || (_state_of_the_state & CannotSave)) {
return 1;
}
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;
bool was_dirty = dirty();
_state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty);
+
if (was_dirty) {
DirtyChanged (); /* EMIT SIGNAL */
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;
}
set_dirty();
+ /* writable() really reflects the whole folder, but if for any
+ reason the session state file can't be written to, still
+ make us unwritable.
+ */
+
+ if (::access (xmlpath.c_str(), W_OK) != 0) {
+ _writable = false;
+ }
+
if (!state_tree->read (xmlpath)) {
error << string_compose(_("Could not understand ardour file %1"), xmlpath) << endmsg;
delete state_tree;
if (is_old) {
string backup_path;
- backup_path = xmlpath;
- backup_path += ".1";
+ backup_path = _path;
+ backup_path += snapshot_name;
+ backup_path += "-1";
+ backup_path += _statefile_suffix;
- 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;
+ /* don't make another copy if it already exists */
- copy_file (xmlpath, backup_path);
-
- /* 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;
Config->set_variables (node, ConfigVariableBase::Session);
+ /* now reset MIDI ports because the session can have its own
+ MIDI configuration.
+ */
+
+ setup_midi ();
+
if ((child = find_named_node (node, "end-marker-is-free")) != 0) {
if ((prop = child->property ("val")) != 0) {
- _end_location_is_free = (prop->value() == "yes");
+ _end_location_is_free = string_is_affirmative (prop->value());
}
}
// 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);
+ snprintf(buf, sizeof(buf), "%d.%d.%d", libardour2_major_version, libardour2_minor_version, libardour2_micro_version);
node->add_property("version", string(buf));
/* store configuration settings */
if (full_state) {
- /* store the name */
node->add_property ("name", _name);
+ snprintf (buf, sizeof (buf), "%" PRId32, _nominal_frame_rate);
+ node->add_property ("sample-rate", buf);
if (session_dirs.size() > 1) {
_name = prop->value ();
}
+ if ((prop = node.property (X_("sample-rate"))) != 0) {
+
+ _nominal_frame_rate = atoi (prop->value());
+
+ if (_nominal_frame_rate != _current_frame_rate) {
+ if (AskAboutSampleRateMismatch (_nominal_frame_rate, _current_frame_rate)) {
+ throw SRMismatchRejected();
+ }
+ }
+ }
+
setup_raid_path(_path);
if ((prop = node.property (X_("id-counter"))) != 0) {
/* Object loading order:
- MIDI
Path
extra
Options/Config
+ MIDI <= relies on data from Options/Config
Locations
Sources
AudioRegions
ControlProtocols
*/
- if (use_config_midi_ports ()) {
- }
-
if ((child = find_named_node (node, "extra")) != 0) {
_extra_xml = new XMLNode (*child);
}
error << _("Session: XML state has no options section") << endmsg;
}
+ if (use_config_midi_ports ()) {
+ }
+
if ((child = find_named_node (node, "Locations")) == 0) {
error << _("Session: XML state has no locations section") << endmsg;
goto out;
StateReady (); /* EMIT SIGNAL */
- _state_of_the_state = Clean;
-
- if (state_was_pending) {
- save_state (_current_snapshot_name);
- remove_pending_capture_state ();
- state_was_pending = false;
- }
-
return 0;
out:
set_dirty();
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
+ XMLProperty* prop = (*niter)->property ("default-type");
+
+ if (prop && prop->value() == "unknown" ) {
+ std::cout << "ignoring route with type unknown. (video-track)" << std::endl;
+ // Note: this may mess up remote_control IDs or more..
+ continue;
+ }
boost::shared_ptr<Route> route (XMLRouteFactory (**niter));
return -1;
}
+ BootMessage (string_compose (_("Loaded track/bus %1"), route->name()));
+
new_routes.push_back (route);
}
- add_routes (new_routes);
+ add_routes (new_routes, false);
return 0;
}
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
if ((region = XMLRegionFactory (**niter, false)) == 0) {
- error << _("Session: cannot create Region from XML description.") << endmsg;
+ error << _("Session: cannot create Region from XML description.");
+ const XMLProperty *name = (**niter).property("name");
+
+ if (name) {
+ error << " " << string_compose (_("Can not load state for region '%1'"), name->value());
+ }
+
+ error << endmsg;
}
}
boost::shared_ptr<Source> source;
boost::shared_ptr<AudioSource> as;
SourceList sources;
+ SourceList master_sources;
uint32_t nchans = 1;
char buf[128];
sources.push_back (as);
}
}
-
+
+ for (uint32_t n=0; n < nchans; ++n) {
+ snprintf (buf, sizeof(buf), X_("master-source-%d"), n);
+ if ((prop = node.property (buf)) != 0) {
+
+ PBD::ID id2 (prop->value());
+
+ if ((source = source_by_id (id2)) == 0) {
+ error << string_compose(_("Session: XMLNode describing a AudioRegion references an unknown source id =%1"), id2) << endmsg;
+ return boost::shared_ptr<AudioRegion>();
+ }
+
+ as = boost::dynamic_pointer_cast<AudioSource>(source);
+ if (!as) {
+ error << string_compose(_("Session: XMLNode describing a AudioRegion references a non-audio source id =%1"), id2) << endmsg;
+ return boost::shared_ptr<AudioRegion>();
+ }
+ master_sources.push_back (as);
+ }
+ }
+
try {
boost::shared_ptr<AudioRegion> region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, node)));
}
}
+ if (!master_sources.empty()) {
+ if (master_sources.size() != nchans) {
+ error << _("Session: XMLNode describing an AudioRegion is missing some master sources; ignored") << endmsg;
+ } else {
+ region->set_master_sources (master_sources);
+ }
+ }
return region;
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;
}
}
}
try {
- return SourceFactory::create (*this, node);
+ /* note: do peak building in another thread when loading session state */
+ return SourceFactory::create (*this, node, true);
}
catch (failed_constructor& err) {
tree.set_root (&get_template());
- xml_path = dir;
- xml_path += template_name;
- xml_path += _template_suffix;
+ xml_path = Glib::build_filename(dir, template_name + _template_suffix);
ifstream in(xml_path.c_str());
int
Session::rename_template (string old_name, string new_name)
{
- string old_path = template_dir() + old_name + _template_suffix;
- string new_path = template_dir() + new_name + _template_suffix;
+ string old_path = Glib::build_filename(template_dir(), old_name + _template_suffix);
+ string new_path = Glib::build_filename(template_dir(), new_name + _template_suffix);
return rename (old_path.c_str(), new_path.c_str());
}
int
Session::delete_template (string name)
{
- string template_path = template_dir();
- template_path += name;
- template_path += _template_suffix;
+ string template_path = Glib::build_filename(template_dir(), name + _template_suffix);
return remove (template_path.c_str());
}
/* Ensure that the sounds directory exists */
- result = path;
- result += '/';
- result += sound_dir_name;
+ result = Glib::build_filename(path, sound_dir_name);
if (g_mkdir_with_parents (result.c_str(), 0775)) {
error << string_compose(_("cannot create sounds directory \"%1\"; ignored"), result) << endmsg;
return -1;
}
- dead = path;
- dead += '/';
- dead += dead_sound_dir_name;
+ dead = Glib::build_filename(path, dead_sound_dir_name);
if (g_mkdir_with_parents (dead.c_str(), 0775)) {
error << string_compose(_("cannot create dead sounds directory \"%1\"; ignored"), dead) << endmsg;
return -1;
}
- peak = path;
- peak += '/';
- peak += peak_dir_name;
+ peak = Glib::build_filename(path, peak_dir_name);
if (g_mkdir_with_parents (peak.c_str(), 0775)) {
error << string_compose(_("cannot create peak file directory \"%1\"; ignored"), peak) << endmsg;
{
string res;
string full;
+ vector<string> parts;
if (with_path) {
res = _path;
full = _path;
}
- res += interchange_dir_name;
- res += '/';
- res += legalize_for_path (_name);
- res += '/';
- res += sound_dir_name;
+ parts.push_back(interchange_dir_name);
+ parts.push_back(legalize_for_path (_name));
+ parts.push_back(sound_dir_name);
+ res += Glib::build_filename(parts);
if (with_path) {
full = res;
} else {
string
Session::peak_dir () const
{
- string res = _path;
- res += peak_dir_name;
- res += '/';
- return res;
+ return Glib::build_filename (_path, peak_dir_name);
}
string
Session::automation_dir () const
{
- string res = _path;
- res += "automation/";
- return res;
+ return Glib::build_filename (_path, "automation");
+}
+
+string
+Session::analysis_dir () const
+{
+ return Glib::build_filename (_path, "analysis");
}
string
Session::template_dir ()
{
- string path = get_user_ardour_path();
- path += "templates/";
+ return Glib::build_filename (get_user_ardour_path(), "templates");
+}
- return path;
+string
+Session::route_template_dir ()
+{
+ return Glib::build_filename (get_user_ardour_path(), "route_templates");
}
string
Session::export_dir () const
{
- string res = _path;
- res += export_dir_name;
- res += '/';
- return res;
+ return Glib::build_filename (_path, export_dir_name);
}
string
return suffixed_search_path (X_("templates"), true);
}
+
+string
+Session::route_template_path ()
+{
+ return suffixed_search_path (X_("route_templates"), true);
+}
+
string
Session::control_protocol_path ()
{
+ char *p = getenv ("ARDOUR_CONTROL_SURFACE_PATH");
+ if (p && *p) {
+ return p;
+ }
return suffixed_search_path (X_("surfaces"), false);
}
current_trans->add_command (cmd);
}
+ if (current_trans->empty()) {
+ return;
+ }
+
gettimeofday (&now, 0);
current_trans->set_timestamp (now);
}
}
+void
+Session::get_route_templates (vector<RouteTemplateInfo>& template_names)
+{
+ vector<string *> *templates;
+ PathScanner scanner;
+ string path;
+
+ path = route_template_path ();
+
+ templates = scanner (path, template_filter, 0, false, true);
+
+ if (!templates) {
+ return;
+ }
+
+ for (vector<string*>::iterator i = templates->begin(); i != templates->end(); ++i) {
+ string fullpath = *(*i);
+
+ XMLTree tree;
+
+ if (!tree.read (fullpath.c_str())) {
+ continue;
+ }
+
+ XMLNode* root = tree.root();
+
+ RouteTemplateInfo rti;
+
+ rti.name = IO::name_from_state (*root->children().front());
+ rti.path = fullpath;
+
+ template_names.push_back (rti);
+ }
+
+ delete templates;
+}
+
int
Session::read_favorite_dirs (FavoriteDirs & favs)
{
- string path = get_user_ardour_path();
- path += "/favorite_dirs";
+ Glib::ustring path = Glib::build_filename (get_user_ardour_path(), "favorite_dirs");
ifstream fav (path.c_str());
int
Session::write_favorite_dirs (FavoriteDirs & favs)
{
- string path = get_user_ardour_path();
- path += "/favorite_dirs";
+ Glib::ustring path = Glib::build_filename (get_user_ardour_path(), "favorite_dirs");
ofstream fav (path.c_str());
continue;
}
- string path = _path; /* /-terminated */
- path += sound_dir_name;
- path += '/';
- path += prop->value();
+ /* now we have to actually find the file */
- result.insert (path);
+ bool is_new;
+ uint16_t chan;
+ Glib::ustring path;
+ std::string name;
+
+ if (AudioFileSource::find (prop->value(), true, false, is_new, chan, path, name)) {
+ cerr << "Got " << path << " from XML source with prop = " << prop->value() << endl;
+ result.insert (path);
+ }
}
return 0;
int ret = -1;
_state_of_the_state = (StateOfTheState) (_state_of_the_state | InCleanup);
+
/* step 1: consider deleting all unused playlists */
}
}
- char tmppath[PATH_MAX+1];
+ char tmppath1[PATH_MAX+1];
+ char tmppath2[PATH_MAX+1];
for (vector<string*>::iterator x = soundfiles->begin(); x != soundfiles->end(); ++x) {
for (set<string>::iterator i = all_sources.begin(); i != all_sources.end(); ++i) {
- if (strcmp(realpath(spath.c_str(), tmppath), realpath( (*i).c_str(), tmppath)) == 0) {
+ realpath(spath.c_str(), tmppath1);
+ realpath((*i).c_str(), tmppath2);
+
+ cerr << "comparing " << tmppath1 << " and " << tmppath2 << endl;
+
+ if (strcmp(tmppath1, tmppath2) == 0) {
used = true;
break;
}
newpath += dead_sound_dir_name;
if (g_mkdir_with_parents (newpath.c_str(), 0755) < 0) {
- error << string_compose(_("Session: cannot create session peakfile dir \"%1\" (%2)"), newpath, strerror (errno)) << endmsg;
+ error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), newpath, strerror (errno)) << endmsg;
return -1;
}
out:
_state_of_the_state = (StateOfTheState) (_state_of_the_state & ~InCleanup);
+
return ret;
}
_state_of_the_state = StateOfTheState (_state_of_the_state | Dirty);
+
if (!was_dirty) {
DirtyChanged(); /* EMIT SIGNAL */
}
_state_of_the_state = Clean;
+
if (was_dirty) {
DirtyChanged(); /* EMIT SIGNAL */
}
Session::set_deletion_in_progress ()
{
_state_of_the_state = StateOfTheState (_state_of_the_state | Deletion);
+
}
void
void
Session::add_instant_xml (XMLNode& node, const std::string& dir)
{
- Stateful::add_instant_xml (node, dir);
+ if (_writable) {
+ Stateful::add_instant_xml (node, dir);
+ }
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 (!_writable) {
+ return 0;
+ }
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;
/* read xml */
xmlpath = _path + snapshot_name + ".history";
- cerr << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg;
+ info << 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 ("session");
+ } else if (PARAM_IS ("initial-program-change")) {
+
+ if (_mmc_port && Config->get_initial_program_change() >= 0) {
+ MIDI::byte* buf = new MIDI::byte[2];
+
+ buf[0] = MIDI::program; // channel zero by default
+ buf[1] = (Config->get_initial_program_change() & 0x7f);
+ deliver_midi (_mmc_port, buf, 2);
+ }
+ } else if (PARAM_IS ("solo-mute-override")) {
+ catch_up_on_solo_mute_override ();
}
set_dirty ();
#undef PARAM_IS
}
+
+void
+Session::set_history_depth (uint32_t d)
+{
+ _history.set_depth (d);
+}