diff options
author | Andrea Piras <andrea.piras.85@gmail.com> | 2019-11-29 03:13:21 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2021-06-14 12:00:44 +0200 |
commit | 0e21f4d8643db547dcca1375a4265fce1edc4d51 (patch) | |
tree | 40beeecff2c6031472d851e78bad13c9459e0346 /seq/aseqnet | |
parent | 6a0d13ddb2b2afb450f3404d3cbaa56253bdcab2 (diff) | |
download | alsa-utils-0e21f4d8643db547dcca1375a4265fce1edc4d51.tar.gz |
added an option to aseqnet to optionally set the midi process name
This option allows to run multiple instances of aseqnet without having
to double check the assigned port number, since each one can get spawned
with a unique name.
Fixes: https://github.com/alsa-project/alsa-utils/pull/95
Signed-off-by: Andrea Piras <andrea.piras.85@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'seq/aseqnet')
-rw-r--r-- | seq/aseqnet/README.aseqnet | 2 | ||||
-rw-r--r-- | seq/aseqnet/aseqnet.1 | 3 | ||||
-rw-r--r-- | seq/aseqnet/aseqnet.c | 26 |
3 files changed, 23 insertions, 8 deletions
diff --git a/seq/aseqnet/README.aseqnet b/seq/aseqnet/README.aseqnet index bd0b68e..6a627f4 100644 --- a/seq/aseqnet/README.aseqnet +++ b/seq/aseqnet/README.aseqnet @@ -50,4 +50,6 @@ The available options are: -s addr : explicit read-subscription to the given address (client:addr). -d addr : explicit write-subscription to the given address. + -n name : specify the midi name of the process. + Default value is either 'Net Client' or 'Net Server'. -v : verbose mode. diff --git a/seq/aseqnet/aseqnet.1 b/seq/aseqnet/aseqnet.1 index 2cb6eb7..6ed3911 100644 --- a/seq/aseqnet/aseqnet.1 +++ b/seq/aseqnet/aseqnet.1 @@ -70,6 +70,9 @@ Subscribe to the given address for read automatically. .B \-d addr Subscribe to the given address for write automatically. .TP +.B \-n name +Specify the midi name of the process. +.TP .B \-v Verbose mode. diff --git a/seq/aseqnet/aseqnet.c b/seq/aseqnet/aseqnet.c index ebdea0b..e756e82 100644 --- a/seq/aseqnet/aseqnet.c +++ b/seq/aseqnet/aseqnet.c @@ -37,7 +37,7 @@ static void usage(void); static void init_buf(void); static void init_pollfds(void); static void close_files(void); -static void init_seq(char *source, char *dest); +static void init_seq(char *source, char *dest, char *name); static int get_port(char *service); static void sigterm_exit(int sig); static void init_server(int port); @@ -87,6 +87,7 @@ static const struct option long_option[] = { {"port", 1, NULL, 'p'}, {"source", 1, NULL, 's'}, {"dest", 1, NULL, 'd'}, + {"name", 1, NULL, 'n'}, {"help", 0, NULL, 'h'}, {"verbose", 0, NULL, 'v'}, {"info", 0, NULL, 'i'}, @@ -98,13 +99,14 @@ int main(int argc, char **argv) int c; int port = DEFAULT_PORT; char *source = NULL, *dest = NULL; + char *name = NULL; #ifdef ENABLE_NLS setlocale(LC_ALL, ""); textdomain(PACKAGE); #endif - while ((c = getopt_long(argc, argv, "p:s:d:vi", long_option, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "p:s:d:n:,vi", long_option, NULL)) != -1) { switch (c) { case 'p': if (isdigit(*optarg)) @@ -118,6 +120,9 @@ int main(int argc, char **argv) case 'd': dest = optarg; break; + case 'n': + name = optarg; + break; case 'v': verbose++; break; @@ -134,7 +139,7 @@ int main(int argc, char **argv) signal(SIGTERM, sigterm_exit); init_buf(); - init_seq(source, dest); + init_seq(source, dest, name); if (optind >= argc) { server_mode = 1; @@ -170,6 +175,7 @@ static void usage(void) printf(_(" -p,--port # : specify TCP port (digit or service name)\n")); printf(_(" -s,--source addr : read from given addr (client:port)\n")); printf(_(" -d,--dest addr : write to given addr (client:port)\n")); + printf(_(" -n,--name value : use a specific midi process name\n")); printf(_(" -v, --verbose : print verbose messages\n")); printf(_(" -i, --info : print certain received events\n")); } @@ -223,7 +229,7 @@ static void close_files(void) /* * initialize sequencer */ -static void init_seq(char *source, char *dest) +static void init_seq(char *source, char *dest, char* name) { snd_seq_addr_t addr; int err, counti, counto; @@ -252,10 +258,14 @@ static void init_seq(char *source, char *dest) snd_seq_nonblock(handle, 1); /* set client info */ - if (server_mode) - snd_seq_set_client_name(handle, "Net Server"); - else - snd_seq_set_client_name(handle, "Net Client"); + if (name) + snd_seq_set_client_name(handle, name); + else { + if (server_mode) + snd_seq_set_client_name(handle, "Net Server"); + else + snd_seq_set_client_name(handle, "Net Client"); + } /* create a port */ seq_port = snd_seq_create_simple_port(handle, "Network", |