mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 23:06:30 +01:00
alsactl - add names for unique rawmidi subdevices
When a rawmidi device has subdevices with unique names, add names for all of them instead of only one name for the device.
This commit is contained in:
parent
13e1fc1a1d
commit
1da1c52d03
1 changed files with 33 additions and 5 deletions
|
@ -315,8 +315,9 @@ static int probe_rawmidi_card(int card, snd_ctl_t *ctl, snd_config_t *config)
|
||||||
snd_rawmidi_info_t * info1, * info2;
|
snd_rawmidi_info_t * info1, * info2;
|
||||||
char name[16];
|
char name[16];
|
||||||
const char *dname;
|
const char *dname;
|
||||||
|
const char *subname;
|
||||||
char *flag;
|
char *flag;
|
||||||
int idx;
|
int subdev;
|
||||||
|
|
||||||
snd_rawmidi_info_alloca(&info1);
|
snd_rawmidi_info_alloca(&info1);
|
||||||
snd_rawmidi_info_alloca(&info2);
|
snd_rawmidi_info_alloca(&info2);
|
||||||
|
@ -339,6 +340,7 @@ static int probe_rawmidi_card(int card, snd_ctl_t *ctl, snd_config_t *config)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dname = snd_rawmidi_info_get_name(info1);
|
dname = snd_rawmidi_info_get_name(info1);
|
||||||
|
subname = snd_rawmidi_info_get_subdevice_name(info1);
|
||||||
if (err1 == 0 && err2 == 0)
|
if (err1 == 0 && err2 == 0)
|
||||||
flag = "Duplex";
|
flag = "Duplex";
|
||||||
else if (err1 == 0)
|
else if (err1 == 0)
|
||||||
|
@ -346,11 +348,37 @@ static int probe_rawmidi_card(int card, snd_ctl_t *ctl, snd_config_t *config)
|
||||||
else {
|
else {
|
||||||
flag = "Input";
|
flag = "Input";
|
||||||
dname = snd_rawmidi_info_get_name(info2);
|
dname = snd_rawmidi_info_get_name(info2);
|
||||||
|
subname = snd_rawmidi_info_get_subdevice_name(info2);
|
||||||
|
}
|
||||||
|
if (subname[0] == '\0') {
|
||||||
|
sprintf(name, "hw:%i,%i", card, dev);
|
||||||
|
err = add_entry(config, name, "Physical Device", flag, dname);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
subdev = 0;
|
||||||
|
do {
|
||||||
|
sprintf(name, "hw:%i,%i,%i", card, dev, subdev);
|
||||||
|
if (err1 == 0)
|
||||||
|
subname = snd_rawmidi_info_get_subdevice_name(info1);
|
||||||
|
else
|
||||||
|
subname = snd_rawmidi_info_get_subdevice_name(info2);
|
||||||
|
if (err1 == 0 && err2 == 0)
|
||||||
|
flag = "Duplex";
|
||||||
|
else if (err1 == 0)
|
||||||
|
flag = "Output";
|
||||||
|
else
|
||||||
|
flag = "Input";
|
||||||
|
err = add_entry(config, name, "Physical Device", flag, subname);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
++subdev;
|
||||||
|
snd_rawmidi_info_set_subdevice(info1, subdev);
|
||||||
|
snd_rawmidi_info_set_subdevice(info2, subdev);
|
||||||
|
err1 = snd_ctl_rawmidi_info(ctl, info1);
|
||||||
|
err2 = snd_ctl_rawmidi_info(ctl, info2);
|
||||||
|
} while (err1 == 0 || err2 == 0);
|
||||||
}
|
}
|
||||||
sprintf(name, "hw:%i,%i", card, dev);
|
|
||||||
err = add_entry(config, name, "Physical Device", flag, dname);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue