From ea0520142e6de6a75263e5b2b5d33c6b387e7309 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Thu, 2 Apr 2020 09:18:44 +0200 Subject: [PATCH] If no -q options are used, expose first 8 midi(4) devices to sndiod clients --- sndiod/sndiod.8 | 8 ++++++++ sndiod/sndiod.c | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sndiod/sndiod.8 b/sndiod/sndiod.8 index 404b0e1..81f868d 100644 --- a/sndiod/sndiod.8 +++ b/sndiod/sndiod.8 @@ -271,6 +271,14 @@ the need to restart programs using it. .It Fl q Ar port Expose the given MIDI 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 Attempt to force the device to use this sample rate in Hertz. The default is 48000. diff --git a/sndiod/sndiod.c b/sndiod/sndiod.c index 56cde52..cacf8e3 100644 --- a/sndiod/sndiod.c +++ b/sndiod/sndiod.c @@ -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" "[-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, * that means that the last SIGINT was not handled, because the process @@ -352,7 +361,7 @@ mkopt(char *path, struct dev *d, int main(int argc, char **argv) { - int c, background, unit; + int c, i, background, unit; int pmin, pmax, rmin, rmax; char base[SOCKPATH_MAX], path[SOCKPATH_MAX]; unsigned int mode, dup, mmc, vol; @@ -490,6 +499,10 @@ main(int argc, char **argv) fputs(usagestr, stderr); return 1; } + if (port_list == NULL) { + for (i = 0; default_ports[i] != NULL; i++) + mkport(default_ports[i], 0); + } if (dev_list == NULL) mkdev(DEFAULT_DEV, &par, 0, bufsz, round, rate, hold, autovol); for (d = dev_list; d != NULL; d = d->next) {