From 9875a958295353aabba73fb05f862c4f92ebb219 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 18 Apr 2020 23:54:24 +0200 Subject: RAII collect processor-change signals --- libs/ardour/ardour/session.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'libs/ardour/ardour/session.h') diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 4c93ecb95f..4c259232f5 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -646,23 +646,27 @@ public: }; class ProcessorChangeBlocker { - public: - ProcessorChangeBlocker (Session* s, bool rc = true) - : _session (s) - , _reconfigure_on_delete (rc) - { - g_atomic_int_inc (&s->_ignore_route_processor_changes); - } - ~ProcessorChangeBlocker () { - if (g_atomic_int_dec_and_test (&_session->_ignore_route_processor_changes)) { + public: + ProcessorChangeBlocker (Session* s, bool rc = true) + : _session (s) + , _reconfigure_on_delete (rc) + { + g_atomic_int_inc (&s->_ignore_route_processor_changes); + } + + ~ProcessorChangeBlocker () + { + if (g_atomic_int_dec_and_test (&_session->_ignore_route_processor_changes)) { + if (g_atomic_int_compare_and_exchange (&_session->_ignored_a_processor_change, 1, 0)) { if (_reconfigure_on_delete) { _session->route_processors_changed (RouteProcessorChange ()); } } } - private: - Session* _session; - bool _reconfigure_on_delete; + } + private: + Session* _session; + bool _reconfigure_on_delete; }; RouteGroup* new_route_group (const std::string&); @@ -2128,6 +2132,7 @@ private: friend class ProcessorChangeBlocker; gint _ignore_route_processor_changes; /* atomic */ + gint _ignored_a_processor_change; MidiClockTicker* midi_clock; -- cgit v1.2.3