]> git.alsa-project.org Git - alsa-utils.git/commitdiff
amidi: Ignore inactive MIDI ports as default at listing master
authorTakashi Iwai <tiwai@suse.de>
Tue, 28 Oct 2025 12:29:59 +0000 (13:29 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 13 Nov 2025 17:12:16 +0000 (18:12 +0100)
When listing the devices, currently we show all MIDI ports including
inactive ones.  But those inactive ports are rarely useful, and it'd
be more convenient to filter them out.

This patch introduces the filtering of inactive ports at listing
devices via amidi -l option.  When user needs to scan all MIDI ports
including inactive ports, pass the new option -x in addition.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
amidi/amidi.1
amidi/amidi.c

index 5bc24ba3ad547e263516b4a424082b2028960bd5..d3d321f16558e2184097c7ad887ad9a47ad9fc52 100644 (file)
@@ -52,6 +52,11 @@ Prints the current version.
 .I \-l, \-\-list\-devices
 Prints a list of all hardware MIDI ports.
 
+.TP
+.I \-x, \-\-list\-inactive
+Use together with \fI\-l\fP option.
+Print all MIDI ports including inactive ports.
+
 .TP
 .I \-L, \-\-list\-rawmidis
 Prints all RawMIDI definitions.
index 75fb8c0a42a3177b08069db604c248b1b866bed5..9a2aaf7205f0cb657d51cbc789537a56c7dc1f17 100644 (file)
@@ -57,6 +57,7 @@ static int stop;
 static int sysex_interval;
 static snd_rawmidi_t *input, **inputp;
 static snd_rawmidi_t *output, **outputp;
+static int list_all;
 
 static void error(const char *format, ...)
 {
@@ -76,6 +77,7 @@ static void usage(void)
                "-h, --help                      this help\n"
                "-V, --version                   print current version\n"
                "-l, --list-devices              list all hardware ports\n"
+               "-x, --list-inactive             list inactive ports, too\n"
                "-L, --list-rawmidis             list all RawMIDI definitions\n"
                "-p, --port=name                 select port by name\n"
                "-s, --send=file                 send the contents of a (.syx) file\n"
@@ -151,6 +153,9 @@ static void list_device(snd_ctl_t *ctl, int card, int device)
                              card, device, sub, snd_strerror(err));
                        return;
                }
+               if (!list_all &&
+                   (snd_rawmidi_info_get_flags(info) & SNDRV_RAWMIDI_INFO_STREAM_INACTIVE))
+                       continue;
                name = snd_rawmidi_info_get_name(info);
                sub_name = snd_rawmidi_info_get_subdevice_name(info);
                if (sub == 0 && sub_name[0] == '\0') {
@@ -471,11 +476,12 @@ static void add_send_hex_data(const char *str)
 
 int main(int argc, char *argv[])
 {
-       static const char short_options[] = "hVlLp:s:r:S::dt:aci:T:";
+       static const char short_options[] = "hVlxLp:s:r:S::dt:aci:T:";
        static const struct option long_options[] = {
                {"help", 0, NULL, 'h'},
                {"version", 0, NULL, 'V'},
                {"list-devices", 0, NULL, 'l'},
+               {"list-inactive", 0, NULL, 'x'},
                {"list-rawmidis", 0, NULL, 'L'},
                {"port", 1, NULL, 'p'},
                {"send", 1, NULL, 's'},
@@ -508,6 +514,9 @@ int main(int argc, char *argv[])
                case 'l':
                        do_device_list = 1;
                        break;
+               case 'x':
+                       list_all = 1;
+                       break;
                case 'L':
                        do_rawmidi_list = 1;
                        break;