summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-08-21 16:48:04 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-08-21 16:48:04 +0000
commit73e8ba63c46a04a9b2affdc0a36cc570630deec5 (patch)
treef75825b43f5a93dba1ca426db68ebbe73a75cadd /lib
parent09413d5babedee41e813f85e2e1e4726712d00ed (diff)
make aucat(1) expose a MIDI device to control server behaviour in
realtime. For now only the playback volume of individual streams can be changed/monitored. To each stream is assigned a MIDI channel; the volume is changed/monitored using the standard controller number 7.
Diffstat (limited to 'lib')
-rw-r--r--lib/libsndio/mio.c6
-rw-r--r--lib/libsndio/mio_priv.h3
-rw-r--r--lib/libsndio/mio_thru.c33
-rw-r--r--lib/libsndio/sndio.728
4 files changed, 50 insertions, 20 deletions
diff --git a/lib/libsndio/mio.c b/lib/libsndio/mio.c
index 6bdb0a6ac2e..cbeeb5d6be6 100644
--- a/lib/libsndio/mio.c
+++ b/lib/libsndio/mio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio.c,v 1.6 2009/07/27 06:30:34 ratchov Exp $ */
+/* $OpenBSD: mio.c,v 1.7 2009/08/21 16:48:03 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -42,6 +42,7 @@ mio_open(const char *str, unsigned mode, int nbio)
{
static char prefix_midithru[] = "midithru";
static char prefix_rmidi[] = "rmidi";
+ static char prefix_aucat[] = "aucat";
struct mio_hdl *hdl;
struct stat sb;
char *sep, buf[4];
@@ -82,6 +83,9 @@ mio_open(const char *str, unsigned mode, int nbio)
if (len == (sizeof(prefix_midithru) - 1) &&
memcmp(str, prefix_midithru, len) == 0)
return mio_open_thru(sep + 1, mode, nbio);
+ if (len == (sizeof(prefix_aucat) - 1) &&
+ memcmp(str, prefix_aucat, len) == 0)
+ return mio_open_aucat(sep + 1, mode, nbio);
if (len == (sizeof(prefix_rmidi) - 1) &&
memcmp(str, prefix_rmidi, len) == 0)
return mio_open_rmidi(sep + 1, mode, nbio);
diff --git a/lib/libsndio/mio_priv.h b/lib/libsndio/mio_priv.h
index ec217394cc4..f5022dc6839 100644
--- a/lib/libsndio/mio_priv.h
+++ b/lib/libsndio/mio_priv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio_priv.h,v 1.3 2009/07/26 13:33:30 ratchov Exp $ */
+/* $OpenBSD: mio_priv.h,v 1.4 2009/08/21 16:48:03 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -59,6 +59,7 @@ struct mio_ops {
struct mio_hdl *mio_open_rmidi(const char *, unsigned, int);
struct mio_hdl *mio_open_thru(const char *, unsigned, int);
+struct mio_hdl *mio_open_aucat(const char *, unsigned, int);
void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int);
void mio_destroy(struct mio_hdl *);
diff --git a/lib/libsndio/mio_thru.c b/lib/libsndio/mio_thru.c
index 6f58ac7ee6a..a6d494d9377 100644
--- a/lib/libsndio/mio_thru.c
+++ b/lib/libsndio/mio_thru.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio_thru.c,v 1.4 2009/07/26 12:40:45 ratchov Exp $ */
+/* $OpenBSD: mio_thru.c,v 1.5 2009/08/21 16:48:03 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -52,7 +52,7 @@ static struct mio_ops thru_ops = {
};
struct mio_hdl *
-mio_open_thru(const char *str, unsigned mode, int nbio)
+thru_open(const char *str, char *sock, unsigned mode, int nbio)
{
extern char *__progname;
struct amsg msg;
@@ -67,7 +67,7 @@ mio_open_thru(const char *str, unsigned mode, int nbio)
if (strchr(str, '/') != NULL)
return NULL;
snprintf(ca.sun_path, sizeof(ca.sun_path),
- "/tmp/aucat-%u/midithru%s", uid, str);
+ "/tmp/aucat-%u/%s%s", uid, sock, str);
ca.sun_family = AF_UNIX;
hdl = malloc(sizeof(struct thru_hdl));
@@ -81,7 +81,7 @@ mio_open_thru(const char *str, unsigned mode, int nbio)
while (connect(s, (struct sockaddr *)&ca, len) < 0) {
if (errno == EINTR)
continue;
- DPERROR("mio_open_thru: connect");
+ DPERROR("thru_open: connect");
goto bad_connect;
}
if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) {
@@ -100,14 +100,15 @@ mio_open_thru(const char *str, unsigned mode, int nbio)
msg.u.hello.proto |= AMSG_MIDIIN;
if (mode & MIO_OUT)
msg.u.hello.proto |= AMSG_MIDIOUT;
+ strlcpy(msg.u.hello.opt, "default", sizeof(msg.u.hello.opt));
strlcpy(msg.u.hello.who, __progname, sizeof(msg.u.hello.who));
n = write(s, &msg, sizeof(struct amsg));
if (n < 0) {
- DPERROR("mio_open_thru");
+ DPERROR("thru_open");
goto bad_connect;
}
if (n != sizeof(struct amsg)) {
- DPRINTF("mio_open_thru: short write\n");
+ DPRINTF("thru_open: short write\n");
goto bad_connect;
}
todo = sizeof(struct amsg);
@@ -115,22 +116,22 @@ mio_open_thru(const char *str, unsigned mode, int nbio)
while (todo > 0) {
n = read(s, data, todo);
if (n < 0) {
- DPERROR("mio_open_thru");
+ DPERROR("thru_open");
goto bad_connect;
}
if (n == 0) {
- DPRINTF("mio_open_thru: eof\n");
+ DPRINTF("thru_open: eof\n");
goto bad_connect;
}
todo -= n;
data += n;
}
if (msg.cmd != AMSG_ACK) {
- DPRINTF("mio_open_thru: proto error\n");
+ DPRINTF("thru_open: proto error\n");
goto bad_connect;
}
if (nbio && fcntl(hdl->fd, F_SETFL, O_NONBLOCK) < 0) {
- DPERROR("mio_open_thru: fcntl(NONBLOCK)");
+ DPERROR("thru_open: fcntl(NONBLOCK)");
goto bad_connect;
}
return (struct mio_hdl *)hdl;
@@ -142,6 +143,18 @@ mio_open_thru(const char *str, unsigned mode, int nbio)
return NULL;
}
+struct mio_hdl *
+mio_open_thru(const char *str, unsigned mode, int nbio)
+{
+ return thru_open(str, "midithru", mode, nbio);
+}
+
+struct mio_hdl *
+mio_open_aucat(const char *str, unsigned mode, int nbio)
+{
+ return thru_open(str, "softaudio", mode, nbio);
+}
+
static void
thru_close(struct mio_hdl *sh)
{
diff --git a/lib/libsndio/sndio.7 b/lib/libsndio/sndio.7
index e842cb468a3..3a7ac25ef63 100644
--- a/lib/libsndio/sndio.7
+++ b/lib/libsndio/sndio.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sndio.7,v 1.1 2009/07/25 09:55:12 ratchov Exp $
+.\" $OpenBSD: sndio.7,v 1.2 2009/08/21 16:48:03 ratchov Exp $
.\"
.\" Copyright (c) 2007 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: July 25 2009 $
+.Dd $Mdocdate: August 21 2009 $
.Dt SNDIO 7
.Os
.Sh NAME
@@ -60,6 +60,11 @@ applications connected to the thru box (for instance a software sequencer
can send events to multiple software synthesizers).
There's no hardware involved: thru boxes are created by
.Xr midicat 1 .
+.Pp
+Additionally,
+.Xr aucat 1
+exposes a MIDI device used to control and monitor audio streams
+in real time using MIDI.
.Sh DEVICE NAMES
From the user's perspective every audio interface, MIDI port,
.Xr aucat 1
@@ -85,14 +90,17 @@ sockets and hardware
.Xr audio 4
devices.
Possible values for MIDI devices are
-.Pa midithru
-and
+.Pa midithru ,
.Pa rmidi ,
+and
+.Pa aucat
corresponding to
.Xr midicat 1
-software MIDI thru boxes and hardware
+software MIDI thru boxes, hardware
.Xr midi 4
-ports respectively.
+ports and
+.Xr aucat 1
+control through MIDI respectively.
.It Pa unit
For hardware audio or MIDI devices, this corresponds to
the character device minor number.
@@ -119,7 +127,7 @@ For example:
.It Pa sun:0
First hardware audio device.
.It Pa aucat:0
-Default device of the first
+Default audio device of the first
.Xr aucat 1
audio server.
.It Pa aucat:0.rear
@@ -132,7 +140,11 @@ device registered with
Hardware MIDI port number 5.
.It Pa midithru:0
First software MIDI thru box created with
-.Xr aucat 1 .
+.Xr midicat 1 .
+.It Pa aucat:0
+MIDI port controlling the first
+.Xr aucat 1
+audio server.
.El
.Sh ENVIRONMENT
.Bl -tag -width "AUDIODEVICEXXX" -compact