summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2008-11-11 19:21:21 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2008-11-11 19:21:21 +0000
commit3bc33a8c8c92b0092ffe1bb775de2cc4fc8ec6d0 (patch)
tree41b72a3468295aa76e553499fd789f5dd303936d
parented226cc67cb8aa4dfdb4c7aef6f9ab9c7272935e (diff)
expose the volume knob in server mode too
-rw-r--r--usr.bin/aucat/amsg.h6
-rw-r--r--usr.bin/aucat/dev.c8
-rw-r--r--usr.bin/aucat/sock.c42
-rw-r--r--usr.bin/aucat/sock.h3
4 files changed, 52 insertions, 7 deletions
diff --git a/usr.bin/aucat/amsg.h b/usr.bin/aucat/amsg.h
index 510d45ad1ea..56116c9ee2e 100644
--- a/usr.bin/aucat/amsg.h
+++ b/usr.bin/aucat/amsg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: amsg.h,v 1.1 2008/10/26 08:49:43 ratchov Exp $ */
+/* $OpenBSD: amsg.h,v 1.2 2008/11/11 19:21:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -34,6 +34,7 @@ struct amsg {
#define AMSG_DATA 5 /* data block */
#define AMSG_MOVE 6 /* position changed */
#define AMSG_GETCAP 7 /* get capabilities */
+#define AMSG_SETVOL 8 /* set volume */
uint32_t cmd;
uint32_t __pad;
union {
@@ -74,6 +75,9 @@ struct amsg {
struct amsg_ts {
int32_t delta;
} ts;
+ struct amsg_vol {
+ uint32_t ctl;
+ } vol;
} u;
};
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c
index c0443783bb7..236bd26bf79 100644
--- a/usr.bin/aucat/dev.c
+++ b/usr.bin/aucat/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.15 2008/11/11 12:56:02 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.16 2008/11/11 19:21:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -501,10 +501,12 @@ dev_attach(char *name,
void
dev_setvol(struct abuf *ibuf, int vol)
{
- if (!dev_getep(&ibuf, NULL))
+ if (!dev_getep(&ibuf, NULL)) {
+ DPRINTF("dev_setvol: not connected yet\n");
return;
- fprintf(stderr, "vol = %d\n", vol);
+ }
ibuf->mixvol = vol;
+ DPRINTF("dev_setvol: %d\n", vol);
}
/*
diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c
index 76b3f3764a9..ad71bfa69aa 100644
--- a/usr.bin/aucat/sock.c
+++ b/usr.bin/aucat/sock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.c,v 1.2 2008/11/03 22:25:13 ratchov Exp $ */
+/* $OpenBSD: sock.c,v 1.3 2008/11/11 19:21:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -280,6 +280,7 @@ sock_new(struct fileops *ops, int fd, char *name)
f->bufsz = 2 * dev_bufsz;
f->round = dev_round;
f->odelta = f->idelta = 0;
+ f->vol = ADATA_UNIT;
wproc = aproc_new(&wsock_ops, name);
wproc->u.io.file = &f->pipe.file;
@@ -344,6 +345,23 @@ sock_allocbuf(struct sock *f)
}
/*
+ * free buffers
+ */
+void
+sock_setvol(struct sock *f, int vol)
+{
+ struct abuf *rbuf;
+
+ f->vol = vol;
+ rbuf = LIST_FIRST(&f->pipe.file.rproc->obuflist);
+ if (!rbuf) {
+ DPRINTF("sock_setvol: no read buffer yet\n");
+ return;
+ }
+ dev_setvol(rbuf, vol);
+}
+
+/*
* attach play and/or record buffers to dev_mix and/or dev_sub
*/
int
@@ -370,7 +388,9 @@ sock_attach(struct sock *f, int force)
dev_attach(f->pipe.file.name,
(f->mode & AMSG_PLAY) ? rbuf : NULL, &f->rpar, f->xrun,
(f->mode & AMSG_REC) ? wbuf : NULL, &f->wpar, f->xrun);
-
+ if (f->mode & AMSG_PLAY)
+ dev_setvol(rbuf, f->vol);
+
/*
* send the initial position, if needed
*/
@@ -756,6 +776,24 @@ sock_execmsg(struct sock *f)
f->rstate = SOCK_RRET;
f->rtodo = sizeof(struct amsg);
break;
+ case AMSG_SETVOL:
+ DPRINTFN(2, "sock_execmsg: %p: SETVOL\n", f);
+ if (f->pstate != SOCK_RUN &&
+ f->pstate != SOCK_START && f->pstate != SOCK_INIT) {
+ DPRINTF("sock_execmsg: %p: SETVOL, bad state\n", f);
+ aproc_del(f->pipe.file.rproc);
+ return 0;
+ }
+ if (m->u.vol.ctl > MIDI_MAXCTL) {
+ DPRINTF("sock_execmsg: %p: SETVOL, out of range\n", f);
+ aproc_del(f->pipe.file.rproc);
+ return 0;
+ }
+ DPRINTF("sock_execmsg: SETVOL %u\n", m->u.vol.ctl);
+ sock_setvol(f, MIDI_TO_ADATA(m->u.vol.ctl));
+ f->rtodo = sizeof(struct amsg);
+ f->rstate = SOCK_RMSG;
+ break;
default:
DPRINTF("sock_execmsg: %p bogus command\n", f);
aproc_del(f->pipe.file.rproc);
diff --git a/usr.bin/aucat/sock.h b/usr.bin/aucat/sock.h
index 45d96b177e8..ff8b12c7e17 100644
--- a/usr.bin/aucat/sock.h
+++ b/usr.bin/aucat/sock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.h,v 1.1 2008/10/26 08:49:44 ratchov Exp $ */
+/* $OpenBSD: sock.h,v 1.2 2008/11/11 19:21:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -50,6 +50,7 @@ struct sock {
unsigned bufsz; /* total buffer size */
unsigned round; /* block size */
unsigned xrun; /* one of AMSG_IGNORE, ... */
+ unsigned vol;
};
struct sock *sock_new(struct fileops *, int fd, char *);