]> git.alsa-project.org Git - alsa-utils.git/commitdiff
added an option to aseqnet to optionally set the midi process name
authorAndrea Piras <andrea.piras.85@gmail.com>
Fri, 29 Nov 2019 02:13:21 +0000 (03:13 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Jun 2021 10:00:44 +0000 (12:00 +0200)
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>
seq/aseqnet/README.aseqnet
seq/aseqnet/aseqnet.1
seq/aseqnet/aseqnet.c

index bd0b68e69340205cd959d1ca403e104dda770331..6a627f451c878c77c122e38968b8b6656cb260f1 100644 (file)
@@ -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.
index 2cb6eb793fb3e7f764c67dade07282394a78764a..6ed3911bbc55b6c749462aa206c5cabb122afecc 100644 (file)
@@ -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.
 
index ebdea0b49acf25c66a91d3a424ffb772eba0047c..e756e82b9200760a13a6201c0d91c9d8c44e441e 100644 (file)
@@ -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",