Mixer: Fix JACK port disconnection when Auto Input/Output mode is changed.

pull/119/merge
Jonathan Moore Liles 2020-12-02 21:49:27 -08:00
parent 00c02c7d74
commit 286dec338c
2 changed files with 11 additions and 7 deletions

View File

@ -1037,14 +1037,19 @@ Mixer_Strip::maybe_auto_connect_output ( Module::Port *p )
if ( ! _auto_input ) if ( ! _auto_input )
{ {
/* break any previous connection between this port and this module */ /* break any previous connection between this port and this module */
p->disconnect_from_strip(this); p->disconnect_from_strip(this);
} }
if ( _auto_input && matches_pattern( _auto_input, p ) ) if ( _auto_input && matches_pattern( _auto_input, p ) )
{ {
/* FIXME: would be faster if we avoided breaking and remaking
* the same connections, while still breaking connections that
* will not be remade */
/* break any prior auto-connection */ /* break any prior auto-connection */
p->disconnect(); p->disconnect();
// FIXME: Find a better way to get the port index. // FIXME: Find a better way to get the port index.
const char* jack_name = p->jack_port()->jack_name(); const char* jack_name = p->jack_port()->jack_name();

View File

@ -285,17 +285,16 @@ Module::paste_before ( void )
void void
Module::Port::disconnect_from_strip ( Mixer_Strip *o ) Module::Port::disconnect_from_strip ( Mixer_Strip *o )
{ {
for ( std::list<Port*>::iterator i = _connected.begin(); i != _connected.end(); i++ ) for ( std::list<Port*>::iterator i = _connected.begin(); i != _connected.end(); )
{ {
Port *p = *i; Port *p = *i;
i++; /* iterator trick */
if ( p->module()->chain()->strip() == o ) if ( p->module()->chain()->strip() == o )
{ {
/* iterator about to be invalidated... */
i = _connected.erase(i);
disconnect(p); disconnect(p);
} }
} }
} }