@@ -23,6 +23,7 @@ | |||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <getopt.h> | |||||
#include <FL/Fl.H> | #include <FL/Fl.H> | ||||
#include <FL/Fl_Double_Window.H> | #include <FL/Fl_Double_Window.H> | ||||
@@ -203,72 +204,69 @@ main ( int argc, char **argv ) | |||||
nsm = new NSM_Client; | nsm = new NSM_Client; | ||||
instance_name = strdup( APP_NAME ); | instance_name = strdup( APP_NAME ); | ||||
bool instance_override = false; | |||||
static struct option long_options[] = | |||||
{ | |||||
{ "instance", required_argument, 0, 'i' }, | |||||
{ "osc-port", required_argument, 0, 'p' }, | |||||
{ 0, 0, 0, 0 } | |||||
}; | |||||
int option_index = 0; | |||||
int c = 0; | |||||
while ( ( c = getopt_long_only( argc, argv, "", long_options, &option_index ) ) != -1 ) | |||||
{ | { | ||||
int r = argc - 1; | |||||
int i = 1; | |||||
for ( ; i < argc; ++i, --r ) | |||||
switch ( c ) | |||||
{ | { | ||||
if ( !strcmp( argv[i], "--instance" ) ) | |||||
{ | |||||
if ( r > 1 ) | |||||
{ | |||||
MESSAGE( "Using instance name \"%s\"", argv[i+1] ); | |||||
instance_name = strdup( argv[i+1] ); | |||||
--r; | |||||
++i; | |||||
} | |||||
else | |||||
{ | |||||
FATAL( "Missing instance name" ); | |||||
} | |||||
} | |||||
else if ( !strcmp( argv[i], "--osc-port" ) ) | |||||
{ | |||||
if ( r > 1 ) | |||||
{ | |||||
MESSAGE( "Using OSC port \"%s\"", argv[i+1] ); | |||||
osc_port = argv[i+1]; | |||||
--r; | |||||
++i; | |||||
} | |||||
else | |||||
{ | |||||
FATAL( "Missing OSC port" ); | |||||
} | |||||
} | |||||
else if ( !strncmp( argv[i], "--", 2 ) ) | |||||
{ | |||||
WARNING( "Unrecognized option: %s", argv[i] ); | |||||
} | |||||
else | |||||
case 'p': | |||||
DMESSAGE( "Using OSC port %s", optarg ); | |||||
osc_port = optarg; | |||||
break; | |||||
case 'i': | |||||
DMESSAGE( "Using OSC port %s", optarg ); | |||||
free( instance_name ); | |||||
instance_name = strdup( optarg ); | |||||
instance_override = true; | |||||
break; | |||||
case '?': | |||||
printf( "Usage: %s [--osc-port portnum]\n\n", argv[0] ); | |||||
exit(0); | |||||
break; | break; | ||||
} | } | ||||
} | |||||
mixer->init_osc( osc_port ); | |||||
mixer->init_osc( osc_port ); | |||||
char *nsm_url = getenv( "NSM_URL" ); | |||||
char *nsm_url = getenv( "NSM_URL" ); | |||||
if ( nsm_url ) | |||||
if ( nsm_url ) | |||||
{ | |||||
if ( ! nsm->init( nsm_url ) ) | |||||
{ | { | ||||
if ( ! nsm->init( nsm_url ) ) | |||||
{ | |||||
nsm->announce( APP_NAME, ":switch:dirty:", argv[0] ); | |||||
if ( instance_override ) | |||||
WARNING( "--instance option is not available when running under session management, ignoring." ); | |||||
if ( optind < argc ) | |||||
WARNING( "Loading files from the command-line is incompatible with session management, ignoring." ); | |||||
// poll so we can keep OSC handlers running in the GUI thread and avoid extra sync | |||||
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL ); | |||||
} | |||||
nsm->announce( APP_NAME, ":switch:dirty:", argv[0] ); | |||||
// poll so we can keep OSC handlers running in the GUI thread and avoid extra sync | |||||
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL ); | |||||
} | } | ||||
else | |||||
} | |||||
else | |||||
{ | |||||
if ( optind < argc ) | |||||
{ | { | ||||
if ( r >= 1 ) | |||||
{ | |||||
MESSAGE( "Loading \"%s\"", argv[i] ); | |||||
MESSAGE( "Loading \"%s\"", argv[optind] ); | |||||
if ( ! mixer->command_load( argv[i] ) ) | |||||
{ | |||||
fl_alert( "Error opening project specified on commandline" ); | |||||
} | |||||
if ( ! mixer->command_load( argv[optind] ) ) | |||||
{ | |||||
fl_alert( "Error opening project specified on commandline" ); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -26,6 +26,7 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <getopt.h> | |||||
/* for registrations */ | /* for registrations */ | ||||
#include "Audio_Region.H" | #include "Audio_Region.H" | ||||
@@ -183,6 +184,7 @@ main ( int argc, char **argv ) | |||||
tle = new TLE; | tle = new TLE; | ||||
instance_name = strdup( APP_NAME ); | instance_name = strdup( APP_NAME ); | ||||
bool instance_override = false; | |||||
/* we don't really need a pointer for this */ | /* we don't really need a pointer for this */ | ||||
// will be created on project new/open | // will be created on project new/open | ||||
@@ -192,67 +194,74 @@ main ( int argc, char **argv ) | |||||
const char *osc_port = NULL; | const char *osc_port = NULL; | ||||
{ | |||||
int r = argc - 1; | |||||
int i = 1; | |||||
for ( ; i < argc; ++i, --r ) | |||||
if ( !strcmp( argv[i], "--osc-port" ) ) | |||||
{ | |||||
if ( r > 1 ) | |||||
{ | |||||
MESSAGE( "Using OSC port \"%s\"", argv[i+1] ); | |||||
osc_port = argv[i+1]; | |||||
--r; | |||||
++i; | |||||
} | |||||
else | |||||
{ | |||||
FATAL( "Missing OSC port" ); | |||||
} | |||||
} | |||||
static struct option long_options[] = | |||||
{ | |||||
{ "instance", required_argument, 0, 'i' }, | |||||
{ "osc-port", required_argument, 0, 'p' }, | |||||
{ 0, 0, 0, 0 } | |||||
}; | |||||
int option_index = 0; | |||||
int c = 0; | |||||
MESSAGE( "Starting GUI" ); | |||||
while ( ( c = getopt_long_only( argc, argv, "", long_options, &option_index ) ) != -1 ) | |||||
{ | |||||
switch ( c ) | |||||
{ | |||||
case 'p': | |||||
DMESSAGE( "Using OSC port %s", optarg ); | |||||
osc_port = optarg; | |||||
break; | |||||
case 'i': | |||||
DMESSAGE( "Using OSC port %s", optarg ); | |||||
free( instance_name ); | |||||
instance_name = strdup( optarg ); | |||||
instance_override = true; | |||||
break; | |||||
case '?': | |||||
printf( "Usage: %s [--osc-port portnum]\n\n", argv[0] ); | |||||
exit(0); | |||||
break; | |||||
} | |||||
} | |||||
tle->run(); | |||||
MESSAGE( "Starting GUI" ); | |||||
tle->run(); | |||||
timeline->init_osc( osc_port ); | |||||
timeline->init_osc( osc_port ); | |||||
#ifdef HAVE_XPM | #ifdef HAVE_XPM | ||||
tle->main_window->icon((char *)p); | |||||
tle->main_window->icon((char *)p); | |||||
#endif | #endif | ||||
tle->main_window->show( argc, argv ); | |||||
tle->main_window->show( 0, NULL ); | |||||
char *nsm_url = getenv( "NSM_URL" ); | |||||
char *nsm_url = getenv( "NSM_URL" ); | |||||
if ( nsm_url ) | |||||
if ( nsm_url ) | |||||
{ | |||||
if ( ! nsm->init( nsm_url ) ) | |||||
{ | { | ||||
if ( ! nsm->init( nsm_url ) ) | |||||
{ | |||||
nsm->announce( APP_NAME, ":progress:switch:", argv[0] ); | |||||
if ( instance_override ) | |||||
WARNING( "--instance option is not available when running under session management, ignoring." ); | |||||
if ( optind < argc ) | |||||
WARNING( "Loading files from the command-line is incompatible with session management, ignoring." ); | |||||
nsm->announce( APP_NAME, ":progress:switch:", argv[0] ); | |||||
/* poll so we can keep OSC handlers running in the GUI thread and avoid extra sync */ | |||||
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL ); | |||||
} | |||||
/* poll so we can keep OSC handlers running in the GUI thread and avoid extra sync */ | |||||
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL ); | |||||
} | } | ||||
else | |||||
} | |||||
else | |||||
{ | |||||
if ( optind < argc ) | |||||
{ | { | ||||
if ( r >= 1 ) | |||||
{ | |||||
MESSAGE( "Loading \"%s\"", argv[i] ); | |||||
MESSAGE( "Loading \"%s\"", argv[optind] ); | |||||
tle->open( argv[i] ); | |||||
/* ) */ | |||||
/* { */ | |||||
/* fl_alert( "Error opening project specified on commandline" ); */ | |||||
/* } */ | |||||
} | |||||
tle->open( argv[optind] ); | |||||
} | } | ||||
} | } | ||||
Fl::add_check( check_sigterm ); | Fl::add_check( check_sigterm ); | ||||