diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 45d5dcc9a9..4b1a302b70 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1940,22 +1940,37 @@ Session::maybe_enable_record (bool rt_context) g_atomic_int_set (&_record_status, Enabled); - /* This function is currently called from somewhere other than an RT thread. - * (except maybe lua scripts, which can use rt_context = true) - * This save_state() call therefore doesn't impact anything. Doing it here - * means that we save pending state of which sources the next record will use, + // TODO make configurable, perhaps capture-buffer-seconds dependnet? + bool quick_start = true; + + /* Save pending state of which sources the next record will use, * which gives us some chance of recovering from a crash during the record. */ - - if (!rt_context) { + if (!rt_context && (!quick_start || _transport_speed == 0)) { save_state ("", true); } - if (_transport_speed) { + if (_transport_speed != 0) { maybe_allow_only_punch (); if (!config.get_punch_in()) { enable_record (); } + /* When rolling, start recording immediately. + * Do not wait for .pending state save to complete + * because that may take some time (up to a second + * for huge sessions). + * + * This is potentially dangerous!! If a crash happens + * while recording before the .pending save completed, + * the data until then may be lost or overwritten. + * (However disk-writer buffers are usually longer, + * compared to the time it takes to save a session. + * disk I/O may not be a bottleneck either. Except + * perhaps plugin-state saves taking a lock. + */ + if (!rt_context && quick_start) { + save_state ("", true); + } } else { send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause)); RecordStateChanged (); /* EMIT SIGNAL */