If no -q options are used, expose first 8 midi(4) devices to sndiod clients

This commit is contained in:
Alexandre Ratchov 2020-04-02 09:18:44 +02:00
parent 3d5dbc6b9f
commit ea0520142e
2 changed files with 22 additions and 1 deletions

View File

@ -271,6 +271,14 @@ the need to restart programs using it.
.It Fl q Ar port .It Fl q Ar port
Expose the given MIDI port. Expose the given MIDI port.
This allows multiple programs to share the port. This allows multiple programs to share the port.
If no
.Fl q
option is used,
.Nm
will use
.Pa rmidi/0 , rmidi/1 ,
.No ... ,
.Pa rmidi/7 .
.It Fl r Ar rate .It Fl r Ar rate
Attempt to force the device to use this sample rate in Hertz. Attempt to force the device to use this sample rate in Hertz.
The default is 48000. The default is 48000.

View File

@ -111,6 +111,15 @@ char usagestr[] = "usage: sndiod [-d] [-a flag] [-b nframes] "
"[-Q port] [-q port] [-r rate] [-s name] [-t mode] [-U unit]\n\t" "[-Q port] [-q port] [-r rate] [-s name] [-t mode] [-U unit]\n\t"
"[-v volume] [-w flag] [-z nframes]\n"; "[-v volume] [-w flag] [-z nframes]\n";
/*
* default MIDI ports
*/
static char *default_ports[] = {
"rmidi/0", "rmidi/1", "rmidi/2", "rmidi/3",
"rmidi/4", "rmidi/5", "rmidi/6", "rmidi/7",
NULL
};
/* /*
* SIGINT handler, it raises the quit flag. If the flag is already set, * SIGINT handler, it raises the quit flag. If the flag is already set,
* that means that the last SIGINT was not handled, because the process * that means that the last SIGINT was not handled, because the process
@ -352,7 +361,7 @@ mkopt(char *path, struct dev *d,
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int c, background, unit; int c, i, background, unit;
int pmin, pmax, rmin, rmax; int pmin, pmax, rmin, rmax;
char base[SOCKPATH_MAX], path[SOCKPATH_MAX]; char base[SOCKPATH_MAX], path[SOCKPATH_MAX];
unsigned int mode, dup, mmc, vol; unsigned int mode, dup, mmc, vol;
@ -490,6 +499,10 @@ main(int argc, char **argv)
fputs(usagestr, stderr); fputs(usagestr, stderr);
return 1; return 1;
} }
if (port_list == NULL) {
for (i = 0; default_ports[i] != NULL; i++)
mkport(default_ports[i], 0);
}
if (dev_list == NULL) if (dev_list == NULL)
mkdev(DEFAULT_DEV, &par, 0, bufsz, round, rate, hold, autovol); mkdev(DEFAULT_DEV, &par, 0, bufsz, round, rate, hold, autovol);
for (d = dev_list; d != NULL; d = d->next) { for (d = dev_list; d != NULL; d = d->next) {