diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-04-07 23:21:48 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-04-07 23:21:48 -0600 |
commit | ec9784764c9996a3af15459b1f9425f3eeb95d92 (patch) | |
tree | bbaf7ce2501f9e7cc39441bf24e0ca8b0ead7f93 /libs/ardour/port_engine_shared.cc | |
parent | 09b51f39010a77e98c512e2de9a6255c5913c291 (diff) |
better fix for port destruction
Diffstat (limited to 'libs/ardour/port_engine_shared.cc')
-rw-r--r-- | libs/ardour/port_engine_shared.cc | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/libs/ardour/port_engine_shared.cc b/libs/ardour/port_engine_shared.cc index 06a19dae83..9606870f99 100644 --- a/libs/ardour/port_engine_shared.cc +++ b/libs/ardour/port_engine_shared.cc @@ -41,7 +41,7 @@ BackendPort::BackendPort (PortEngineSharedImpl &b, const std::string& name, Port BackendPort::~BackendPort () { assert (_connections.empty()); - std::cerr << "Backendport @ " << this << " being deleted\n"; + std::cerr << "Backendport " << _name << " @ " << this << " being deleted\n"; } int @@ -366,6 +366,9 @@ PortEngineSharedImpl::unregister_port (PortEngine::PortHandle port_handle) pm->erase (port->name()); ps->erase (i); } + + _ports.flush (); + _portmap.flush (); } @@ -377,42 +380,53 @@ PortEngineSharedImpl::unregister_ports (bool system_only) _system_midi_in.clear(); _system_midi_out.clear(); - RCUWriter<PortIndex> index_writer (_ports); - RCUWriter<PortMap> map_writer (_portmap); + { + RCUWriter<PortIndex> index_writer (_ports); + RCUWriter<PortMap> map_writer (_portmap); - boost::shared_ptr<PortIndex> ps = index_writer.get_copy (); - boost::shared_ptr<PortMap> pm = map_writer.get_copy (); + boost::shared_ptr<PortIndex> ps = index_writer.get_copy (); + boost::shared_ptr<PortMap> pm = map_writer.get_copy (); - for (PortIndex::iterator i = ps->begin (); i != ps->end ();) { - PortIndex::iterator cur = i++; - BackendPortPtr port = *cur; - if (! system_only || (port->is_physical () && port->is_terminal ())) { - port->disconnect_all (port); - pm->erase (port->name()); - ps->erase (cur); + for (PortIndex::iterator i = ps->begin (); i != ps->end ();) { + PortIndex::iterator cur = i++; + BackendPortPtr port = *cur; + if (! system_only || (port->is_physical () && port->is_terminal ())) { + port->disconnect_all (port); + pm->erase (port->name()); + ps->erase (cur); + } } } + + _ports.flush (); + _portmap.flush (); } void PortEngineSharedImpl::clear_ports () { - RCUWriter<PortIndex> index_writer (_ports); - RCUWriter<PortMap> map_writer (_portmap); + { + RCUWriter<PortIndex> index_writer (_ports); + RCUWriter<PortMap> map_writer (_portmap); - boost::shared_ptr<PortIndex> ps = index_writer.get_copy(); - boost::shared_ptr<PortMap> pm = map_writer.get_copy (); + boost::shared_ptr<PortIndex> ps = index_writer.get_copy(); + boost::shared_ptr<PortMap> pm = map_writer.get_copy (); - if (ps->size () || pm->size ()) { - PBD::warning << _("PortEngineSharedImpl: recovering from unclean shutdown, port registry is not empty.") << endmsg; - _system_inputs.clear(); - _system_outputs.clear(); - _system_midi_in.clear(); - _system_midi_out.clear(); - ps->clear(); - pm->clear(); + if (ps->size () || pm->size ()) { + PBD::warning << _("PortEngineSharedImpl: recovering from unclean shutdown, port registry is not empty.") << endmsg; + _system_inputs.clear(); + _system_outputs.clear(); + _system_midi_in.clear(); + _system_midi_out.clear(); + ps->clear(); + pm->clear(); + } } + + _ports.flush (); + _portmap.flush (); + } uint32_t |