diff --git a/Mixer/Chain.C b/Mixer/Chain.C index 651ffda..8a33b32 100644 --- a/Mixer/Chain.C +++ b/Mixer/Chain.C @@ -77,6 +77,7 @@ #include "Mixer_Strip.H" #include +extern char *instance_name; @@ -402,7 +403,7 @@ Chain::can_configure_outputs ( Module *m, int n ) const int Chain::maximum_name_length ( void ) { - return JACK::Client::maximum_name_length() - strlen( APP_NAME "/" ); + return JACK::Client::maximum_name_length() - ( strlen( APP_NAME ) + 1 + ( instance_name ? strlen( instance_name ) + 1 : 0 ) ); } /* rename chain... we have to let our modules know our name has @@ -412,7 +413,7 @@ void Chain::name ( const char *name ) { char ename[512]; - snprintf( ename, sizeof(ename), "%s/%s", APP_NAME, name ); + snprintf( ename, sizeof(ename), "%s%s%s/%s", APP_NAME, instance_name ? "." : "", instance_name ? instance_name : "", name ); if ( ! _engine ) { diff --git a/Mixer/main.C b/Mixer/main.C index 87ce399..10045be 100644 --- a/Mixer/main.C +++ b/Mixer/main.C @@ -59,6 +59,8 @@ char *user_config_dir; Mixer *mixer; +const char *instance_name; + #include static int @@ -134,19 +136,41 @@ main ( int argc, char **argv ) } { - if ( argc > 1 ) + int r = argc - 1; + int i = 1; + for ( ; i < argc; ++i, --r ) { - MESSAGE( "Loading \"%s\"", argv[1] ); + if ( !strcmp( argv[i], "--instance" ) ) + { + if ( r > 1 ) + { + MESSAGE( "Using instance name \"%s\"", argv[i+1] ); + instance_name = argv[i+1]; + ++i; + } + else + { + FATAL( "Missing instance name" ); + } + } + else if ( !strncmp( argv[i], "--", 2 ) ) + { + WARNING( "Unrecognized option: %s", argv[i] ); + } + else + break; + } - if ( ! mixer->command_load( argv[1] ) ) + if ( r >= 1 ) + { + MESSAGE( "Loading \"%s\"", argv[i] ); + + if ( ! mixer->command_load( argv[i] ) ) { fl_alert( "Error opening project specified on commandline" ); } } - else - { - WARNING( "Running without a project--nothing will be saved." ); - } + } Fl::run();