diff options
author | David Robillard <d@drobilla.net> | 2008-10-12 07:18:39 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-10-12 07:18:39 +0000 |
commit | 8db5a44398dbee8efbf8707ea1cf7c9e9348ebcb (patch) | |
tree | 5682c0524fbcc136a8631d33b89b513b4a2e8e3a /src/ingen | |
parent | d154ae5b114a6a04acd17a83f6d59caa9ec1005a (diff) | |
download | ingen-8db5a44398dbee8efbf8707ea1cf7c9e9348ebcb.tar.gz ingen-8db5a44398dbee8efbf8707ea1cf7c9e9348ebcb.tar.bz2 ingen-8db5a44398dbee8efbf8707ea1cf7c9e9348ebcb.zip |
Add --jack-name command line option (implement feature request #176).
Move queued engine interface and events into separate library (so core engine library doesn't require them).
Remove some cruft.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1654 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/ingen')
-rw-r--r-- | src/ingen/cmdline.c | 202 | ||||
-rw-r--r-- | src/ingen/cmdline.ggo | 7 | ||||
-rw-r--r-- | src/ingen/cmdline.h | 32 | ||||
-rw-r--r-- | src/ingen/main.cpp | 7 |
4 files changed, 156 insertions, 92 deletions
diff --git a/src/ingen/cmdline.c b/src/ingen/cmdline.c index ea48135c..e8a6ab63 100644 --- a/src/ingen/cmdline.c +++ b/src/ingen/cmdline.c @@ -1,7 +1,7 @@ /* - File autogenerated by gengetopt + File autogenerated by gengetopt version 2.22.1 generated with the following command: - gengetopt -g + gengetopt -u The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -23,22 +23,23 @@ const char *gengetopt_args_info_purpose = "A modular realtime audio processing system"; -const char *gengetopt_args_info_usage = "Usage: ingen [OPTIONS]..."; +const char *gengetopt_args_info_usage = "Usage: ingen [OPTIONS]... [FILES]..."; const char *gengetopt_args_info_description = "Ingen can be run in various configurations. The engine can\nrun as a stand-alone server controlled by OSC, or internal to\nanother process (e.g. the GUI). The GUI can communicate with the engine\nvia either method, and many GUIs (or other things) may connect to an\nengine via OSC.\n\nExamples:\n\n ingen -e - Run an engine, listen for OSC \n ingen -g - Run a GUI, connect via OSC \n ingen -eg - Run an engine and a GUI in one process\n\nThe -l (load) option can be used in all cases:\n \n ingen -el patch.ingen.ttl - Run an engine and load a patch\n ingen -gl patch.ingen.ttl - Run a GUI and load a patch\n ingen -egl patch.ingen.ttl - Run an engine and a GUI and load a patch\n\nOptions:\n"; const char *gengetopt_args_info_help[] = { - " -h, --help Print help and exit", - " -V, --version Print version and exit", - " -e, --engine Run (JACK) engine (default=off)", - " -E, --engine-port=INT Engine OSC port (default=`16180')", - " -c, --connect=STRING Connect to existing engine at OSC URI \n (default=`osc.udp://localhost:16180')", - " -g, --gui Launch the GTK graphical interface (default=off)", - " -C, --client-port=INT Client OSC port", - " -l, --load=STRING Load patch", - " -L, --path=STRING Target path for loaded patch", - " -r, --run=STRING Run script", - " -p, --parallelism=INT Number of concurrent process threads (default=`1')", + " -h, --help Print help and exit", + " -V, --version Print version and exit", + " -C, --client-port=INT Client OSC port", + " -c, --connect=STRING Connect to existing engine at OSC URI \n (default=`osc.udp://localhost:16180')", + " -e, --engine Run (JACK) engine (default=off)", + " -E, --engine-port=INT Engine OSC port (default=`16180')", + " -g, --gui Launch the GTK graphical interface (default=off)", + " -n, --jack-name=STRING JACK client name (default=`ingen')", + " -l, --load=STRING Load patch", + " -p, --parallelism=INT Number of concurrent process threads (default=`1')", + " -L, --path=STRING Target path for loaded patch", + " -r, --run=STRING Run script", 0 }; @@ -66,35 +67,38 @@ void clear_given (struct gengetopt_args_info *args_info) { args_info->help_given = 0 ; args_info->version_given = 0 ; + args_info->client_port_given = 0 ; + args_info->connect_given = 0 ; args_info->engine_given = 0 ; args_info->engine_port_given = 0 ; - args_info->connect_given = 0 ; args_info->gui_given = 0 ; - args_info->client_port_given = 0 ; + args_info->jack_name_given = 0 ; args_info->load_given = 0 ; + args_info->parallelism_given = 0 ; args_info->path_given = 0 ; args_info->run_given = 0 ; - args_info->parallelism_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { + args_info->client_port_orig = NULL; + args_info->connect_arg = gengetopt_strdup ("osc.udp://localhost:16180"); + args_info->connect_orig = NULL; args_info->engine_flag = 0; args_info->engine_port_arg = 16180; args_info->engine_port_orig = NULL; - args_info->connect_arg = gengetopt_strdup ("osc.udp://localhost:16180"); - args_info->connect_orig = NULL; args_info->gui_flag = 0; - args_info->client_port_orig = NULL; + args_info->jack_name_arg = gengetopt_strdup ("ingen"); + args_info->jack_name_orig = NULL; args_info->load_arg = NULL; args_info->load_orig = NULL; + args_info->parallelism_arg = 1; + args_info->parallelism_orig = NULL; args_info->path_arg = NULL; args_info->path_orig = NULL; args_info->run_arg = NULL; args_info->run_orig = NULL; - args_info->parallelism_arg = 1; - args_info->parallelism_orig = NULL; } @@ -105,15 +109,16 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->help_help = gengetopt_args_info_help[0] ; args_info->version_help = gengetopt_args_info_help[1] ; - args_info->engine_help = gengetopt_args_info_help[2] ; - args_info->engine_port_help = gengetopt_args_info_help[3] ; - args_info->connect_help = gengetopt_args_info_help[4] ; - args_info->gui_help = gengetopt_args_info_help[5] ; - args_info->client_port_help = gengetopt_args_info_help[6] ; - args_info->load_help = gengetopt_args_info_help[7] ; - args_info->path_help = gengetopt_args_info_help[8] ; - args_info->run_help = gengetopt_args_info_help[9] ; - args_info->parallelism_help = gengetopt_args_info_help[10] ; + args_info->client_port_help = gengetopt_args_info_help[2] ; + args_info->connect_help = gengetopt_args_info_help[3] ; + args_info->engine_help = gengetopt_args_info_help[4] ; + args_info->engine_port_help = gengetopt_args_info_help[5] ; + args_info->gui_help = gengetopt_args_info_help[6] ; + args_info->jack_name_help = gengetopt_args_info_help[7] ; + args_info->load_help = gengetopt_args_info_help[8] ; + args_info->parallelism_help = gengetopt_args_info_help[9] ; + args_info->path_help = gengetopt_args_info_help[10] ; + args_info->run_help = gengetopt_args_info_help[11] ; } @@ -153,6 +158,9 @@ cmdline_parser_init (struct gengetopt_args_info *args_info) clear_given (args_info); clear_args (args_info); init_args_info (args_info); + + args_info->inputs = NULL; + args_info->inputs_num = 0; } void @@ -191,20 +199,27 @@ free_string_field (char **s) static void cmdline_parser_release (struct gengetopt_args_info *args_info) { - - free_string_field (&(args_info->engine_port_orig)); + unsigned int i; + free_string_field (&(args_info->client_port_orig)); free_string_field (&(args_info->connect_arg)); free_string_field (&(args_info->connect_orig)); - free_string_field (&(args_info->client_port_orig)); + free_string_field (&(args_info->engine_port_orig)); + free_string_field (&(args_info->jack_name_arg)); + free_string_field (&(args_info->jack_name_orig)); free_string_field (&(args_info->load_arg)); free_string_field (&(args_info->load_orig)); + free_string_field (&(args_info->parallelism_orig)); free_string_field (&(args_info->path_arg)); free_string_field (&(args_info->path_orig)); free_string_field (&(args_info->run_arg)); free_string_field (&(args_info->run_orig)); - free_string_field (&(args_info->parallelism_orig)); + for (i = 0; i < args_info->inputs_num; ++i) + free (args_info->inputs [i]); + + if (args_info->inputs_num) + free (args_info->inputs); clear_given (args_info); } @@ -236,24 +251,26 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "help", 0, 0 ); if (args_info->version_given) write_into_file(outfile, "version", 0, 0 ); + if (args_info->client_port_given) + write_into_file(outfile, "client-port", args_info->client_port_orig, 0); + if (args_info->connect_given) + write_into_file(outfile, "connect", args_info->connect_orig, 0); if (args_info->engine_given) write_into_file(outfile, "engine", 0, 0 ); if (args_info->engine_port_given) write_into_file(outfile, "engine-port", args_info->engine_port_orig, 0); - if (args_info->connect_given) - write_into_file(outfile, "connect", args_info->connect_orig, 0); if (args_info->gui_given) write_into_file(outfile, "gui", 0, 0 ); - if (args_info->client_port_given) - write_into_file(outfile, "client-port", args_info->client_port_orig, 0); + if (args_info->jack_name_given) + write_into_file(outfile, "jack-name", args_info->jack_name_orig, 0); if (args_info->load_given) write_into_file(outfile, "load", args_info->load_orig, 0); + if (args_info->parallelism_given) + write_into_file(outfile, "parallelism", args_info->parallelism_orig, 0); if (args_info->path_given) write_into_file(outfile, "path", args_info->path_orig, 0); if (args_info->run_given) write_into_file(outfile, "run", args_info->run_orig, 0); - if (args_info->parallelism_given) - write_into_file(outfile, "parallelism", args_info->parallelism_orig, 0); i = EXIT_SUCCESS; @@ -504,19 +521,20 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, + { "client-port", 1, NULL, 'C' }, + { "connect", 1, NULL, 'c' }, { "engine", 0, NULL, 'e' }, { "engine-port", 1, NULL, 'E' }, - { "connect", 1, NULL, 'c' }, { "gui", 0, NULL, 'g' }, - { "client-port", 1, NULL, 'C' }, + { "jack-name", 1, NULL, 'n' }, { "load", 1, NULL, 'l' }, + { "parallelism", 1, NULL, 'p' }, { "path", 1, NULL, 'L' }, { "run", 1, NULL, 'r' }, - { "parallelism", 1, NULL, 'p' }, { NULL, 0, NULL, 0 } }; - c = getopt_long (argc, argv, "hVeE:c:gC:l:L:r:p:", long_options, &option_index); + c = getopt_long (argc, argv, "hVC:c:eE:gn:l:p:L:r:", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ @@ -532,6 +550,30 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); + case 'C': /* Client OSC port. */ + + + if (update_arg( (void *)&(args_info->client_port_arg), + &(args_info->client_port_orig), &(args_info->client_port_given), + &(local_args_info.client_port_given), optarg, 0, 0, ARG_INT, + check_ambiguity, override, 0, 0, + "client-port", 'C', + additional_error)) + goto failure; + + break; + case 'c': /* Connect to existing engine at OSC URI. */ + + + if (update_arg( (void *)&(args_info->connect_arg), + &(args_info->connect_orig), &(args_info->connect_given), + &(local_args_info.connect_given), optarg, 0, "osc.udp://localhost:16180", ARG_STRING, + check_ambiguity, override, 0, 0, + "connect", 'c', + additional_error)) + goto failure; + + break; case 'e': /* Run (JACK) engine. */ @@ -554,18 +596,6 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf goto failure; break; - case 'c': /* Connect to existing engine at OSC URI. */ - - - if (update_arg( (void *)&(args_info->connect_arg), - &(args_info->connect_orig), &(args_info->connect_given), - &(local_args_info.connect_given), optarg, 0, "osc.udp://localhost:16180", ARG_STRING, - check_ambiguity, override, 0, 0, - "connect", 'c', - additional_error)) - goto failure; - - break; case 'g': /* Launch the GTK graphical interface. */ @@ -576,14 +606,14 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf goto failure; break; - case 'C': /* Client OSC port. */ + case 'n': /* JACK client name. */ - if (update_arg( (void *)&(args_info->client_port_arg), - &(args_info->client_port_orig), &(args_info->client_port_given), - &(local_args_info.client_port_given), optarg, 0, 0, ARG_INT, + if (update_arg( (void *)&(args_info->jack_name_arg), + &(args_info->jack_name_orig), &(args_info->jack_name_given), + &(local_args_info.jack_name_given), optarg, 0, "ingen", ARG_STRING, check_ambiguity, override, 0, 0, - "client-port", 'C', + "jack-name", 'n', additional_error)) goto failure; @@ -600,6 +630,18 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf goto failure; break; + case 'p': /* Number of concurrent process threads. */ + + + if (update_arg( (void *)&(args_info->parallelism_arg), + &(args_info->parallelism_orig), &(args_info->parallelism_given), + &(local_args_info.parallelism_given), optarg, 0, "1", ARG_INT, + check_ambiguity, override, 0, 0, + "parallelism", 'p', + additional_error)) + goto failure; + + break; case 'L': /* Target path for loaded patch. */ @@ -624,18 +666,6 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf goto failure; break; - case 'p': /* Number of concurrent process threads. */ - - - if (update_arg( (void *)&(args_info->parallelism_arg), - &(args_info->parallelism_orig), &(args_info->parallelism_given), - &(local_args_info.parallelism_given), optarg, 0, "1", ARG_INT, - check_ambiguity, override, 0, 0, - "parallelism", 'p', - additional_error)) - goto failure; - - break; case 0: /* Long option with no short option */ case '?': /* Invalid option. */ @@ -656,6 +686,30 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf if ( error ) return (EXIT_FAILURE); + if (optind < argc) + { + int i = 0 ; + int found_prog_name = 0; + /* whether program name, i.e., argv[0], is in the remaining args + (this may happen with some implementations of getopt, + but surely not with the one included by gengetopt) */ + + i = optind; + while (i < argc) + if (argv[i++] == argv[0]) { + found_prog_name = 1; + break; + } + i = 0; + + args_info->inputs_num = argc - optind - found_prog_name; + args_info->inputs = + (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; + while (optind < argc) + if (argv[optind++] != argv[0]) + args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; + } + return 0; failure: diff --git a/src/ingen/cmdline.ggo b/src/ingen/cmdline.ggo index 994e6ff9..f639cd98 100644 --- a/src/ingen/cmdline.ggo +++ b/src/ingen/cmdline.ggo @@ -24,13 +24,14 @@ The -l (load) option can be used in all cases: Options: " +option "client-port" C "Client OSC port" int no +option "connect" c "Connect to existing engine at OSC URI" string no default="osc.udp://localhost:16180" option "engine" e "Run (JACK) engine" flag off option "engine-port" E "Engine OSC port" int no default="16180" -option "connect" c "Connect to existing engine at OSC URI" string no default="osc.udp://localhost:16180" option "gui" g "Launch the GTK graphical interface" flag off -option "client-port" C "Client OSC port" int no +option "jack-name" n "JACK client name" string no default="ingen" option "load" l "Load patch" string no +option "parallelism" p "Number of concurrent process threads" int no default="1" option "path" L "Target path for loaded patch" string no option "run" r "Run script" string no -option "parallelism" p "Number of concurrent process threads" int no default="1" diff --git a/src/ingen/cmdline.h b/src/ingen/cmdline.h index 80358089..ee916423 100644 --- a/src/ingen/cmdline.h +++ b/src/ingen/cmdline.h @@ -1,6 +1,6 @@ /** @file cmdline.h * @brief The header file for the command line option parser - * generated by GNU Gengetopt + * generated by GNU Gengetopt version 2.22.1 * http://www.gnu.org/software/gengetopt. * DO NOT modify this file, since it can be overwritten * @author GNU Gengetopt by Lorenzo Bettini */ @@ -34,44 +34,50 @@ struct gengetopt_args_info { const char *help_help; /**< @brief Print help and exit help description. */ const char *version_help; /**< @brief Print version and exit help description. */ + int client_port_arg; /**< @brief Client OSC port. */ + char * client_port_orig; /**< @brief Client OSC port original value given at command line. */ + const char *client_port_help; /**< @brief Client OSC port help description. */ + char * connect_arg; /**< @brief Connect to existing engine at OSC URI (default='osc.udp://localhost:16180'). */ + char * connect_orig; /**< @brief Connect to existing engine at OSC URI original value given at command line. */ + const char *connect_help; /**< @brief Connect to existing engine at OSC URI help description. */ int engine_flag; /**< @brief Run (JACK) engine (default=off). */ const char *engine_help; /**< @brief Run (JACK) engine help description. */ int engine_port_arg; /**< @brief Engine OSC port (default='16180'). */ char * engine_port_orig; /**< @brief Engine OSC port original value given at command line. */ const char *engine_port_help; /**< @brief Engine OSC port help description. */ - char * connect_arg; /**< @brief Connect to existing engine at OSC URI (default='osc.udp://localhost:16180'). */ - char * connect_orig; /**< @brief Connect to existing engine at OSC URI original value given at command line. */ - const char *connect_help; /**< @brief Connect to existing engine at OSC URI help description. */ int gui_flag; /**< @brief Launch the GTK graphical interface (default=off). */ const char *gui_help; /**< @brief Launch the GTK graphical interface help description. */ - int client_port_arg; /**< @brief Client OSC port. */ - char * client_port_orig; /**< @brief Client OSC port original value given at command line. */ - const char *client_port_help; /**< @brief Client OSC port help description. */ + char * jack_name_arg; /**< @brief JACK client name (default='ingen'). */ + char * jack_name_orig; /**< @brief JACK client name original value given at command line. */ + const char *jack_name_help; /**< @brief JACK client name help description. */ char * load_arg; /**< @brief Load patch. */ char * load_orig; /**< @brief Load patch original value given at command line. */ const char *load_help; /**< @brief Load patch help description. */ + int parallelism_arg; /**< @brief Number of concurrent process threads (default='1'). */ + char * parallelism_orig; /**< @brief Number of concurrent process threads original value given at command line. */ + const char *parallelism_help; /**< @brief Number of concurrent process threads help description. */ char * path_arg; /**< @brief Target path for loaded patch. */ char * path_orig; /**< @brief Target path for loaded patch original value given at command line. */ const char *path_help; /**< @brief Target path for loaded patch help description. */ char * run_arg; /**< @brief Run script. */ char * run_orig; /**< @brief Run script original value given at command line. */ const char *run_help; /**< @brief Run script help description. */ - int parallelism_arg; /**< @brief Number of concurrent process threads (default='1'). */ - char * parallelism_orig; /**< @brief Number of concurrent process threads original value given at command line. */ - const char *parallelism_help; /**< @brief Number of concurrent process threads help description. */ unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ + unsigned int client_port_given ; /**< @brief Whether client-port was given. */ + unsigned int connect_given ; /**< @brief Whether connect was given. */ unsigned int engine_given ; /**< @brief Whether engine was given. */ unsigned int engine_port_given ; /**< @brief Whether engine-port was given. */ - unsigned int connect_given ; /**< @brief Whether connect was given. */ unsigned int gui_given ; /**< @brief Whether gui was given. */ - unsigned int client_port_given ; /**< @brief Whether client-port was given. */ + unsigned int jack_name_given ; /**< @brief Whether jack-name was given. */ unsigned int load_given ; /**< @brief Whether load was given. */ + unsigned int parallelism_given ; /**< @brief Whether parallelism was given. */ unsigned int path_given ; /**< @brief Whether path was given. */ unsigned int run_given ; /**< @brief Whether run was given. */ - unsigned int parallelism_given ; /**< @brief Whether parallelism was given. */ + char **inputs ; /**< @brief unamed options (options without names) */ + unsigned inputs_num ; /**< @brief unamed options number */ } ; /** @brief The additional parameters to pass to parser functions */ diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp index 4c958606..0b2ed83e 100644 --- a/src/ingen/main.cpp +++ b/src/ingen/main.cpp @@ -77,7 +77,7 @@ main(int argc, char** argv) if (argc <= 1) { cmdline_parser_print_help(); cerr << endl << "*** Ingen requires at least one command line parameter" << endl; - cerr << "*** Just want to use a graphical app? Try 'ingen -eg'" << endl; + cerr << "*** Just want a graphical application? Try 'ingen -eg'" << endl; return 1; } else if (args.connect_given && args.engine_flag) { cerr << "\n*** Nonsense arguments, can't both run a local engine " @@ -109,6 +109,7 @@ main(int argc, char** argv) world->rdf_world->add_prefix("ingen", "http://drobilla.net/ns/ingen#"); world->rdf_world->add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#"); world->rdf_world->add_prefix("lv2", "http://lv2plug.in/ns/lv2core#"); + world->rdf_world->add_prefix("lv2ev", "http://lv2plug.in/ns/ext/event#"); world->rdf_world->add_prefix("lv2var", "http://lv2plug.in/ns/ext/instance-var#"); world->rdf_world->add_prefix("lv2_midi", "http://lv2plug.in/ns/ext/midi"); world->rdf_world->add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); @@ -193,9 +194,11 @@ main(int argc, char** argv) Ingen::JackAudioDriver* (*new_driver)( Ingen::Engine& engine, std::string server_name, + std::string client_name, jack_client_t* jack_client) = NULL; if (engine_jack_module->get_symbol("new_jack_audio_driver", (void*&)new_driver)) - engine->set_driver(DataType::AUDIO, SharedPtr<Driver>(new_driver(*engine, "default", 0))); + engine->set_driver(DataType::AUDIO, SharedPtr<Driver>(new_driver( + *engine, "default", args.jack_name_arg, NULL))); engine->activate(args.parallelism_arg); } |