diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-10-02 19:22:16 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-10-02 22:08:14 -0400 |
commit | 3bc7f863ca3434aeda872a862229b8d14e6eef62 (patch) | |
tree | e2b7598281cb3d6fda7d9a4f1316d10ce8b4a360 | |
parent | fd4a34251c564a1f1430131c8b718d49d579a5a2 (diff) |
explicitly drop control surface protocols before disconnecting from engine.
This is not bomb/thread proof yet, because it still requires at least one process callback to function
-rw-r--r-- | libs/ardour/ardour/control_protocol_manager.h | 5 | ||||
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 43 | ||||
-rw-r--r-- | libs/ardour/session.cc | 6 |
3 files changed, 35 insertions, 19 deletions
diff --git a/libs/ardour/ardour/control_protocol_manager.h b/libs/ardour/ardour/control_protocol_manager.h index 0c8c9014f0..8d196b36d7 100644 --- a/libs/ardour/ardour/control_protocol_manager.h +++ b/libs/ardour/ardour/control_protocol_manager.h @@ -64,8 +64,9 @@ class LIBARDOUR_API ControlProtocolManager : public PBD::Stateful, public ARDOUR void foreach_known_protocol (boost::function<void(const ControlProtocolInfo*)>); void load_mandatory_protocols (); void midi_connectivity_established (); - - int activate (ControlProtocolInfo&); + void drop_protocols (); + + int activate (ControlProtocolInfo&); int deactivate (ControlProtocolInfo&); std::list<ControlProtocolInfo*> control_protocol_info; diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index fdac48e731..376152c139 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -126,26 +126,35 @@ void ControlProtocolManager::session_going_away() { SessionHandlePtr::session_going_away (); + /* Session::destroy() will explicitly call drop_protocols() so we don't + * have to worry about that here. + */ +} - { - Glib::Threads::Mutex::Lock lm (protocols_lock); - - for (list<ControlProtocol*>::iterator p = control_protocols.begin(); p != control_protocols.end(); ++p) { - delete *p; - } - - control_protocols.clear (); - - for (list<ControlProtocolInfo*>::iterator p = control_protocol_info.begin(); p != control_protocol_info.end(); ++p) { - // mark existing protocols as requested - // otherwise the ControlProtocol instances are not recreated in set_session - if ((*p)->protocol) { - (*p)->requested = true; - (*p)->protocol = 0; - } +void +ControlProtocolManager::drop_protocols () +{ + /* called explicitly by Session::destroy() so that we can clean up + * before the process cycle stops and ports vanish. + */ + + Glib::Threads::Mutex::Lock lm (protocols_lock); + + for (list<ControlProtocol*>::iterator p = control_protocols.begin(); p != control_protocols.end(); ++p) { + delete *p; + } + + control_protocols.clear (); + + for (list<ControlProtocolInfo*>::iterator p = control_protocol_info.begin(); p != control_protocol_info.end(); ++p) { + // mark existing protocols as requested + // otherwise the ControlProtocol instances are not recreated in set_session + if ((*p)->protocol) { + (*p)->requested = true; + (*p)->protocol = 0; } } -} +} ControlProtocol* ControlProtocolManager::instantiate (ControlProtocolInfo& cpi) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 496afad83b..b0aee20ce3 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -551,6 +551,12 @@ Session::destroy () drop_connections (); + /* shutdown control surface protocols while we still have ports + and the engine to move data to any devices. + */ + + ControlProtocolManager::instance().drop_protocols (); + _engine.remove_session (); #ifdef USE_TRACKS_CODE_FEATURES |