Skip to content

Commit 241fd2a

Browse files
committed
amidi: Ignore inactive MIDI ports as default at listing
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 <[email protected]>
1 parent 007a74a commit 241fd2a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

amidi/amidi.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ Prints the current version.
5252
.I \-l, \-\-list\-devices
5353
Prints a list of all hardware MIDI ports.
5454

55+
.TP
56+
.I \-x, \-\-list\-inactive
57+
Use together with \fI\-l\fP option.
58+
Print all MIDI ports including inactive ports.
59+
5560
.TP
5661
.I \-L, \-\-list\-rawmidis
5762
Prints all RawMIDI definitions.

amidi/amidi.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static int stop;
5757
static int sysex_interval;
5858
static snd_rawmidi_t *input, **inputp;
5959
static snd_rawmidi_t *output, **outputp;
60+
static int list_all;
6061

6162
static void error(const char *format, ...)
6263
{
@@ -76,6 +77,7 @@ static void usage(void)
7677
"-h, --help this help\n"
7778
"-V, --version print current version\n"
7879
"-l, --list-devices list all hardware ports\n"
80+
"-x, --list-inactive list inactive ports, too\n"
7981
"-L, --list-rawmidis list all RawMIDI definitions\n"
8082
"-p, --port=name select port by name\n"
8183
"-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)
151153
card, device, sub, snd_strerror(err));
152154
return;
153155
}
156+
if (!list_all &&
157+
(snd_rawmidi_info_get_flags(info) & SNDRV_RAWMIDI_INFO_STREAM_INACTIVE))
158+
continue;
154159
name = snd_rawmidi_info_get_name(info);
155160
sub_name = snd_rawmidi_info_get_subdevice_name(info);
156161
if (sub == 0 && sub_name[0] == '\0') {
@@ -471,11 +476,12 @@ static void add_send_hex_data(const char *str)
471476

472477
int main(int argc, char *argv[])
473478
{
474-
static const char short_options[] = "hVlLp:s:r:S::dt:aci:T:";
479+
static const char short_options[] = "hVlxLp:s:r:S::dt:aci:T:";
475480
static const struct option long_options[] = {
476481
{"help", 0, NULL, 'h'},
477482
{"version", 0, NULL, 'V'},
478483
{"list-devices", 0, NULL, 'l'},
484+
{"list-inactive", 0, NULL, 'x'},
479485
{"list-rawmidis", 0, NULL, 'L'},
480486
{"port", 1, NULL, 'p'},
481487
{"send", 1, NULL, 's'},
@@ -508,6 +514,9 @@ int main(int argc, char *argv[])
508514
case 'l':
509515
do_device_list = 1;
510516
break;
517+
case 'x':
518+
list_all = 1;
519+
break;
511520
case 'L':
512521
do_rawmidi_list = 1;
513522
break;

0 commit comments

Comments
 (0)