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 <tiwai@suse.de>
This commit is contained in:
parent
007a74a867
commit
241fd2aecc
2 changed files with 15 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue