diff options
author | Robin Gareus <robin@gareus.org> | 2014-06-28 21:27:36 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-06-28 22:02:20 +0200 |
commit | ecd11253c1b4a06e9fd77a9ccc126850abf7a72f (patch) | |
tree | 1b752c4a82ef1e4627360e8116da3f787ee76676 /libs | |
parent | c0c68dbf4dbe59f68bae94fa393f3f8e4e1a3196 (diff) |
add Session::StateProtector
temp. disable save during batch updates, save once at
the end.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/session.h | 22 | ||||
-rw-r--r-- | libs/ardour/session.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 6 |
3 files changed, 30 insertions, 0 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f5266154f4..788d4d9fcb 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -429,6 +429,23 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop StateOfTheState state_of_the_state() const { return _state_of_the_state; } + class StateProtector { + public: + StateProtector (Session* s) : _session (s) { + g_atomic_int_inc (&s->_suspend_save); + } + ~StateProtector () { + if (g_atomic_int_dec_and_test (&_session->_suspend_save)) { + while (_session->_save_queued) { + _session->_save_queued = false; + _session->save_state (""); + } + } + } + private: + Session * _session; + }; + void add_route_group (RouteGroup *); void remove_route_group (RouteGroup&); void reorder_route_groups (std::list<RouteGroup*>); @@ -1099,6 +1116,10 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop bool state_was_pending; StateOfTheState _state_of_the_state; + friend class StateProtector; + gint _suspend_save; /* atomic */ + volatile bool _save_queued; + void auto_save(); int load_options (const XMLNode&); int load_state (std::string snapshot_name); @@ -1648,6 +1669,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop static int get_session_info_from_path (XMLTree& state_tree, const std::string& xmlpath); }; + } // namespace ARDOUR #endif /* __ardour_session_h__ */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4a3ce009eb..b4ae76c1ca 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -194,6 +194,8 @@ Session::Session (AudioEngine &eng, , state_tree (0) , state_was_pending (false) , _state_of_the_state (StateOfTheState(CannotSave|InitialConnecting|Loading)) + , _suspend_save (0) + , _save_queued (false) , _last_roll_location (0) , _last_roll_or_reversal_location (0) , _last_record_location (0) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index c9267b058f..6979f88dcb 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -669,6 +669,12 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot return 1; } + if (g_atomic_int_get(&_suspend_save)) { + _save_queued = true; + return 1; + } + _save_queued = false; + if (!_engine.connected ()) { error << string_compose (_("the %1 audio engine is not connected and state saving would lose all I/O connections. Session not saved"), PROGRAM_NAME) |