summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2020-04-01 16:54:18 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2020-04-01 16:54:18 +0000
commitd4191e243bbc9c5892b41db8acfc90c038e9b58b (patch)
treefad53190f13e47094052e6f93344fa776d5b9b61 /usr.bin/sndiod
parentd42516e4357237a9a12a0a0f82fbde3ae1d3e481 (diff)
If no -q options are used, expose first 8 midi(4) devices to sndiod clients
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r--usr.bin/sndiod/sndiod.812
-rw-r--r--usr.bin/sndiod/sndiod.c17
2 files changed, 25 insertions, 4 deletions
diff --git a/usr.bin/sndiod/sndiod.8 b/usr.bin/sndiod/sndiod.8
index af81829595a..ef03c23639e 100644
--- a/usr.bin/sndiod/sndiod.8
+++ b/usr.bin/sndiod/sndiod.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sndiod.8,v 1.5 2019/09/21 05:49:38 jmc Exp $
+.\" $OpenBSD: sndiod.8,v 1.6 2020/04/01 16:54:17 ratchov Exp $
.\"
.\" Copyright (c) 2006-2012 Alexandre Ratchov <alex@caoua.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 21 2019 $
+.Dd $Mdocdate: April 1 2020 $
.Dt SNDIOD 8
.Os
.Sh NAME
@@ -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/usr.bin/sndiod/sndiod.c b/usr.bin/sndiod/sndiod.c
index 7e48affb1f3..403bfdad8c2 100644
--- a/usr.bin/sndiod/sndiod.c
+++ b/usr.bin/sndiod/sndiod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndiod.c,v 1.38 2020/02/26 13:53:58 ratchov Exp $ */
+/* $OpenBSD: sndiod.c,v 1.39 2020/04/01 16:54:17 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -119,6 +119,15 @@ char usagestr[] = "usage: sndiod [-d] [-a flag] [-b nframes] "
"[-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
* is blocked somewhere, so exit.
@@ -445,7 +454,7 @@ stop_helper(void)
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;
@@ -583,6 +592,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) {