Mixer: Support specifying an instance name on the command line (--instance)

This commit is contained in:
Jonathan Moore Liles 2010-01-31 22:21:05 -06:00
parent ac3222e576
commit 609a7e02ff
2 changed files with 34 additions and 9 deletions

View File

@ -77,6 +77,7 @@
#include "Mixer_Strip.H"
#include <dsp.h>
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 )
{

View File

@ -59,6 +59,8 @@
char *user_config_dir;
Mixer *mixer;
const char *instance_name;
#include <errno.h>
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();