Retain TransportMaster Ports across sessions

Unloading a session should only remove session-ports.
This fixes Timecode master sync when switching snapshots
or sessions.
This commit is contained in:
Robin Gareus 2023-12-03 20:38:31 +01:00
parent 4194313e4b
commit 0786be859d
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 15 additions and 8 deletions

View File

@ -186,7 +186,7 @@ public:
void set_port_pretty_name (std::string const&, std::string const&);
void remove_all_ports ();
void remove_session_ports ();
/** reset port-buffers. e.g. after freewheeling */
void reinit (bool with_ratio = false);

View File

@ -834,7 +834,7 @@ AudioEngine::remove_session ()
SessionHandlePtr::set_session (0);
}
remove_all_ports ();
remove_session_ports ();
}
void

View File

@ -274,7 +274,7 @@ PortManager::clear_pending_port_deletions ()
}
void
PortManager::remove_all_ports ()
PortManager::remove_session_ports ()
{
/* make sure that JACK callbacks that will be invoked as we cleanup
* ports know that they have nothing to do.
@ -282,13 +282,20 @@ PortManager::remove_all_ports ()
PBD::Unwinder<bool> uw (_port_remove_in_progress, true);
/* process lock MUST be held by caller
*/
/* process lock MUST be held by caller */
{
RCUWriter<Ports> writer (_ports);
RCUWriter<Ports> writer (_ports);
std::shared_ptr<Ports> ps = writer.get_copy ();
ps->clear ();
for (auto i = ps->begin (); i != ps->end (); ) {
std::shared_ptr<Port> port = i->second;
if (i->second->flags () & TransportMasterPort) {
++i;
} else {
i = ps->erase (i);
}
}
}
/* clear dead wood list in RCU */
@ -857,7 +864,7 @@ PortManager::reestablish_ports ()
if (i != p->end ()) {
/* failed */
remove_all_ports ();
remove_session_ports ();
return -1;
}