diff --git a/src/portmanager.cpp b/src/portmanager.cpp index 2e69e87..4e153e4 100644 --- a/src/portmanager.cpp +++ b/src/portmanager.cpp @@ -46,20 +46,33 @@ void PortManager::Refresh() Add(jack_port_by_name(client, ports[i])); } - for (int i = 0; ports[i] != NULL; ++i) { - jack_port_t *port = jack_port_by_name(client, ports[i]); - if (jack_port_flags(port) & JackPortIsInput) { - const char **connections = jack_port_get_all_connections(client, port); + free(ports); + + RefreshConnections(); +} + +void PortManager::RefreshConnections() +{ + jack_client_t *client = jack.GetClient(); + + PortList::iterator it; + for (it = m_ports.begin(); it != m_ports.end(); ++it) { + Port *p = *it; + p->m_connections.clear(); + } + + for (it = m_ports.begin(); it != m_ports.end(); ++it) { + Port *p = *it; + if (p->m_is_input) { + const char **connections = jack_port_get_all_connections(client, p->m_port); if (connections != NULL) { for (int j = 0; connections[j] != NULL; ++j) { - Connect(port, jack_port_by_name(client, connections[j])); + Connect(p->m_port, jack_port_by_name(client, connections[j])); } free(connections); } } } - - free(ports); } void PortManager::Add(jack_port_t *port) @@ -207,6 +220,7 @@ void PortManager::Rename(jack_port_t *port) { Delete(port); Add(port); + RefreshConnections(); } Client *PortManager::FindOrMakeClient(std::string name, bool is_input, bool is_midi) diff --git a/src/portmanager.h b/src/portmanager.h index 2cb510e..d0445d1 100644 --- a/src/portmanager.h +++ b/src/portmanager.h @@ -38,6 +38,7 @@ public: public: void Refresh(); + void RefreshConnections(); void Add(jack_port_t *port); void Delete(jack_port_t *port);