Mixer: Make port autoconnection during startup and shutdown more efficient.

pull/119/merge
Jonathan Moore Liles 2020-12-12 17:24:48 -08:00
parent f6e3ca8831
commit 793a9c1d4b
6 changed files with 25 additions and 22 deletions

View File

@ -301,9 +301,9 @@ JACK_Module::update_connection_status ( void )
return; return;
} }
/* causes a lot of unnecessary redraws to do this when loading */ /* /\* causes a lot of unnecessary redraws to do this when loading *\/ */
if ( Project::is_opening() ) /* if ( Project::is_opening_closing() ) */
return; /* return; */
/* FIXME: only do something if port list actually changed! */ /* FIXME: only do something if port list actually changed! */
std::list<std::string> output_names = get_connections_for_ports( aux_audio_output ); std::list<std::string> output_names = get_connections_for_ports( aux_audio_output );

View File

@ -1099,7 +1099,7 @@ int
Mixer::handle ( int m ) Mixer::handle ( int m )
{ {
/* if user presses certain keys when project is loading it can cause a crash. Don't respond to input. */ /* if user presses certain keys when project is loading it can cause a crash. Don't respond to input. */
if ( Project::is_opening() ) if ( Project::is_opening_closing() )
return 0; return 0;
if ( Fl_Group::handle( m ) ) if ( Fl_Group::handle( m ) )
@ -1179,7 +1179,7 @@ Mixer::get_auto_connect_targets ( void )
void void
Mixer::auto_connect ( void ) Mixer::auto_connect ( void )
{ {
if ( Project::is_opening() ) if ( Project::is_opening_closing() )
/* it's more efficient to do this once at the end rather than as we go. */ /* it's more efficient to do this once at the end rather than as we go. */
return; return;
@ -1207,7 +1207,7 @@ Mixer::auto_connect ( void )
void void
Mixer::maybe_auto_connect_output ( Module::Port *p ) Mixer::maybe_auto_connect_output ( Module::Port *p )
{ {
if ( Project::is_opening() ) if ( Project::is_opening_closing() )
/* it's more efficient to do this once at the end rather than as we go. */ /* it's more efficient to do this once at the end rather than as we go. */
return; return;
@ -1223,7 +1223,7 @@ Mixer::maybe_auto_connect_output ( Module::Port *p )
return; return;
} }
/* now do that catch-alls, first one wins! */ /* now do the catch-alls, first one wins! */
for ( int i = 0; i < mixer_strips->children(); i++ ) for ( int i = 0; i < mixer_strips->children(); i++ )
{ {
Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i)); Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i));

View File

@ -1036,18 +1036,17 @@ 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 */ /* not accepting auto inputs, so ensure all previous auto
input connection are broken and ignore this port. */
p->disconnect_from_strip(this); p->disconnect_from_strip(this);
return false;
} }
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 /* got a match, add this to list of accepted connections */
* the same connections, while still breaking connections that
* will not be remade */
/* break any prior auto-connection */
p->disconnect();
// FIXME: Find a better way to get the port index. // FIXME: Find a better way to get the port index.

View File

@ -1314,10 +1314,10 @@ Module::auto_disconnect_outputs ( void )
{ {
Module::Port *p = &aux_audio_output[i]; Module::Port *p = &aux_audio_output[i];
if ( p->connected_port() ) while ( p->connected() )
{ {
p->connected_port()->jack_port()->disconnect( p->jack_port()->jack_name() ); p->connected_port()->jack_port()->disconnect( p->jack_port()->jack_name() );
p->disconnect(); p->disconnect(p->connected_port());
} }
} }
} }

View File

@ -58,7 +58,7 @@ char Project::_name[256];
char Project::_created_on[40]; char Project::_created_on[40];
char Project::_path[512]; char Project::_path[512];
bool Project::_is_open = false; bool Project::_is_open = false;
bool Project::_is_opening = false; bool Project::_is_opening_closing = false;
int Project::_lockfd = 0; int Project::_lockfd = 0;
@ -193,6 +193,8 @@ Project::close ( void )
if ( ! save() ) if ( ! save() )
return false; return false;
Project::_is_opening_closing = true;
Loggable::close(); Loggable::close();
/* // write_info(); */ /* // write_info(); */
@ -203,6 +205,8 @@ Project::close ( void )
release_lock( &_lockfd, ".lock" ); release_lock( &_lockfd, ".lock" );
Project::_is_opening_closing = false;
return true; return true;
} }
@ -262,7 +266,7 @@ Project::open ( const char *name )
if ( version != PROJECT_VERSION ) if ( version != PROJECT_VERSION )
return E_VERSION; return E_VERSION;
_is_opening = true; _is_opening_closing = true;
if ( ! Loggable::replay( "snapshot" ) ) if ( ! Loggable::replay( "snapshot" ) )
return E_INVALID; return E_INVALID;
@ -282,7 +286,7 @@ Project::open ( const char *name )
_is_open = true; _is_open = true;
_is_opening = false; _is_opening_closing = false;
// tle->load_timeline_settings(); // tle->load_timeline_settings();
// timeline->zoom_fit(); // timeline->zoom_fit();

View File

@ -27,7 +27,7 @@ class Project
static int _lockfd; static int _lockfd;
static bool _is_open; static bool _is_open;
static bool _is_opening; static bool _is_opening_closing;
static char _name[256]; static char _name[256];
static char _path[512]; static char _path[512];
static char _created_on[40]; static char _created_on[40];
@ -62,5 +62,5 @@ public:
static const char *path ( void ) { return _path; } static const char *path ( void ) { return _path; }
static const char *created_on ( void ) { return _created_on; } static const char *created_on ( void ) { return _created_on; }
static const bool is_opening ( void ) { return _is_opening; } static const bool is_opening_closing ( void ) { return _is_opening_closing; }
}; };