diff options
author | Robin Gareus <robin@gareus.org> | 2020-01-30 04:12:19 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-01-30 04:12:19 +0100 |
commit | 0d127813fb6c4a5baa8802f09d32c1fc9b6a0f63 (patch) | |
tree | 041985b39ecfc1b6443ebbd77c666006533ee20a /libs/ardour | |
parent | 998fadda573f7e6b1432bba2ed3b2b555d358964 (diff) |
Allow StateProtector to save pending files
This is in preparation for saving state while the session is
record-arm'ed. Most notably config changes and undo/redo.
In case both normal and pending save happens, pending must be
last and is required to recover from crashes during recording.
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/session.h | 6 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 807c2686eb..daaecd8a38 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -628,6 +628,10 @@ public: _session->_save_queued = false; _session->save_state (""); } + while (_session->_save_queued_pending) { + _session->_save_queued_pending = false; + _session->save_state ("", true); + } } } private: @@ -1413,6 +1417,8 @@ private: friend class StateProtector; gint _suspend_save; /* atomic */ volatile bool _save_queued; + volatile bool _save_queued_pending; + Glib::Threads::Mutex save_state_lock; Glib::Threads::Mutex save_source_lock; Glib::Threads::Mutex peak_cleanup_lock; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e7b1a29d3e..757344f69c 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -785,10 +785,20 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot } if (g_atomic_int_get(&_suspend_save)) { - _save_queued = true; + /* StateProtector cannot be used for templates or save-as */ + assert (!template_only && !switch_to_snapshot && !for_archive && snapshot_name.empty ()); + if (pending) { + _save_queued_pending = true; + } else { + _save_queued = true; + } return 1; } - _save_queued = false; + if (pending) { + _save_queued_pending = false; + } else { + _save_queued = false; + } snapshot_t fork_state = NormalSave; if (!snapshot_name.empty() && snapshot_name != _current_snapshot_name && !template_only && !pending && !for_archive) { |