summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/aucat/Makefile4
-rw-r--r--usr.bin/aucat/abuf.c116
-rw-r--r--usr.bin/aucat/abuf.h3
-rw-r--r--usr.bin/aucat/aparams.c27
-rw-r--r--usr.bin/aucat/aparams.h5
-rw-r--r--usr.bin/aucat/aproc.c163
-rw-r--r--usr.bin/aucat/aproc.h3
-rw-r--r--usr.bin/aucat/aucat.112
-rw-r--r--usr.bin/aucat/aucat.c73
-rw-r--r--usr.bin/aucat/conf.h28
-rw-r--r--usr.bin/aucat/dev.c47
-rw-r--r--usr.bin/aucat/file.c95
-rw-r--r--usr.bin/aucat/file.h3
-rw-r--r--usr.bin/aucat/headers.c14
-rw-r--r--usr.bin/aucat/listen.c3
-rw-r--r--usr.bin/aucat/midi.c41
-rw-r--r--usr.bin/aucat/midicat.115
-rw-r--r--usr.bin/aucat/miofile.c10
-rw-r--r--usr.bin/aucat/opt.c13
-rw-r--r--usr.bin/aucat/pipe.c43
-rw-r--r--usr.bin/aucat/safile.c52
-rw-r--r--usr.bin/aucat/sock.c126
-rw-r--r--usr.bin/aucat/sock.h3
-rw-r--r--usr.bin/aucat/wav.c9
24 files changed, 89 insertions, 819 deletions
diff --git a/usr.bin/aucat/Makefile b/usr.bin/aucat/Makefile
index 2a8844d207b..5aad09ff145 100644
--- a/usr.bin/aucat/Makefile
+++ b/usr.bin/aucat/Makefile
@@ -1,10 +1,10 @@
-# $OpenBSD: Makefile,v 1.9 2009/07/25 08:44:27 ratchov Exp $
+# $OpenBSD: Makefile,v 1.10 2009/09/27 11:51:20 ratchov Exp $
PROG= aucat
SRCS= aucat.c abuf.c aparams.c aproc.c dev.c midi.c file.c headers.c \
safile.c miofile.c sock.c pipe.c listen.c opt.c wav.c legacy.c
MAN= aucat.1 midicat.1
LINKS= ${BINDIR}/aucat ${BINDIR}/midicat
-CFLAGS+= -DDEBUG -Wall -Wstrict-prototypes -Wundef
+CFLAGS+= -Wall -Wstrict-prototypes -Wundef
LDADD+= -lsndio
.include <bsd.prog.mk>
diff --git a/usr.bin/aucat/abuf.c b/usr.bin/aucat/abuf.c
index f989498816e..5485f0147b7 100644
--- a/usr.bin/aucat/abuf.c
+++ b/usr.bin/aucat/abuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abuf.c,v 1.14 2009/08/21 16:48:03 ratchov Exp $ */
+/* $OpenBSD: abuf.c,v 1.15 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -42,27 +42,6 @@
#include "aproc.h"
#include "conf.h"
-#ifdef DEBUG
-void
-abuf_dprn(int n, struct abuf *buf, char *fmt, ...)
-{
- va_list ap;
-
- if (debug_level < n)
- return;
- fprintf(stderr, "%s->%s: ",
- buf->wproc ? buf->wproc->name : "none",
- buf->rproc ? buf->rproc->name : "none");
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-}
-#define ABUF_DPRN(n, buf, ...) abuf_dprn((n), (buf), __VA_ARGS__)
-#define ABUF_DPR(buf, ...) abuf_dprn(1, (buf), __VA_ARGS__)
-#else
-#define ABUF_DPRN(n, buf, ...) do {} while (0)
-#define ABUF_DPR(buf, ...) do {} while (0)
-#endif
struct abuf *
abuf_new(unsigned nfr, struct aparams *par)
@@ -74,8 +53,7 @@ abuf_new(unsigned nfr, struct aparams *par)
len = nfr * bpf;
buf = malloc(sizeof(struct abuf) + len);
if (buf == NULL) {
- fprintf(stderr, "abuf_new: out of mem: %u * %u\n", nfr, bpf);
- abort();
+ err(1, "malloc");
}
buf->bpf = bpf;
buf->cmin = par->cmin;
@@ -103,21 +81,6 @@ abuf_del(struct abuf *buf)
{
if (buf->duplex)
buf->duplex->duplex = NULL;
-#ifdef DEBUG
- if (buf->rproc || buf->wproc || ABUF_ROK(buf)) {
- /*
- * XXX : we should call abort(), here.
- * However, poll() doesn't seem to return POLLHUP,
- * so the reader is never destroyed; instead it appears
- * as blocked. Fix file_poll(), if fixable, and add
- * a call to abord() here.
- */
-#if 0
- ABUF_DPRN(0, buf, "abuf_del: used = %u\n", buf->used);
- abort();
-#endif
- }
-#endif
free(buf);
}
@@ -127,7 +90,6 @@ abuf_del(struct abuf *buf)
void
abuf_clear(struct abuf *buf)
{
- ABUF_DPR(buf, "abuf_clear:\n");
buf->used = 0;
buf->start = 0;
buf->abspos = 0;
@@ -147,14 +109,6 @@ abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs)
used = buf->used - ofs;
if (start >= buf->len)
start -= buf->len;
-#ifdef DEBUG
- if (start >= buf->len || used > buf->used) {
- ABUF_DPRN(0, buf, "abuf_rgetblk: "
- "bad ofs: start = %u used = %u/%u, ofs = %u\n",
- buf->start, buf->used, buf->len, ofs);
- abort();
- }
-#endif
count = buf->len - start;
if (count > used)
count = used;
@@ -168,12 +122,6 @@ abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs)
void
abuf_rdiscard(struct abuf *buf, unsigned count)
{
-#ifdef DEBUG
- if (count > buf->used) {
- ABUF_DPRN(0, buf, "abuf_rdiscard: bad count %u\n", count);
- abort();
- }
-#endif
buf->used -= count;
buf->start += count;
if (buf->start >= buf->len)
@@ -187,12 +135,6 @@ abuf_rdiscard(struct abuf *buf, unsigned count)
void
abuf_wcommit(struct abuf *buf, unsigned count)
{
-#ifdef DEBUG
- if (count > (buf->len - buf->used)) {
- ABUF_DPR(buf, "abuf_wcommit: bad count\n");
- abort();
- }
-#endif
buf->used += count;
}
@@ -208,15 +150,6 @@ abuf_wgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs)
end = buf->start + buf->used + ofs;
if (end >= buf->len)
end -= buf->len;
-#ifdef DEBUG
- if (end >= buf->len) {
- ABUF_DPR(buf, "abuf_wgetblk: %s -> %s: bad ofs, "
- "start = %u, used = %u, len = %u, ofs = %u\n",
- buf->wproc->name, buf->rproc->name,
- buf->start, buf->used, buf->len, ofs);
- abort();
- }
-#endif
avail = buf->len - (buf->used + ofs);
count = buf->len - end;
if (count > avail)
@@ -240,17 +173,15 @@ abuf_flush_do(struct abuf *buf)
if (count > buf->used)
count = buf->used;
if (count == 0) {
- ABUF_DPR(buf, "abuf_flush_do: no data to drop\n");
return 0;
}
abuf_rdiscard(buf, count);
buf->drop -= count;
- ABUF_DPR(buf, "abuf_flush_do: drop = %u\n", buf->drop);
- p = buf->rproc;
} else {
- ABUF_DPRN(4, buf, "abuf_flush_do: in ready\n");
p = buf->rproc;
- if (!p || !p->ops->in(p, buf))
+ if (!p)
+ return 0;
+ if (!p->ops->in(p, buf))
return 0;
}
return 1;
@@ -272,18 +203,17 @@ abuf_fill_do(struct abuf *buf)
if (count >= buf->silence)
count = buf->silence;
if (count == 0) {
- ABUF_DPR(buf, "abuf_fill_do: no space for silence\n");
return 0;
}
memset(data, 0, count);
abuf_wcommit(buf, count);
buf->silence -= count;
- ABUF_DPR(buf, "abuf_fill_do: silence = %u\n", buf->silence);
p = buf->wproc;
} else {
- ABUF_DPRN(4, buf, "abuf_fill_do: out avail\n");
p = buf->wproc;
- if (p == NULL || !p->ops->out(p, buf)) {
+ if (!p)
+ return 0;
+ if (!p->ops->out(p, buf)) {
return 0;
}
}
@@ -301,14 +231,12 @@ abuf_eof_do(struct abuf *buf)
p = buf->rproc;
if (p) {
- ABUF_DPRN(2, buf, "abuf_eof_do: signaling reader\n");
buf->rproc = NULL;
LIST_REMOVE(buf, ient);
buf->inuse++;
p->ops->eof(p, buf);
buf->inuse--;
- } else
- ABUF_DPR(buf, "abuf_eof_do: no reader, freeng buf\n");
+ }
abuf_del(buf);
}
@@ -322,19 +250,16 @@ abuf_hup_do(struct abuf *buf)
struct aproc *p;
if (ABUF_ROK(buf)) {
- ABUF_DPR(buf, "abuf_hup_do: lost %u bytes\n", buf->used);
buf->used = 0;
}
p = buf->wproc;
if (p != NULL) {
- ABUF_DPRN(2, buf, "abuf_hup_do: signaling writer\n");
buf->wproc = NULL;
LIST_REMOVE(buf, oent);
buf->inuse++;
p->ops->hup(p, buf);
buf->inuse--;
- } else
- ABUF_DPR(buf, "abuf_hup_do: no writer, freeng buf\n");
+ }
abuf_del(buf);
}
@@ -346,7 +271,6 @@ int
abuf_flush(struct abuf *buf)
{
if (buf->inuse) {
- ABUF_DPRN(4, buf, "abuf_flush: blocked\n");
} else {
buf->inuse++;
for (;;) {
@@ -375,7 +299,6 @@ int
abuf_fill(struct abuf *buf)
{
if (buf->inuse) {
- ABUF_DPRN(4, buf, "abuf_fill: blocked\n");
} else {
buf->inuse++;
for (;;) {
@@ -405,7 +328,6 @@ abuf_run(struct abuf *buf)
int canfill = 1, canflush = 1;
if (buf->inuse) {
- ABUF_DPRN(4, buf, "abuf_run: blocked\n");
return;
}
buf->inuse++;
@@ -442,13 +364,6 @@ abuf_run(struct abuf *buf)
void
abuf_eof(struct abuf *buf)
{
-#ifdef DEBUG
- if (buf->wproc == NULL) {
- ABUF_DPR(buf, "abuf_eof: no writer\n");
- abort();
- }
-#endif
- ABUF_DPRN(2, buf, "abuf_eof: requested\n");
LIST_REMOVE(buf, oent);
buf->wproc = NULL;
if (buf->rproc != NULL) {
@@ -459,12 +374,10 @@ abuf_eof(struct abuf *buf)
* Could not flush everything, the reader will
* have a chance to delete the abuf later.
*/
- ABUF_DPRN(2, buf, "abuf_eof: will drain later\n");
return;
}
}
if (buf->inuse) {
- ABUF_DPRN(2, buf, "abuf_eof: signal blocked\n");
return;
}
abuf_eof_do(buf);
@@ -477,19 +390,10 @@ abuf_eof(struct abuf *buf)
void
abuf_hup(struct abuf *buf)
{
-#ifdef DEBUG
- if (buf->rproc == NULL) {
- ABUF_DPR(buf, "abuf_hup: no reader\n");
- abort();
- }
-#endif
- ABUF_DPRN(2, buf, "abuf_hup: initiated\n");
-
buf->rproc = NULL;
LIST_REMOVE(buf, ient);
if (buf->wproc != NULL) {
if (buf->inuse) {
- ABUF_DPRN(2, buf, "abuf_hup: signal blocked\n");
return;
}
}
diff --git a/usr.bin/aucat/abuf.h b/usr.bin/aucat/abuf.h
index 636d32eb5d1..659e658897e 100644
--- a/usr.bin/aucat/abuf.h
+++ b/usr.bin/aucat/abuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: abuf.h,v 1.17 2009/07/25 08:44:27 ratchov Exp $ */
+/* $OpenBSD: abuf.h,v 1.18 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -106,6 +106,7 @@ struct abuf {
struct abuf *abuf_new(unsigned, struct aparams *);
void abuf_del(struct abuf *);
+void abuf_dbg(struct abuf *);
void abuf_clear(struct abuf *);
unsigned char *abuf_rgetblk(struct abuf *, unsigned *, unsigned);
unsigned char *abuf_wgetblk(struct abuf *, unsigned *, unsigned);
diff --git a/usr.bin/aucat/aparams.c b/usr.bin/aucat/aparams.c
index e94086ad6d3..eabdd0a80f4 100644
--- a/usr.bin/aucat/aparams.c
+++ b/usr.bin/aucat/aparams.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aparams.c,v 1.8 2009/08/17 15:07:49 ratchov Exp $ */
+/* $OpenBSD: aparams.c,v 1.9 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -15,10 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "aparams.h"
int aparams_ctltovol[128] = {
@@ -185,27 +181,6 @@ aparams_init(struct aparams *par, unsigned cmin, unsigned cmax, unsigned rate)
par->rate = rate;
}
-/*
- * Print the format/channels/encoding on stderr.
- */
-void
-aparams_print(struct aparams *par)
-{
- char enc[ENCMAX];
-
- aparams_enctostr(par, enc);
- fprintf(stderr, "%s", enc);
- fprintf(stderr, ",%u:%u", par->cmin, par->cmax);
- fprintf(stderr, ",%uHz", par->rate);
-}
-
-void
-aparams_print2(struct aparams *par1, struct aparams *par2)
-{
- aparams_print(par1);
- fprintf(stderr, " -> ");
- aparams_print(par2);
-}
/*
* Return true if both encodings are the same.
diff --git a/usr.bin/aucat/aparams.h b/usr.bin/aucat/aparams.h
index 8e0b9b33096..c36195e642a 100644
--- a/usr.bin/aucat/aparams.h
+++ b/usr.bin/aucat/aparams.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aparams.h,v 1.7 2009/08/17 15:07:49 ratchov Exp $ */
+/* $OpenBSD: aparams.h,v 1.8 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -76,8 +76,7 @@ extern int aparams_ctltovol[128];
extern struct aparams aparams_none;
void aparams_init(struct aparams *, unsigned, unsigned, unsigned);
-void aparams_print(struct aparams *);
-void aparams_print2(struct aparams *, struct aparams *);
+void aparams_dbg(struct aparams *);
int aparams_eqrate(struct aparams *, struct aparams *);
int aparams_eqenc(struct aparams *, struct aparams *);
int aparams_eq(struct aparams *, struct aparams *);
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index 364338b3b29..b7f8853d17f 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.33 2009/07/25 10:52:18 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.34 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -33,19 +33,8 @@
*
* - resamp: resample streams in native format
*
- * TODO
- *
- * (easy) split the "conv" into 2 converters: one for input (that
- * convers anything to 16bit signed) and one for the output (that
- * converts 16bit signed to anything)
- *
- * (hard) add a lowpass filter for the resampler. Quality is
- * not acceptable as is.
- *
*/
#include <err.h>
-#include <limits.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -55,6 +44,7 @@
#include "conf.h"
#include "file.h"
+
struct aproc *
aproc_new(struct aproc_ops *ops, char *name)
{
@@ -76,11 +66,14 @@ aproc_del(struct aproc *p)
{
struct abuf *i;
- DPRINTF("aproc_del: %s(%s): terminating...\n", p->ops->name, p->name);
+ /*
+ * XXX: souldn't call ops->done() and friends twice
+ * use a ``zomb'' flag or whatever
+ */
- if (p->ops->done)
+ if (p->ops->done) {
p->ops->done(p);
-
+ }
while (!LIST_EMPTY(&p->ibuflist)) {
i = LIST_FIRST(&p->ibuflist);
abuf_hup(i);
@@ -89,11 +82,8 @@ aproc_del(struct aproc *p)
i = LIST_FIRST(&p->obuflist);
abuf_eof(i);
}
- if (p->refs > 0) {
- DPRINTF("aproc_del: %s(%s): has refs\n", p->ops->name, p->name);
+ if (p->refs > 0)
return;
- }
- DPRINTF("aproc_del: %s(%s): freed\n", p->ops->name, p->name);
free(p);
}
@@ -120,8 +110,6 @@ aproc_ipos(struct aproc *p, struct abuf *ibuf, int delta)
{
struct abuf *obuf;
- DPRINTFN(3, "aproc_ipos: %s: delta = %d\n", p->name, delta);
-
LIST_FOREACH(obuf, &p->obuflist, oent) {
abuf_ipos(obuf, delta);
}
@@ -132,8 +120,6 @@ aproc_opos(struct aproc *p, struct abuf *obuf, int delta)
{
struct abuf *ibuf;
- DPRINTFN(3, "aproc_opos: %s: delta = %d\n", p->name, delta);
-
LIST_FOREACH(ibuf, &p->ibuflist, ient) {
abuf_opos(ibuf, delta);
}
@@ -152,7 +138,6 @@ aproc_inuse(struct aproc *p)
if (i->inuse)
return 1;
}
- DPRINTFN(3, "aproc_inuse: %s: not inuse\n", p->name);
return 0;
}
@@ -178,8 +163,6 @@ rpipe_in(struct aproc *p, struct abuf *ibuf_dummy)
unsigned char *data;
unsigned count;
- DPRINTFN(3, "rpipe_in: %s\n", p->name);
-
if (ABUF_FULL(obuf) || !(f->state & FILE_ROK))
return 0;
data = abuf_wgetblk(obuf, &count, 0);
@@ -201,8 +184,6 @@ rpipe_out(struct aproc *p, struct abuf *obuf)
if (f->state & FILE_RINUSE)
return 0;
- DPRINTFN(3, "rpipe_out: %s\n", p->name);
-
if (ABUF_FULL(obuf) || !(f->state & FILE_ROK))
return 0;
data = abuf_wgetblk(obuf, &count, 0);
@@ -229,14 +210,12 @@ rpipe_done(struct aproc *p)
void
rpipe_eof(struct aproc *p, struct abuf *ibuf_dummy)
{
- DPRINTFN(3, "rpipe_eof: %s\n", p->name);
aproc_del(p);
}
void
rpipe_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTFN(3, "rpipe_hup: %s\n", p->name);
aproc_del(p);
}
@@ -286,8 +265,6 @@ wpipe_in(struct aproc *p, struct abuf *ibuf)
if (f->state & FILE_WINUSE)
return 0;
- DPRINTFN(3, "wpipe_in: %s\n", p->name);
-
if (ABUF_EMPTY(ibuf) || !(f->state & FILE_WOK))
return 0;
data = abuf_rgetblk(ibuf, &count, 0);
@@ -306,17 +283,13 @@ wpipe_out(struct aproc *p, struct abuf *obuf_dummy)
unsigned char *data;
unsigned count;
- DPRINTFN(3, "wpipe_out: %s\n", p->name);
-
- if (!abuf_fill(ibuf)) {
- DPRINTFN(3, "wpipe_out: fill failed\n");
+ if (!abuf_fill(ibuf))
return 0;
- }
if (ABUF_EMPTY(ibuf) || !(f->state & FILE_WOK))
return 0;
data = abuf_rgetblk(ibuf, &count, 0);
if (count == 0) {
- DPRINTF("wpipe_out: %s: underrun\n", p->name);
+ /* XXX: this can't happen, right ? */
return 0;
}
count = file_write(f, data, count);
@@ -329,14 +302,12 @@ wpipe_out(struct aproc *p, struct abuf *obuf_dummy)
void
wpipe_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTFN(3, "wpipe_eof: %s\n", p->name);
aproc_del(p);
}
void
wpipe_hup(struct aproc *p, struct abuf *obuf_dummy)
{
- DPRINTFN(3, "wpipe_hup: %s\n", p->name);
aproc_del(p);
}
@@ -374,7 +345,6 @@ mix_bzero(struct abuf *obuf, unsigned zcount)
short *odata;
unsigned ocount;
- DPRINTFN(4, "mix_bzero: used = %u, zcount = %u\n", obuf->used, zcount);
odata = (short *)abuf_wgetblk(obuf, &ocount, obuf->mixitodo);
ocount -= ocount % obuf->bpf;
if (ocount > zcount)
@@ -394,9 +364,6 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf)
unsigned scount, icount, ocount, zcount;
int vol;
- DPRINTFN(4, "mix_badd: todo = %u, done = %u\n",
- obuf->mixitodo, ibuf->mixodone);
-
/*
* Calculate the maximum we can read.
*/
@@ -437,8 +404,6 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf)
abuf_rdiscard(ibuf, scount * ibuf->bpf);
ibuf->mixodone += scount * obuf->bpf;
- DPRINTFN(4, "mix_badd: added %u, done = %u, todo = %u\n",
- scount, ibuf->mixodone, obuf->mixitodo);
}
/*
@@ -463,12 +428,10 @@ mix_xrun(struct abuf *i, struct abuf *obuf)
else {
abuf_opos(i, -(int)fdrop);
if (i->duplex) {
- DPRINTF("mix_xrun: duplex %u\n", fdrop);
i->duplex->drop += fdrop * i->duplex->bpf;
abuf_ipos(i->duplex, -(int)fdrop);
}
}
- DPRINTF("mix_xrun: drop = %u\n", i->drop);
return 1;
}
@@ -478,9 +441,6 @@ mix_in(struct aproc *p, struct abuf *ibuf)
struct abuf *i, *inext, *obuf = LIST_FIRST(&p->obuflist);
unsigned odone;
- DPRINTFN(4, "mix_in: used/len = %u/%u, done/todo = %u/%u\n",
- ibuf->used, ibuf->len, ibuf->mixodone, obuf->mixitodo);
-
if (!ABUF_ROK(ibuf))
return 0;
odone = obuf->len;
@@ -511,9 +471,6 @@ mix_out(struct aproc *p, struct abuf *obuf)
struct abuf *i, *inext;
unsigned odone;
- DPRINTFN(4, "mix_out: used/len = %u/%u, todo/len = %u/%u\n",
- obuf->used, obuf->len, obuf->mixitodo, obuf->len);
-
if (!ABUF_WOK(obuf))
return 0;
odone = obuf->len;
@@ -533,7 +490,6 @@ mix_out(struct aproc *p, struct abuf *obuf)
}
if (LIST_EMPTY(&p->ibuflist)) {
if (p->u.mix.flags & MIX_AUTOQUIT) {
- DPRINTF("mix_out: nothing more to do...\n");
aproc_del(p);
return 0;
}
@@ -560,11 +516,9 @@ mix_eof(struct aproc *p, struct abuf *ibuf)
struct abuf *i, *obuf = LIST_FIRST(&p->obuflist);
unsigned odone;
- DPRINTF("mix_eof: %s: detached\n", p->name);
mix_setmaster(p);
if (!aproc_inuse(p)) {
- DPRINTF("mix_eof: %s: from input\n", p->name);
/*
* Find a blocked input.
*/
@@ -588,19 +542,12 @@ mix_eof(struct aproc *p, struct abuf *ibuf)
void
mix_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTF("mix_hup: %s: done\n", p->name);
aproc_del(p);
}
void
mix_newin(struct aproc *p, struct abuf *ibuf)
{
- struct abuf *obuf = LIST_FIRST(&p->obuflist);
-
- if (!obuf || ibuf->cmin < obuf->cmin || ibuf->cmax > obuf->cmax) {
- fprintf(stderr, "mix_newin: channel ranges mismatch\n");
- abort();
- }
p->u.mix.idle = 0;
ibuf->mixodone = 0;
ibuf->mixvol = ADATA_UNIT;
@@ -612,14 +559,12 @@ mix_newin(struct aproc *p, struct abuf *ibuf)
void
mix_newout(struct aproc *p, struct abuf *obuf)
{
- DPRINTF("mix_newout: using %u fpb\n", obuf->len / obuf->bpf);
obuf->mixitodo = 0;
}
void
mix_opos(struct aproc *p, struct abuf *obuf, int delta)
{
- DPRINTFN(3, "mix_opos: lat = %d/%d\n", p->u.mix.lat, p->u.mix.maxlat);
p->u.mix.lat -= delta;
aproc_opos(p, obuf, delta);
}
@@ -669,8 +614,6 @@ mix_setmaster(struct aproc *p)
if (weight > buf->mixmaxweight)
weight = buf->mixmaxweight;
buf->mixweight = weight;
- DPRINTF("mix_setmaster: %p: %d/%d -> %d\n", buf,
- buf->mixweight, buf->mixmaxweight, weight);
}
}
@@ -716,7 +659,6 @@ sub_bcopy(struct abuf *ibuf, struct abuf *obuf)
}
abuf_wcommit(obuf, scount * obuf->bpf);
obuf->subidone += scount * ibuf->bpf;
- DPRINTFN(4, "sub_bcopy: %u frames\n", scount);
}
/*
@@ -739,13 +681,11 @@ sub_xrun(struct abuf *ibuf, struct abuf *i)
else {
abuf_ipos(i, -(int)fdrop);
if (i->duplex) {
- DPRINTF("sub_xrun: duplex %u\n", fdrop);
i->duplex->silence += fdrop * i->duplex->bpf;
abuf_opos(i->duplex, -(int)fdrop);
}
}
i->subidone += fdrop * ibuf->bpf;
- DPRINTF("sub_xrun: silence = %u\n", i->silence);
return 1;
}
@@ -774,7 +714,6 @@ sub_in(struct aproc *p, struct abuf *ibuf)
}
if (LIST_EMPTY(&p->obuflist)) {
if (p->u.sub.flags & SUB_AUTOQUIT) {
- DPRINTF("sub_in: nothing more to do...\n");
aproc_del(p);
return 0;
}
@@ -826,7 +765,6 @@ sub_out(struct aproc *p, struct abuf *obuf)
void
sub_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTF("sub_hup: %s: eof\n", p->name);
aproc_del(p);
}
@@ -836,10 +774,7 @@ sub_hup(struct aproc *p, struct abuf *obuf)
struct abuf *i, *ibuf = LIST_FIRST(&p->ibuflist);
unsigned idone;
- DPRINTF("sub_hup: %s: detached\n", p->name);
-
if (!aproc_inuse(p)) {
- DPRINTF("sub_hup: %s: from input\n", p->name);
/*
* Find a blocked output.
*/
@@ -863,12 +798,6 @@ sub_hup(struct aproc *p, struct abuf *obuf)
void
sub_newout(struct aproc *p, struct abuf *obuf)
{
- struct abuf *ibuf = LIST_FIRST(&p->ibuflist);
-
- if (!ibuf || obuf->cmin < ibuf->cmin || obuf->cmax > ibuf->cmax) {
- fprintf(stderr, "sub_newout: channel ranges mismatch\n");
- abort();
- }
p->u.sub.idle = 0;
obuf->subidone = 0;
obuf->xrun = XRUN_IGNORE;
@@ -878,7 +807,6 @@ void
sub_ipos(struct aproc *p, struct abuf *ibuf, int delta)
{
p->u.sub.lat += delta;
- DPRINTFN(3, "sub_ipos: lat = %d/%d\n", p->u.sub.lat, p->u.sub.maxlat);
aproc_ipos(p, ibuf, delta);
}
@@ -961,7 +889,6 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
/*
* Start conversion.
*/
- DPRINTFN(4, "resamp_bcopy: ifr=%d ofr=%d\n", ifr, ofr);
for (;;) {
if (diff < 0) {
if (ifr == 0)
@@ -990,8 +917,6 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
}
p->u.resamp.diff = diff;
p->u.resamp.ctx_start = ctx_start;
- DPRINTFN(4, "resamp_bcopy: done, ifr=%d ofr=%d\n", ifr, ofr);
-
/*
* Update FIFO pointers.
*/
@@ -1006,8 +931,6 @@ resamp_in(struct aproc *p, struct abuf *ibuf)
{
struct abuf *obuf = LIST_FIRST(&p->obuflist);
- DPRINTFN(4, "resamp_in: %s\n", p->name);
-
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
return 0;
resamp_bcopy(p, ibuf, obuf);
@@ -1021,8 +944,6 @@ resamp_out(struct aproc *p, struct abuf *obuf)
{
struct abuf *ibuf = LIST_FIRST(&p->ibuflist);
- DPRINTFN(4, "resamp_out: %s\n", p->name);
-
if (!abuf_fill(ibuf))
return 0;
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
@@ -1034,16 +955,12 @@ resamp_out(struct aproc *p, struct abuf *obuf)
void
resamp_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTFN(4, "resamp_eof: %s\n", p->name);
-
aproc_del(p);
}
void
resamp_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTFN(4, "resamp_hup: %s\n", p->name);
-
aproc_del(p);
}
@@ -1054,8 +971,6 @@ resamp_ipos(struct aproc *p, struct abuf *ibuf, int delta)
long long ipos;
int ifac, ofac;
- DPRINTFN(3, "resamp_ipos: %d\n", delta);
-
ifac = p->u.resamp.iblksz;
ofac = p->u.resamp.oblksz;
ipos = p->u.resamp.idelta + (long long)delta * ofac;
@@ -1071,8 +986,6 @@ resamp_opos(struct aproc *p, struct abuf *obuf, int delta)
long long opos;
int ifac, ofac;
- DPRINTFN(3, "resamp_opos: %d\n", delta);
-
ifac = p->u.resamp.iblksz;
ofac = p->u.resamp.oblksz;
opos = p->u.resamp.odelta + (long long)delta * ifac;
@@ -1109,10 +1022,6 @@ resamp_new(char *name, unsigned iblksz, unsigned oblksz)
p->u.resamp.ctx_start = 0;
for (i = 0; i < NCHAN_MAX * RESAMP_NCTX; i++)
p->u.resamp.ctx[i] = 0;
-#ifdef DEBUG
- if (debug_level > 0)
- fprintf(stderr, "resamp_new: %u/%u\n", iblksz, oblksz);
-#endif
return p;
}
@@ -1160,7 +1069,6 @@ cmap_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
ctx++;
}
}
- DPRINTFN(4, "cmap_bcopy: scount = %u\n", scount);
abuf_rdiscard(ibuf, scount * ibuf->bpf);
abuf_wcommit(obuf, scount * obuf->bpf);
}
@@ -1170,8 +1078,6 @@ cmap_in(struct aproc *p, struct abuf *ibuf)
{
struct abuf *obuf = LIST_FIRST(&p->obuflist);
- DPRINTFN(4, "cmap_in: %s\n", p->name);
-
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
return 0;
cmap_bcopy(p, ibuf, obuf);
@@ -1185,8 +1091,6 @@ cmap_out(struct aproc *p, struct abuf *obuf)
{
struct abuf *ibuf = LIST_FIRST(&p->ibuflist);
- DPRINTFN(4, "cmap_out: %s\n", p->name);
-
if (!abuf_fill(ibuf))
return 0;
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
@@ -1198,16 +1102,12 @@ cmap_out(struct aproc *p, struct abuf *obuf)
void
cmap_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTFN(4, "cmap_eof: %s\n", p->name);
-
aproc_del(p);
}
void
cmap_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTFN(4, "cmap_hup: %s\n", p->name);
-
aproc_del(p);
}
@@ -1233,13 +1133,6 @@ cmap_new(char *name, struct aparams *ipar, struct aparams *opar)
p = aproc_new(&cmap_ops, name);
for (i = 0; i < NCHAN_MAX; i++)
p->u.cmap.ctx[i] = 0;
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "cmap_new: %s: ", p->name);
- aparams_print2(ipar, opar);
- fprintf(stderr, "\n");
- }
-#endif
return p;
}
@@ -1274,8 +1167,6 @@ enc_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
return;
scount = (icount < ocount) ? icount : ocount;
nch = ibuf->cmax - ibuf->cmin + 1;
- DPRINTFN(4, "enc_bcopy: scount = %u, nch = %u\n", scount, nch);
-
/*
* Partially copy structures into local variables, to avoid
* unnecessary indirections; this also allows the compiler to
@@ -1316,8 +1207,6 @@ enc_in(struct aproc *p, struct abuf *ibuf)
{
struct abuf *obuf = LIST_FIRST(&p->obuflist);
- DPRINTFN(4, "enc_in: %s\n", p->name);
-
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
return 0;
enc_bcopy(p, ibuf, obuf);
@@ -1331,8 +1220,6 @@ enc_out(struct aproc *p, struct abuf *obuf)
{
struct abuf *ibuf = LIST_FIRST(&p->ibuflist);
- DPRINTFN(4, "enc_out: %s\n", p->name);
-
if (!abuf_fill(ibuf))
return 0;
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
@@ -1344,16 +1231,12 @@ enc_out(struct aproc *p, struct abuf *obuf)
void
enc_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTFN(4, "enc_eof: %s\n", p->name);
-
aproc_del(p);
}
void
enc_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTFN(4, "enc_hup: %s\n", p->name);
-
aproc_del(p);
}
@@ -1392,13 +1275,6 @@ enc_new(char *name, struct aparams *par)
p->u.conv.bnext = 1;
p->u.conv.snext = 0;
}
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "enc_new: %s: ", p->name);
- aparams_print(par);
- fprintf(stderr, "\n");
- }
-#endif
return p;
}
@@ -1433,8 +1309,6 @@ dec_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
return;
scount = (icount < ocount) ? icount : ocount;
nch = obuf->cmax - obuf->cmin + 1;
- DPRINTFN(4, "dec_bcopy: scount = %u, nch = %u\n", scount, nch);
-
/*
* Partially copy structures into local variables, to avoid
* unnecessary indirections; this also allows the compiler to
@@ -1475,8 +1349,6 @@ dec_in(struct aproc *p, struct abuf *ibuf)
{
struct abuf *obuf = LIST_FIRST(&p->obuflist);
- DPRINTFN(4, "dec_in: %s\n", p->name);
-
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
return 0;
dec_bcopy(p, ibuf, obuf);
@@ -1490,8 +1362,6 @@ dec_out(struct aproc *p, struct abuf *obuf)
{
struct abuf *ibuf = LIST_FIRST(&p->ibuflist);
- DPRINTFN(4, "dec_out: %s\n", p->name);
-
if (!abuf_fill(ibuf))
return 0;
if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf))
@@ -1503,16 +1373,12 @@ dec_out(struct aproc *p, struct abuf *obuf)
void
dec_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTFN(4, "dec_eof: %s\n", p->name);
-
aproc_del(p);
}
void
dec_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTFN(4, "dec_hup: %s\n", p->name);
-
aproc_del(p);
}
@@ -1551,12 +1417,5 @@ dec_new(char *name, struct aparams *par)
p->u.conv.bnext = 1;
p->u.conv.snext = 0;
}
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "dec_new: %s: ", p->name);
- aparams_print(par);
- fprintf(stderr, "\n");
- }
-#endif
return p;
}
diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h
index e075ab5eccb..d139ffc7003 100644
--- a/usr.bin/aucat/aproc.h
+++ b/usr.bin/aucat/aproc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.h,v 1.22 2009/08/27 06:31:13 ratchov Exp $ */
+/* $OpenBSD: aproc.h,v 1.23 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -184,6 +184,7 @@ struct aproc {
struct aproc *aproc_new(struct aproc_ops *, char *);
void aproc_del(struct aproc *);
+void aproc_dbg(struct aproc *);
void aproc_setin(struct aproc *, struct abuf *);
void aproc_setout(struct aproc *, struct abuf *);
int aproc_depend(struct aproc *, struct aproc *);
diff --git a/usr.bin/aucat/aucat.1 b/usr.bin/aucat/aucat.1
index 11d0aa8fda0..0ed8dcf21f9 100644
--- a/usr.bin/aucat/aucat.1
+++ b/usr.bin/aucat/aucat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: aucat.1,v 1.57 2009/08/25 21:37:18 ratchov Exp $
+.\" $OpenBSD: aucat.1,v 1.58 2009/09/27 11:51:20 ratchov Exp $
.\"
.\" Copyright (c) 2006 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: August 25 2009 $
+.Dd $Mdocdate: September 27 2009 $
.Dt AUCAT 1
.Os
.Sh NAME
@@ -187,11 +187,6 @@ is sent
or
.Dv SIGTERM ,
it terminates recording to files.
-If sent
-.Dv SIGUSR1
-or
-.Dv SIGUSR2 ,
-it increases or decreases debug level, respectively.
.Pp
Settings for input files
.Pq Fl i ,
@@ -399,9 +394,6 @@ If the device does not support the encoding,
will exit with an error.
.Sh ENVIRONMENT
.Bl -tag -width "AUDIODEVICE" -compact
-.It Ev AUCAT_DEBUG
-The debug level:
-may be a value between 0 and 4.
.It Ev AUDIODEVICE
.Xr sndio 7
audio device to use if the
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 7078c2768a3..174de5f18b6 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.67 2009/08/26 06:33:52 jmc Exp $ */
+/* $OpenBSD: aucat.c,v 1.68 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -47,7 +47,6 @@
#define PROG_AUCAT "aucat"
#define PROG_MIDICAT "midicat"
-int debug_level = 0;
volatile int quit_flag = 0;
/*
@@ -63,39 +62,6 @@ sigint(int s)
quit_flag = 1;
}
-/*
- * Increase debug level on SIGUSR1.
- */
-void
-sigusr1(int s)
-{
- if (debug_level < 4)
- debug_level++;
-}
-
-/*
- * Decrease debug level on SIGUSR2.
- */
-void
-sigusr2(int s)
-{
- if (debug_level > 0)
- debug_level--;
-}
-
-void
-set_debug_level(char *envname)
-{
- char *dbgenv;
- const char *errstr;
-
- dbgenv = getenv(envname);
- if (dbgenv) {
- debug_level = strtonum(dbgenv, 0, 4, &errstr);
- if (errstr)
- errx(1, "%s is %s: %s", envname, errstr, dbgenv);
- }
-}
void
opt_ch(struct aparams *par)
@@ -203,10 +169,8 @@ farg_add(struct farglist *list,
if (namelen >= 4 &&
strcasecmp(optarg + namelen - 4, ".wav") == 0) {
fa->hdr = HDR_WAV;
- DPRINTF("%s: assuming wav file format\n", optarg);
} else {
fa->hdr = HDR_RAW;
- DPRINTF("%s: assuming headerless file\n", optarg);
}
} else
fa->hdr = hdr;
@@ -336,19 +300,11 @@ setsig(void)
sa.sa_flags = SA_RESTART;
sa.sa_handler = sigint;
if (sigaction(SIGINT, &sa, NULL) < 0)
- DPRINTF("sigaction(int) failed\n");
+ err(1, "sigaction(int) failed");
if (sigaction(SIGTERM, &sa, NULL) < 0)
- DPRINTF("sigaction(term) failed\n");
+ err(1, "sigaction(term) failed");
if (sigaction(SIGHUP, &sa, NULL) < 0)
- DPRINTF("sigaction(hup) failed\n");
-#ifdef DEBUG
- sa.sa_handler = sigusr1;
- if (sigaction(SIGUSR1, &sa, NULL) < 0)
- DPRINTF("sigaction(usr1) failed\n");
- sa.sa_handler = sigusr2;
- if (sigaction(SIGUSR2, &sa, NULL) < 0)
- DPRINTF("sigaction(usr2) failed1n");
-#endif
+ err(1, "sigaction(hup) failed");
}
void
@@ -359,18 +315,12 @@ unsetsig(void)
sigfillset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sa.sa_handler = SIG_DFL;
-#ifdef DEBUG
- if (sigaction(SIGUSR2, &sa, NULL) < 0)
- DPRINTF("unsetsig(usr2): sigaction failed\n");
- if (sigaction(SIGUSR1, &sa, NULL) < 0)
- DPRINTF("unsetsig(usr1): sigaction failed\n");
-#endif
if (sigaction(SIGHUP, &sa, NULL) < 0)
- DPRINTF("unsetsig(hup): sigaction failed\n");
+ err(1, "unsetsig(hup): sigaction failed\n");
if (sigaction(SIGTERM, &sa, NULL) < 0)
- DPRINTF("unsetsig(term): sigaction failed\n");
+ err(1, "unsetsig(term): sigaction failed\n");
if (sigaction(SIGINT, &sa, NULL) < 0)
- DPRINTF("unsetsig(int): sigaction failed\n");
+ err(1, "unsetsig(int): sigaction failed\n");
}
void
@@ -625,7 +575,7 @@ aucat_main(int argc, char **argv)
snprintf(path, sizeof(path), "%s/%s%u", base,
DEFAULT_SOFTAUDIO, unit);
listen_new(&listen_ops, path);
- if (debug_level == 0 && daemon(0, 0) < 0)
+ if (daemon(0, 0) < 0)
err(1, "daemon");
}
@@ -648,7 +598,6 @@ aucat_main(int argc, char **argv)
if (!l_flag)
break;
if (!suspend) {
- DPRINTF("suspending\n");
suspend = 1;
dev_stop();
dev_clear();
@@ -657,7 +606,6 @@ aucat_main(int argc, char **argv)
if ((dev_mix && dev_mix->u.mix.idle == 0) ||
(dev_sub && dev_sub->u.sub.idle == 0)) {
if (suspend) {
- DPRINTF("resuming\n");
suspend = 0;
dev_start();
}
@@ -669,7 +617,6 @@ aucat_main(int argc, char **argv)
warn("rmdir(\"%s\")", base);
}
if (suspend) {
- DPRINTF("resuming to drain\n");
suspend = 0;
dev_start();
}
@@ -772,7 +719,7 @@ midicat_main(int argc, char **argv)
snprintf(path, sizeof(path), "%s/%s%u", base,
DEFAULT_MIDITHRU, unit);
listen_new(&listen_ops, path);
- if (debug_level == 0 && daemon(0, 0) < 0)
+ if (daemon(0, 0) < 0)
err(1, "daemon");
}
while (!SLIST_EMPTY(&ifiles)) {
@@ -850,10 +797,8 @@ main(int argc, char **argv)
else
prog++;
if (strcmp(prog, PROG_AUCAT) == 0) {
- set_debug_level("AUCAT_DEBUG");
return aucat_main(argc, argv);
} else if (strcmp(prog, PROG_MIDICAT) == 0) {
- set_debug_level("MIDICAT_DEBUG");
return midicat_main(argc, argv);
} else {
fprintf(stderr, "%s: can't determine program to run\n", prog);
diff --git a/usr.bin/aucat/conf.h b/usr.bin/aucat/conf.h
index dc16d9dbad2..5a138919166 100644
--- a/usr.bin/aucat/conf.h
+++ b/usr.bin/aucat/conf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.h,v 1.9 2009/08/17 16:17:46 ratchov Exp $ */
+/* $OpenBSD: conf.h,v 1.10 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -17,30 +17,6 @@
#ifndef CONF_H
#define CONF_H
-/*
- * Debug trace levels:
- *
- * 0 - traces are off
- * 1 - init, free, stuff that's done only once
- * 2 - rare real-time events: eof / hup, etc...
- * 3 - poll(), block / unblock state changes
- * 4 - read()/write()
- */
-#ifdef DEBUG
-
-/* defined in main.c */
-extern int debug_level;
-
-#define DPRINTF(...) DPRINTFN(1, __VA_ARGS__)
-#define DPRINTFN(n, ...) \
- do { \
- if (debug_level >= (n)) \
- fprintf(stderr, __VA_ARGS__); \
- } while(0)
-#else
-#define DPRINTF(...) do {} while(0)
-#define DPRINTFN(n, ...) do {} while(0)
-#endif
/*
* Number of blocks in the device play/record buffers. Because Sun API
@@ -65,6 +41,6 @@ extern int debug_level;
/*
* MIDI buffer size
*/
-#define MIDI_BUFSZ 3125 /* 1 second */
+#define MIDI_BUFSZ 3125 /* 1 second at 31.25kbit/s */
#endif /* !defined(CONF_H) */
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c
index 98b46668cf0..03ebec61b2f 100644
--- a/usr.bin/aucat/dev.c
+++ b/usr.bin/aucat/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.29 2009/08/21 16:48:03 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.30 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -131,8 +131,6 @@ dev_loopdone(void)
{
struct file *f;
- DPRINTF("dev_loopdone:\n");
-
dev_sub->refs--;
dev_sub = NULL;
dev_mix->refs--;
@@ -183,23 +181,9 @@ dev_init(char *devpath,
if (f == NULL)
return 0;
if (dipar) {
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "dev_init: hw recording ");
- aparams_print(dipar);
- fprintf(stderr, "\n");
- }
-#endif
dev_rate = dipar->rate;
}
if (dopar) {
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "dev_init: hw playing ");
- aparams_print(dopar);
- fprintf(stderr, "\n");
- }
-#endif
dev_rate = dopar->rate;
}
ibufsz = obufsz = dev_bufsz;
@@ -234,7 +218,7 @@ dev_init(char *devpath,
* Append a converter, if needed.
*/
if (!aparams_eqenc(dipar, &ipar)) {
- conv = dec_new("subin", dipar);
+ conv = dec_new("rec", dipar);
aproc_setin(conv, buf);
buf = abuf_new(nfr, &ipar);
aproc_setout(conv, buf);
@@ -245,7 +229,7 @@ dev_init(char *devpath,
/*
* Append a "sub" to which clients will connect.
*/
- dev_sub = sub_new("sub", nfr);
+ dev_sub = sub_new("rec", nfr);
dev_sub->refs++;
aproc_setin(dev_sub, buf);
} else {
@@ -271,7 +255,7 @@ dev_init(char *devpath,
* Append a converter, if needed.
*/
if (!aparams_eqenc(&opar, dopar)) {
- conv = enc_new("mixout", dopar);
+ conv = enc_new("play", dopar);
aproc_setout(conv, buf);
buf = abuf_new(nfr, &opar);
aproc_setin(conv, buf);
@@ -282,7 +266,7 @@ dev_init(char *devpath,
/*
* Append a "mix" to which clients will connect.
*/
- dev_mix = mix_new("mix", nfr);
+ dev_mix = mix_new("play", nfr);
dev_mix->refs++;
aproc_setout(dev_mix, buf);
} else {
@@ -290,7 +274,6 @@ dev_init(char *devpath,
dev_mix = NULL;
}
dev_bufsz = (dopar) ? obufsz : ibufsz;
- DPRINTF("dev_init: using %u fpb\n", dev_bufsz);
dev_midi = ctl_new("ctl");
dev_midi->refs++;
dev_start();
@@ -306,7 +289,6 @@ dev_done(void)
{
struct file *f;
- DPRINTF("dev_done: dev_mix = %p, dev_sub = %p\n", dev_mix, dev_sub);
dev_midi->refs--;
aproc_del(dev_midi);
dev_midi = NULL;
@@ -426,7 +408,6 @@ dev_getep(struct abuf **sibuf, struct abuf **sobuf)
ibuf = *sibuf;
for (;;) {
if (!ibuf || !ibuf->rproc) {
- DPRINTF("dev_getep: reader desappeared\n");
return 0;
}
if (ibuf->rproc == dev_mix)
@@ -439,7 +420,6 @@ dev_getep(struct abuf **sibuf, struct abuf **sobuf)
obuf = *sobuf;
for (;;) {
if (!obuf || !obuf->wproc) {
- DPRINTF("dev_getep: writer desappeared\n");
return 0;
}
if (obuf->wproc == dev_sub)
@@ -481,9 +461,6 @@ dev_sync(struct abuf *ibuf, struct abuf *obuf)
rbuf->bpf * (pbuf->abspos + pbuf->used) -
pbuf->bpf * rbuf->abspos;
delta /= pbuf->bpf * rbuf->bpf;
- DPRINTF("dev_sync: delta = %d, ppos = %u, pused = %u, rpos = %u\n",
- delta, pbuf->abspos, pbuf->used, rbuf->abspos);
-
if (delta > 0) {
/*
* If the play chain is ahead (most cases) drop some of
@@ -498,8 +475,7 @@ dev_sync(struct abuf *ibuf, struct abuf *obuf)
*/
ibuf->silence += -delta * ibuf->bpf;
abuf_opos(ibuf, delta);
- } else
- DPRINTF("dev_sync: nothing to do\n");
+ }
}
/*
@@ -609,13 +585,10 @@ dev_attach(char *name,
void
dev_setvol(struct abuf *ibuf, int vol)
{
- DPRINTF("dev_setvol: %p\n", ibuf);
if (!dev_getep(&ibuf, NULL)) {
- DPRINTF("dev_setvol: not connected yet\n");
return;
}
ibuf->mixvol = vol;
- DPRINTF("dev_setvol: %p -> %d\n", ibuf, vol);
}
/*
@@ -628,10 +601,6 @@ dev_clear(void)
struct abuf *buf;
if (dev_mix) {
- if (!LIST_EMPTY(&dev_mix->ibuflist)) {
- fprintf(stderr, "dev_clear: mixer not idle\n");
- abort();
- }
buf = LIST_FIRST(&dev_mix->obuflist);
while (buf) {
abuf_clear(buf);
@@ -640,10 +609,6 @@ dev_clear(void)
mix_clear(dev_mix);
}
if (dev_sub) {
- if (!LIST_EMPTY(&dev_sub->obuflist)) {
- fprintf(stderr, "dev_suspend: demux not idle\n");
- abort();
- }
buf = LIST_FIRST(&dev_sub->ibuflist);
while (buf) {
abuf_clear(buf);
diff --git a/usr.bin/aucat/file.c b/usr.bin/aucat/file.c
index 1663701a778..100e597a630 100644
--- a/usr.bin/aucat/file.c
+++ b/usr.bin/aucat/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.13 2009/07/25 10:52:19 ratchov Exp $ */
+/* $OpenBSD: file.c,v 1.14 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -90,16 +90,6 @@ timo_add(struct timo *o, unsigned delta)
unsigned val;
int diff;
-#ifdef DEBUG
- if (o->set) {
- fprintf(stderr, "timo_set: already set\n");
- abort();
- }
- if (delta == 0) {
- fprintf(stderr, "timo_set: zero timeout is evil\n");
- abort();
- }
-#endif
val = timo_abstime + delta;
for (i = &timo_queue; *i != NULL; i = &(*i)->next) {
diff = (*i)->val - val;
@@ -128,7 +118,6 @@ timo_del(struct timo *o)
return;
}
}
- DPRINTF("timo_del: not found\n");
}
/*
@@ -182,31 +171,9 @@ timo_init(void)
void
timo_done(void)
{
- if (timo_queue != NULL) {
- fprintf(stderr, "timo_done: timo_queue not empty!\n");
- abort();
- }
timo_queue = (struct timo *)0xdeadbeef;
}
-void
-file_dprint(int n, struct file *f)
-{
-#ifdef DEBUG
- if (debug_level < n)
- return;
- fprintf(stderr, "%s:%s <", f->ops->name, f->name);
- if (f->state & FILE_ROK)
- fprintf(stderr, "ROK");
- if (f->state & FILE_WOK)
- fprintf(stderr, "WOK");
- if (f->state & FILE_EOF)
- fprintf(stderr, "EOF");
- if (f->state & FILE_HUP)
- fprintf(stderr, "HUP");
- fprintf(stderr, ">");
-#endif
-}
struct file *
file_new(struct fileops *ops, char *name, unsigned nfds)
@@ -216,7 +183,6 @@ file_new(struct fileops *ops, char *name, unsigned nfds)
LIST_FOREACH(f, &file_list, entry)
nfds += f->ops->nfds(f);
if (nfds > MAXFDS) {
- DPRINTF("file_new: %s: too many polled files\n", name);
return NULL;
}
f = malloc(ops->size);
@@ -228,21 +194,15 @@ file_new(struct fileops *ops, char *name, unsigned nfds)
f->rproc = NULL;
f->wproc = NULL;
LIST_INSERT_HEAD(&file_list, f, entry);
- DPRINTF("file_new: %s:%s\n", ops->name, f->name);
return f;
}
void
file_del(struct file *f)
{
- DPRINTF("file_del: ");
- file_dprint(1, f);
if (f->state & (FILE_RINUSE | FILE_WINUSE)) {
- DPRINTF(": delayed\n");
f->state |= FILE_ZOMB;
- return;
} else {
- DPRINTF(": immediate\n");
LIST_REMOVE(f, entry);
f->ops->close(f);
free(f);
@@ -265,7 +225,6 @@ file_poll(void)
* Fill the pfds[] array with files that are blocked on reading
* and/or writing, skipping those that are just waiting.
*/
- DPRINTFN(4, "file_poll:");
nfds = 0;
LIST_FOREACH(f, &file_list, entry) {
events = 0;
@@ -273,7 +232,6 @@ file_poll(void)
events |= POLLIN;
if (f->wproc && !(f->state & FILE_WOK))
events |= POLLOUT;
- DPRINTFN(4, " %s(%x)", f->name, events);
n = f->ops->pollfd(f, pfds + nfds, events);
if (n == 0) {
f->pfd = NULL;
@@ -282,15 +240,7 @@ file_poll(void)
f->pfd = pfds + nfds;
nfds += n;
}
- DPRINTFN(4, "\n");
- if (debug_level >= 4) {
- DPRINTF("file_poll: pfds[] =");
- for (n = 0; n < nfds; n++)
- DPRINTF(" %x", pfds[n].events);
- DPRINTF("\n");
- }
if (LIST_EMPTY(&file_list)) {
- DPRINTF("file_poll: nothing to do...\n");
return 0;
}
if (nfds > 0) {
@@ -323,11 +273,12 @@ file_poll(void)
if (!(f->state & FILE_ZOMB) && (revents & POLLIN)) {
revents &= ~POLLIN;
f->state |= FILE_ROK;
- DPRINTFN(3, "file_poll: %s rok\n", f->name);
f->state |= FILE_RINUSE;
for (;;) {
p = f->rproc;
- if (!p || !p->ops->in(p, NULL))
+ if (!p)
+ break;
+ if (!p->ops->in(p, NULL))
break;
}
f->state &= ~FILE_RINUSE;
@@ -335,21 +286,20 @@ file_poll(void)
if (!(f->state & FILE_ZOMB) && (revents & POLLOUT)) {
revents &= ~POLLOUT;
f->state |= FILE_WOK;
- DPRINTFN(3, "file_poll: %s wok\n", f->name);
f->state |= FILE_WINUSE;
for (;;) {
p = f->wproc;
- if (!p || !p->ops->out(p, NULL))
+ if (!p)
+ break;
+ if (!p->ops->out(p, NULL))
break;
}
f->state &= ~FILE_WINUSE;
}
if (!(f->state & FILE_ZOMB) && (revents & POLLHUP)) {
- DPRINTFN(2, "file_poll: %s: disconnected\n", f->name);
f->state |= (FILE_EOF | FILE_HUP);
}
if (!(f->state & FILE_ZOMB) && (f->state & FILE_EOF)) {
- DPRINTFN(2, "file_poll: %s: eof\n", f->name);
p = f->rproc;
if (p) {
f->state |= FILE_RINUSE;
@@ -359,7 +309,6 @@ file_poll(void)
f->state &= ~FILE_EOF;
}
if (!(f->state & FILE_ZOMB) && (f->state & FILE_HUP)) {
- DPRINTFN(2, "file_poll: %s hup\n", f->name);
p = f->wproc;
if (p) {
f->state |= FILE_WINUSE;
@@ -374,7 +323,6 @@ file_poll(void)
f = fnext;
}
if (LIST_EMPTY(&file_list)) {
- DPRINTFN(2, "file_poll: terminated\n");
return 0;
}
return 1;
@@ -397,18 +345,7 @@ filelist_init(void)
void
filelist_done(void)
{
- struct file *f;
-
timo_done();
- if (!LIST_EMPTY(&file_list)) {
- fprintf(stderr, "filelist_done: list not empty:\n");
- LIST_FOREACH(f, &file_list, entry) {
- fprintf(stderr, "\t");
- file_dprint(0, f);
- fprintf(stderr, "\n");
- }
- abort();
- }
}
/*
@@ -429,15 +366,19 @@ filelist_unlisten(void)
}
unsigned
-file_read(struct file *file, unsigned char *data, unsigned count)
+file_read(struct file *f, unsigned char *data, unsigned count)
{
- return file->ops->read(file, data, count);
+ unsigned n;
+ n = f->ops->read(f, data, count);
+ return n;
}
unsigned
-file_write(struct file *file, unsigned char *data, unsigned count)
+file_write(struct file *f, unsigned char *data, unsigned count)
{
- return file->ops->write(file, data, count);
+ unsigned n;
+ n = f->ops->write(f, data, count);
+ return n;
}
void
@@ -446,7 +387,6 @@ file_eof(struct file *f)
struct aproc *p;
if (!(f->state & (FILE_RINUSE | FILE_WINUSE))) {
- DPRINTFN(2, "file_eof: %s: immediate\n", f->name);
p = f->rproc;
if (p) {
f->state |= FILE_RINUSE;
@@ -456,7 +396,6 @@ file_eof(struct file *f)
if (f->state & FILE_ZOMB)
file_del(f);
} else {
- DPRINTFN(2, "file_eof: %s: delayed\n", f->name);
f->state &= ~FILE_ROK;
f->state |= FILE_EOF;
}
@@ -468,7 +407,6 @@ file_hup(struct file *f)
struct aproc *p;
if (!(f->state & (FILE_RINUSE | FILE_WINUSE))) {
- DPRINTFN(2, "file_hup: %s immediate\n", f->name);
p = f->wproc;
if (p) {
f->state |= FILE_WINUSE;
@@ -478,7 +416,6 @@ file_hup(struct file *f)
if (f->state & FILE_ZOMB)
file_del(f);
} else {
- DPRINTFN(2, "file_hup: %s: delayed\n", f->name);
f->state &= ~FILE_WOK;
f->state |= FILE_HUP;
}
@@ -490,7 +427,6 @@ file_close(struct file *f)
struct aproc *p;
if (!(f->state & (FILE_RINUSE | FILE_WINUSE))) {
- DPRINTFN(2, "file_close: %s: immediate\n", f->name);
p = f->rproc;
if (p) {
f->state |= FILE_RINUSE;
@@ -506,7 +442,6 @@ file_close(struct file *f)
if (f->state & FILE_ZOMB)
file_del(f);
} else {
- DPRINTFN(2, "file_close: %s: delayed\n", f->name);
f->state &= ~(FILE_ROK | FILE_WOK);
f->state |= (FILE_EOF | FILE_HUP);
}
diff --git a/usr.bin/aucat/file.h b/usr.bin/aucat/file.h
index 4458f6977fb..4c7a1c1607b 100644
--- a/usr.bin/aucat/file.h
+++ b/usr.bin/aucat/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.8 2009/07/25 10:52:19 ratchov Exp $ */
+/* $OpenBSD: file.h,v 1.9 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -75,6 +75,7 @@ void filelist_unlisten(void);
struct file *file_new(struct fileops *, char *, unsigned);
void file_del(struct file *);
+void file_dbg(struct file *);
void file_attach(struct file *, struct aproc *, struct aproc *);
unsigned file_read(struct file *, unsigned char *, unsigned);
diff --git a/usr.bin/aucat/headers.c b/usr.bin/aucat/headers.c
index a3b52e139b3..53e550b182c 100644
--- a/usr.bin/aucat/headers.c
+++ b/usr.bin/aucat/headers.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: headers.c,v 1.7 2009/07/25 10:52:19 ratchov Exp $ */
+/* $OpenBSD: headers.c,v 1.8 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -125,13 +125,6 @@ wav_readfmt(int fd, unsigned csize, struct aparams *par, short **map)
par->msb = 1;
par->cmax = cmax;
par->rate = rate;
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "wav_readfmt: using ");
- aparams_print(par);
- fprintf(stderr, "\n");
- }
-#endif
return 1;
}
@@ -148,7 +141,7 @@ wav_readhdr(int fd, struct aparams *par, off_t *datasz, short **map)
return 0;
}
if (read(fd, &riff, sizeof(riff)) != sizeof(riff)) {
- warn("riff_read: header");
+ warn("wav_readhdr: header");
return 0;
}
if (memcmp(&riff.magic, &wav_id_riff, 4) != 0 ||
@@ -159,7 +152,7 @@ wav_readhdr(int fd, struct aparams *par, off_t *datasz, short **map)
rsize = letoh32(riff.size);
while (pos + sizeof(struct wavchunk) <= rsize) {
if (read(fd, &chunk, sizeof(chunk)) != sizeof(chunk)) {
- warn("riff_read: chunk");
+ warn("wav_readhdr: chunk");
return 0;
}
csize = letoh32(chunk.size);
@@ -171,7 +164,6 @@ wav_readhdr(int fd, struct aparams *par, off_t *datasz, short **map)
*datasz = csize;
break;
} else {
- DPRINTF("unknown chunk: <%.4s>\n", chunk.id);
}
/*
diff --git a/usr.bin/aucat/listen.c b/usr.bin/aucat/listen.c
index 43b7cabbc8c..90be6b9628a 100644
--- a/usr.bin/aucat/listen.c
+++ b/usr.bin/aucat/listen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: listen.c,v 1.10 2009/07/25 10:52:19 ratchov Exp $ */
+/* $OpenBSD: listen.c,v 1.11 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -113,7 +113,6 @@ listen_revents(struct file *file, struct pollfd *pfd)
int sock;
if (pfd->revents & POLLIN) {
- DPRINTF("listen_revents: %s: accepting connection\n", f->path);
caddrlen = sizeof(caddrlen);
sock = accept(f->fd, &caddr, &caddrlen);
if (sock < 0) {
diff --git a/usr.bin/aucat/midi.c b/usr.bin/aucat/midi.c
index 7652b9c2d3d..54ccf219d80 100644
--- a/usr.bin/aucat/midi.c
+++ b/usr.bin/aucat/midi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midi.c,v 1.8 2009/08/29 14:46:44 ratchov Exp $ */
+/* $OpenBSD: midi.c,v 1.9 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -80,11 +80,9 @@ thru_flush(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
itodo = ibuf->mused;
idata = ibuf->mdata;
- DPRINTFN(4, "thru_flush: mused = %u\n", itodo);
while (itodo > 0) {
if (!ABUF_WOK(obuf)) {
abuf_rdiscard(obuf, obuf->used);
- DPRINTFN(2, "thru_flush: discarded %u\n", obuf->used);
if (p->u.thru.owner == ibuf)
p->u.thru.owner = NULL;
return;
@@ -110,9 +108,7 @@ thru_rt(struct aproc *p, struct abuf *ibuf, struct abuf *obuf, unsigned c)
unsigned ocount;
unsigned char *odata;
- DPRINTFN(4, "thru_rt:\n");
if (!ABUF_WOK(obuf)) {
- DPRINTFN(2, "thru_rt: discarded %u\n", obuf->used);
abuf_rdiscard(obuf, obuf->used);
if (p->u.thru.owner == ibuf)
p->u.thru.owner = NULL;
@@ -200,12 +196,9 @@ thru_in(struct aproc *p, struct abuf *ibuf)
struct abuf *i, *inext;
unsigned todo;
- DPRINTFN(3, "thru_in: %s\n", p->name);
-
if (!ABUF_ROK(ibuf))
return 0;
if (ibuf->mtickets == 0) {
- DPRINTFN(2, "thru_in: out of tickets\n");
return 0;
}
todo = ibuf->used;
@@ -232,13 +225,11 @@ thru_out(struct aproc *p, struct abuf *obuf)
void
thru_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTF("thru_eof: %s: eof\n", p->name);
}
void
thru_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTF("thru_hup: %s: detached\n", p->name);
}
void
@@ -324,13 +315,11 @@ ctl_sendmsg(struct aproc *p, struct abuf *ibuf, unsigned char *msg, unsigned len
idata = msg;
while (itodo > 0) {
if (!ABUF_WOK(i)) {
- DPRINTFN(2, "ctl_sendmsg: lost %u\n", i->used);
abuf_rdiscard(i, i->used);
}
odata = abuf_wgetblk(i, &ocount, 0);
if (ocount > itodo)
ocount = itodo;
- DPRINTFN(2, "ctl_sendmsg: xfer %u\n", ocount);
memcpy(odata, idata, ocount);
abuf_wcommit(i, ocount);
itodo -= ocount;
@@ -384,9 +373,6 @@ ctl_slotnew(struct aproc *p, char *who, void (*cb)(void *, unsigned), void *arg)
if ((umap & (1 << i)) == 0)
break;
}
-
- DPRINTF("ctl_newslot: using %s%u as control name\n", name, unit);
-
/*
* find a free controller slot with the same name/unit
*/
@@ -394,7 +380,6 @@ ctl_slotnew(struct aproc *p, char *who, void (*cb)(void *, unsigned), void *arg)
if (slot->cb == NULL &&
strcmp(slot->name, name) == 0 &&
slot->unit == unit) {
- DPRINTFN(1, "ctl_newslot: reusing %u\n", i);
slot->cb = cb;
slot->arg = arg;
slot->cb(slot->arg, slot->vol);
@@ -424,7 +409,6 @@ ctl_slotnew(struct aproc *p, char *who, void (*cb)(void *, unsigned), void *arg)
slot->serial = p->u.ctl.serial++;
slot->unit = unit;
slot->vol = MIDI_MAXCTL;
- DPRINTFN(1, "ctl_newslot: %u overwritten)\n", bestidx);
slot->cb = cb;
slot->arg = arg;
slot->cb(slot->arg, slot->vol);
@@ -451,7 +435,6 @@ ctl_slotvol(struct aproc *p, int slot, unsigned vol)
{
unsigned char msg[3];
- DPRINTFN(1, "ctl_slotvol: [%u] -> %u\n", slot, vol);
p->u.ctl.slot[slot].vol = vol;
msg[0] = MIDI_CTL | slot;
msg[1] = MIDI_CTLVOL;
@@ -465,18 +448,8 @@ ctl_slotvol(struct aproc *p, int slot, unsigned vol)
void
ctl_ev(struct aproc *p, struct abuf *ibuf)
{
- unsigned i;
unsigned chan;
struct ctl_slot *slot;
-
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "ctl_ev:");
- for (i = 0; i < ibuf->mindex; i++)
- fprintf(stderr, " %02x", ibuf->mdata[i]);
- fprintf(stderr, "\n");
- }
-#endif
if ((ibuf->mdata[0] & MIDI_CMDMASK) == MIDI_CTL &&
ibuf->mdata[1] == MIDI_CTLVOL) {
chan = ibuf->mdata[0] & MIDI_CHANMASK;
@@ -545,13 +518,11 @@ ctl_out(struct aproc *p, struct abuf *obuf)
void
ctl_eof(struct aproc *p, struct abuf *ibuf)
{
- DPRINTF("ctl_eof: %s: eof\n", p->name);
}
void
ctl_hup(struct aproc *p, struct abuf *obuf)
{
- DPRINTF("ctl_hup: %s: detached\n", p->name);
}
void
@@ -566,16 +537,6 @@ ctl_newin(struct aproc *p, struct abuf *ibuf)
void
ctl_done(struct aproc *p)
{
- unsigned i;
- struct ctl_slot *s;
-
- for (i = 0, s = p->u.ctl.slot; i < CTL_NSLOT; i++, s++) {
- /*
- * XXX: shouldn't we abord() here ?
- */
- if (s->cb != NULL)
- DPRINTF("ctl_done: %s%u in use\n", s->name, s->unit);
- }
}
struct aproc_ops ctl_ops = {
diff --git a/usr.bin/aucat/midicat.1 b/usr.bin/aucat/midicat.1
index 01ba004dd43..a86889de616 100644
--- a/usr.bin/aucat/midicat.1
+++ b/usr.bin/aucat/midicat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: midicat.1,v 1.2 2009/08/17 15:07:49 ratchov Exp $
+.\" $OpenBSD: midicat.1,v 1.3 2009/09/27 11:51:20 ratchov Exp $
.\"
.\" Copyright (c) 2006 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: August 17 2009 $
+.Dd $Mdocdate: September 27 2009 $
.Dt MIDICAT 1
.Os
.Sh NAME
@@ -79,11 +79,6 @@ is sent
or
.Dv SIGTERM ,
then processing terminates.
-If sent
-.Dv SIGUSR1
-or
-.Dv SIGUSR2 ,
-it increases or decreases debug level, respectively.
.Sh SERVER MODE
.Nm
can be used in server mode
@@ -119,12 +114,6 @@ For example:
$ midicat -l
$ sudo renice -n -20 -p `pgrep -x midicat`
.Ed
-.Sh ENVIRONMENT
-.Bl -tag -width "MIDICAT_DEBUGXXX" -compact
-.It Ev MIDICAT_DEBUG
-The debug level:
-may be a value between 0 and 4.
-.El
.Sh SEE ALSO
.Xr aucat 1 ,
.Xr midi 4 ,
diff --git a/usr.bin/aucat/miofile.c b/usr.bin/aucat/miofile.c
index a5effc82d93..7e797b30bde 100644
--- a/usr.bin/aucat/miofile.c
+++ b/usr.bin/aucat/miofile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: miofile.c,v 1.1 2009/07/25 08:44:27 ratchov Exp $ */
+/* $OpenBSD: miofile.c,v 1.2 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -72,7 +72,7 @@ miofile_new(struct fileops *ops, char *path, int input, int output)
hdl = mio_open(path, mode, 1);
if (hdl == NULL)
return NULL;
- f = (struct miofile *)file_new(ops, "miohdl", mio_nfds(hdl));
+ f = (struct miofile *)file_new(ops, "hdl", mio_nfds(hdl));
if (f == NULL)
goto bad_close;
f->hdl = hdl;
@@ -92,11 +92,8 @@ miofile_read(struct file *file, unsigned char *data, unsigned count)
if (n == 0) {
f->file.state &= ~FILE_ROK;
if (mio_eof(f->hdl)) {
- fprintf(stderr, "miofile_read: eof\n");
file_eof(&f->file);
} else {
- DPRINTFN(3, "miofile_read: %s: blocking...\n",
- f->file.name);
}
return 0;
}
@@ -114,11 +111,8 @@ miofile_write(struct file *file, unsigned char *data, unsigned count)
if (n == 0) {
f->file.state &= ~FILE_WOK;
if (mio_eof(f->hdl)) {
- fprintf(stderr, "miofile_write: %s: hup\n", f->file.name);
file_hup(&f->file);
} else {
- DPRINTFN(3, "miofile_write: %s: blocking...\n",
- f->file.name);
}
return 0;
}
diff --git a/usr.bin/aucat/opt.c b/usr.bin/aucat/opt.c
index 1d507c14011..8eb267a6a2e 100644
--- a/usr.bin/aucat/opt.c
+++ b/usr.bin/aucat/opt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opt.c,v 1.1 2009/07/25 08:44:27 ratchov Exp $ */
+/* $OpenBSD: opt.c,v 1.2 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -53,15 +53,6 @@ opt_new(char *name, struct aparams *wpar, struct aparams *rpar, int maxweight)
o->wpar = *wpar;
o->rpar = *rpar;
o->maxweight = maxweight;
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "opt_new: %s: wpar=", o->name);
- aparams_print(&o->wpar);
- fprintf(stderr, ", rpar=");
- aparams_print(&o->rpar);
- fprintf(stderr, ", vol=%u\n", o->maxweight);
- }
-#endif
SLIST_INSERT_HEAD(&opt_list, o, entry);
}
@@ -72,11 +63,9 @@ opt_byname(char *name)
SLIST_FOREACH(o, &opt_list, entry) {
if (strcmp(name, o->name) == 0) {
- DPRINTF("opt_byname: %s found\n", o->name);
return o;
}
}
- DPRINTF("opt_byname: %s not found\n", name);
return NULL;
}
diff --git a/usr.bin/aucat/pipe.c b/usr.bin/aucat/pipe.c
index 418be80f074..d95afdb4e77 100644
--- a/usr.bin/aucat/pipe.c
+++ b/usr.bin/aucat/pipe.c
@@ -58,21 +58,10 @@ pipe_read(struct file *file, unsigned char *data, unsigned count)
{
struct pipe *f = (struct pipe *)file;
int n;
-#ifdef DEBUG
- struct timeval tv0, tv1, dtv;
- unsigned us;
-
- if (!(f->file.state & FILE_ROK)) {
- DPRINTF("pipe_read: %s: bad state\n", f->file.name);
- abort();
- }
- gettimeofday(&tv0, NULL);
-#endif
+
while ((n = read(f->fd, data, count)) < 0) {
f->file.state &= ~FILE_ROK;
if (errno == EAGAIN) {
- DPRINTFN(3, "pipe_read: %s: blocking...\n",
- f->file.name);
} else {
warn("%s", f->file.name);
file_eof(&f->file);
@@ -80,19 +69,10 @@ pipe_read(struct file *file, unsigned char *data, unsigned count)
return 0;
}
if (n == 0) {
- DPRINTFN(2, "pipe_read: %s: eof\n", f->file.name);
- f->file.state &= ~FILE_ROK;
+ f->file.state &= ~FILE_ROK; /* XXX: already cleared in file_eof */
file_eof(&f->file);
return 0;
}
-#ifdef DEBUG
- gettimeofday(&tv1, NULL);
- timersub(&tv1, &tv0, &dtv);
- us = dtv.tv_sec * 1000000 + dtv.tv_usec;
- DPRINTFN(us < 5000 ? 4 : 2,
- "pipe_read: %s: got %d bytes in %uus\n",
- f->file.name, n, us);
-#endif
return n;
}
@@ -102,21 +82,10 @@ pipe_write(struct file *file, unsigned char *data, unsigned count)
{
struct pipe *f = (struct pipe *)file;
int n;
-#ifdef DEBUG
- struct timeval tv0, tv1, dtv;
- unsigned us;
- if (!(f->file.state & FILE_WOK)) {
- DPRINTF("pipe_write: %s: bad state\n", f->file.name);
- abort();
- }
- gettimeofday(&tv0, NULL);
-#endif
while ((n = write(f->fd, data, count)) < 0) {
f->file.state &= ~FILE_WOK;
if (errno == EAGAIN) {
- DPRINTFN(3, "pipe_write: %s: blocking...\n",
- f->file.name);
} else {
if (errno != EPIPE)
warn("%s", f->file.name);
@@ -124,14 +93,6 @@ pipe_write(struct file *file, unsigned char *data, unsigned count)
}
return 0;
}
-#ifdef DEBUG
- gettimeofday(&tv1, NULL);
- timersub(&tv1, &tv0, &dtv);
- us = dtv.tv_sec * 1000000 + dtv.tv_usec;
- DPRINTFN(us < 5000 ? 4 : 2,
- "pipe_write: %s: wrote %d bytes in %uus\n",
- f->file.name, n, us);
-#endif
return n;
}
diff --git a/usr.bin/aucat/safile.c b/usr.bin/aucat/safile.c
index a7a62f4b112..eae7808228b 100644
--- a/usr.bin/aucat/safile.c
+++ b/usr.bin/aucat/safile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safile.c,v 1.17 2009/09/19 16:30:10 ratchov Exp $ */
+/* $OpenBSD: safile.c,v 1.18 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -35,9 +35,6 @@ struct safile {
struct file file;
struct sio_hdl *hdl;
int started;
-#ifdef DEBUG
- struct timeval itv, otv;
-#endif
};
void safile_close(struct file *);
@@ -50,7 +47,7 @@ int safile_pollfd(struct file *, struct pollfd *, int);
int safile_revents(struct file *, struct pollfd *);
struct fileops safile_ops = {
- "sndio",
+ "sio",
sizeof(struct safile),
safile_close,
safile_read,
@@ -146,7 +143,6 @@ safile_new(struct fileops *ops, char *path,
}
*bufsz = par.bufsz;
*round = par.round;
- DPRINTF("safile_new: using %u(%u) fpb\n", *bufsz, *round);
f = (struct safile *)file_new(ops, "hdl", sio_nfds(hdl));
if (f == NULL)
goto bad_close;
@@ -165,12 +161,10 @@ safile_start(struct file *file)
struct safile *f = (struct safile *)file;
if (!sio_start(f->hdl)) {
- DPRINTF("safile_start: sio_start() failed\n");
file_close(file);
return;
}
f->started = 1;
- DPRINTF("safile_start: play/rec started\n");
}
void
@@ -180,11 +174,9 @@ safile_stop(struct file *file)
f->started = 0;
if (!sio_eof(f->hdl) && !sio_stop(f->hdl)) {
- DPRINTF("safile_stop: sio_stop() filed\n");
file_close(file);
return;
}
- DPRINTF("safile_stop: play/rec stopped\n");
}
unsigned
@@ -192,36 +184,16 @@ safile_read(struct file *file, unsigned char *data, unsigned count)
{
struct safile *f = (struct safile *)file;
unsigned n;
-#ifdef DEBUG
- struct timeval tv0, tv1, dtv;
- unsigned us;
- if (!(f->file.state & FILE_ROK)) {
- DPRINTF("safile_read: %s: bad state\n", f->file.name);
- abort();
- }
- gettimeofday(&tv0, NULL);
-#endif
n = sio_read(f->hdl, data, count);
if (n == 0) {
f->file.state &= ~FILE_ROK;
if (sio_eof(f->hdl)) {
- fprintf(stderr, "safile_read: eof\n");
file_eof(&f->file);
} else {
- DPRINTFN(3, "safile_read: %s: blocking...\n",
- f->file.name);
}
return 0;
}
-#ifdef DEBUG
- gettimeofday(&tv1, NULL);
- timersub(&tv1, &tv0, &dtv);
- us = dtv.tv_sec * 1000000 + dtv.tv_usec;
- DPRINTFN(us < 5000 ? 4 : 2,
- "safile_read: %s: got %d bytes in %uus\n",
- f->file.name, n, us);
-#endif
return n;
}
@@ -231,36 +203,16 @@ safile_write(struct file *file, unsigned char *data, unsigned count)
{
struct safile *f = (struct safile *)file;
unsigned n;
-#ifdef DEBUG
- struct timeval tv0, tv1, dtv;
- unsigned us;
- if (!(f->file.state & FILE_WOK)) {
- DPRINTF("safile_write: %s: bad state\n", f->file.name);
- abort();
- }
- gettimeofday(&tv0, NULL);
-#endif
n = sio_write(f->hdl, data, count);
if (n == 0) {
f->file.state &= ~FILE_WOK;
if (sio_eof(f->hdl)) {
- fprintf(stderr, "safile_write: %s: hup\n", f->file.name);
file_hup(&f->file);
} else {
- DPRINTFN(3, "safile_write: %s: blocking...\n",
- f->file.name);
}
return 0;
}
-#ifdef DEBUG
- gettimeofday(&tv1, NULL);
- timersub(&tv1, &tv0, &dtv);
- us = dtv.tv_sec * 1000000 + dtv.tv_usec;
- DPRINTFN(us < 5000 ? 4 : 2,
- "safile_write: %s: wrote %d bytes in %uus\n",
- f->file.name, n, us);
-#endif
return n;
}
diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c
index d79ec01f04d..1f4a6fcf6b9 100644
--- a/usr.bin/aucat/sock.c
+++ b/usr.bin/aucat/sock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.c,v 1.28 2009/08/28 06:37:06 ratchov Exp $ */
+/* $OpenBSD: sock.c,v 1.29 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -57,7 +57,6 @@ rsock_done(struct aproc *p)
{
struct sock *f = (struct sock *)p->u.io.file;
- DPRINTFN(1, "rsock_done: %p\n", f);
if (f == NULL)
return;
sock_reset(f);
@@ -77,8 +76,6 @@ rsock_in(struct aproc *p, struct abuf *ibuf_dummy)
struct sock *f = (struct sock *)p->u.io.file;
struct abuf *obuf;
- DPRINTFN(4, "rsock_in: %p\n", f);
-
if (!sock_read(f))
return 0;
obuf = LIST_FIRST(&p->obuflist);
@@ -97,8 +94,6 @@ rsock_out(struct aproc *p, struct abuf *obuf)
if (f->pipe.file.state & FILE_RINUSE)
return 0;
- DPRINTFN(4, "rsock_out: %p\n", f);
-
/*
* When calling sock_read(), we may receive a ``STOP'' command,
* and detach ``obuf''. In this case, there's no more caller and
@@ -116,14 +111,12 @@ rsock_out(struct aproc *p, struct abuf *obuf)
void
rsock_eof(struct aproc *p, struct abuf *ibuf_dummy)
{
- DPRINTFN(3, "rsock_eof: %p\n", p->u.io.file);
aproc_del(p);
}
void
rsock_hup(struct aproc *p, struct abuf *ibuf)
{
- DPRINTFN(3, "rsock_hup: %p\n", p->u.io.file);
aproc_del(p);
}
@@ -136,9 +129,6 @@ rsock_opos(struct aproc *p, struct abuf *obuf, int delta)
return;
f->delta += delta;
- DPRINTFN(3, "rsock_opos: %p: delta = %d, f->delta = %d\n",
- f, delta, f->delta);
-
/*
* Negative deltas are xrun notifications for internal uses
* only. Don't generate a packet for this, the client will be
@@ -171,7 +161,6 @@ wsock_done(struct aproc *p)
{
struct sock *f = (struct sock *)p->u.io.file;
- DPRINTFN(1, "wsock_done: %p\n", f);
if (f == NULL)
return;
sock_reset(f);
@@ -192,8 +181,6 @@ wsock_in(struct aproc *p, struct abuf *ibuf)
if (f->pipe.file.state & FILE_WINUSE)
return 0;
-
- DPRINTFN(4, "wsock_in: %p\n", f);
/*
* See remark in rsock_out().
*/
@@ -210,10 +197,7 @@ wsock_out(struct aproc *p, struct abuf *obuf_dummy)
struct abuf *ibuf = LIST_FIRST(&p->ibuflist);
struct sock *f = (struct sock *)p->u.io.file;
- DPRINTFN(3, "wsock_out: %p\n", f);
-
if (ibuf) {
- DPRINTFN(3, "wsock_out: %p, filling ibuf\n", f);
if (!abuf_fill(ibuf))
return 0;
}
@@ -225,14 +209,12 @@ wsock_out(struct aproc *p, struct abuf *obuf_dummy)
void
wsock_eof(struct aproc *p, struct abuf *obuf)
{
- DPRINTFN(3, "wsock_eof: %p\n", p->u.io.file);
aproc_del(p);
}
void
wsock_hup(struct aproc *p, struct abuf *obuf_dummy)
{
- DPRINTFN(3, "wsock_hup: %p\n", p->u.io.file);
aproc_del(p);
}
@@ -245,8 +227,6 @@ wsock_ipos(struct aproc *p, struct abuf *obuf, int delta)
return;
f->delta += delta;
- DPRINTFN(3, "wsock_ipos: %p, delta = %d, f->delta = %d\n",
- f, delta, f->delta);
/*
* Negative deltas are xrun notifications for internal uses
* only. Don't generate a packet for this, the client will be
@@ -327,7 +307,6 @@ sock_freebuf(struct sock *f)
struct abuf *rbuf, *wbuf;
f->pstate = SOCK_INIT;
- DPRINTF("sock_freebuf:\n");
rbuf = LIST_FIRST(&f->pipe.file.rproc->obuflist);
if (rbuf)
abuf_eof(rbuf);
@@ -354,9 +333,6 @@ sock_allocbuf(struct sock *f)
}
f->delta = 0;
f->tickpending = 0;
-
- DPRINTF("sock_allocbuf: %p, using %u frames buffer\n", f, f->bufsz);
-
f->pstate = SOCK_START;
if (!(f->mode & AMSG_PLAY))
(void)sock_attach(f, 0);
@@ -374,7 +350,6 @@ sock_setvol(void *arg, unsigned vol)
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, MIDI_TO_ADATA(vol));
@@ -398,7 +373,6 @@ sock_attach(struct sock *f, int force)
if (!force && rbuf && ABUF_WOK(rbuf))
return 0;
- DPRINTF("sock_attach: %p\n", f);
f->pstate = SOCK_RUN;
/*
@@ -451,7 +425,6 @@ sock_rmsg(struct sock *f)
while (f->rtodo > 0) {
if (!(f->pipe.file.state & FILE_ROK)) {
- DPRINTFN(4, "sock_rmsg: blk, rtodo = %u\n", f->rtodo);
return 0;
}
data = (unsigned char *)&f->rmsg;
@@ -461,7 +434,6 @@ sock_rmsg(struct sock *f)
return 0;
f->rtodo -= count;
}
- DPRINTFN(4, "sock_rmsg: %p: done\n", f);
return 1;
}
@@ -478,7 +450,6 @@ sock_wmsg(struct sock *f, struct amsg *m, unsigned *ptodo)
while (*ptodo > 0) {
if (!(f->pipe.file.state & FILE_WOK)) {
- DPRINTFN(4, "sock_wmsg: blk, *ptodo = %u\n", *ptodo);
return 0;
}
data = (unsigned char *)m;
@@ -488,7 +459,6 @@ sock_wmsg(struct sock *f, struct amsg *m, unsigned *ptodo)
return 0;
*ptodo -= count;
}
- DPRINTFN(4, "sock_wmsg: %p: done\n", f);
return 1;
}
@@ -504,12 +474,6 @@ sock_rdata(struct sock *f)
unsigned char *data;
unsigned count, n;
-#ifdef DEBUG
- if (f->pstate != SOCK_MIDI && f->rtodo == 0) {
- fprintf(stderr, "sock_rdata: bad call: zero arg\n");
- abort();
- }
-#endif
p = f->pipe.file.rproc;
obuf = LIST_FIRST(&p->obuflist);
if (obuf == NULL)
@@ -542,12 +506,6 @@ sock_wdata(struct sock *f)
#define ZERO_MAX 0x1000
static char zero[ZERO_MAX];
-#ifdef DEBUG
- if (f->pstate != SOCK_MIDI && f->wtodo == 0) {
- fprintf(stderr, "sock_wdata: bad call: zero arg\n");
- abort();
- }
-#endif
if (!(f->pipe.file.state & FILE_WOK))
return 0;
p = f->pipe.file.wproc;
@@ -592,12 +550,11 @@ sock_setpar(struct sock *f)
if (AMSG_ISSET(p->legacy_mode)) {
/*
- * XXX: allow old clients that don't support HELLO
- * to work
+ * allow old clients that don't support HELLO to work
+ * XXX: remove this.
*/
if ((p->legacy_mode & ~(AMSG_PLAY | AMSG_REC)) ||
(p->legacy_mode == 0)) {
- DPRINTF("sock_setpar: bad mode %x\n", p->legacy_mode);
return 0;
}
f->mode = 0;
@@ -605,23 +562,19 @@ sock_setpar(struct sock *f)
f->mode |= AMSG_PLAY;
if ((p->legacy_mode & AMSG_REC) && dev_sub)
f->mode |= AMSG_REC;
- DPRINTF("sock_setpar: mode -> %x\n", f->mode);
}
if (AMSG_ISSET(p->bits)) {
if (p->bits < BITS_MIN || p->bits > BITS_MAX) {
- DPRINTF("sock_setpar: bits out of bounds\n");
return 0;
}
if (AMSG_ISSET(p->bps)) {
if (p->bps < ((p->bits + 7) / 8) || p->bps > 4) {
- DPRINTF("sock_setpar: bps out of bounds\n");
return 0;
}
} else
p->bps = APARAMS_BPS(p->bits);
f->rpar.bits = f->wpar.bits = p->bits;
f->rpar.bps = f->wpar.bps = p->bps;
- DPRINTF("sock_setpar: bits/bps -> %u/%u\n", p->bits, p->bps);
}
if (AMSG_ISSET(p->sig))
f->rpar.sig = f->wpar.sig = p->sig ? 1 : 0;
@@ -638,8 +591,6 @@ sock_setpar(struct sock *f)
f->wpar.cmax = f->opt->wpar.cmin + p->rchan - 1;
if (f->wpar.cmax > f->opt->wpar.cmax)
f->wpar.cmax = f->opt->wpar.cmax;
- DPRINTF("sock_setpar: rchan -> %u:%u\n",
- f->wpar.cmin, f->wpar.cmax);
}
if (AMSG_ISSET(p->pchan) && (f->mode & AMSG_PLAY)) {
if (p->pchan < 1)
@@ -650,8 +601,6 @@ sock_setpar(struct sock *f)
f->rpar.cmax = f->opt->rpar.cmin + p->pchan - 1;
if (f->rpar.cmax > f->opt->rpar.cmax)
f->rpar.cmax = f->opt->rpar.cmax;
- DPRINTF("sock_setpar: pchan -> %u:%u\n",
- f->rpar.cmin, f->rpar.cmax);
}
if (AMSG_ISSET(p->rate)) {
if (p->rate < RATE_MIN)
@@ -662,27 +611,21 @@ sock_setpar(struct sock *f)
f->rpar.rate = f->wpar.rate = p->rate;
if (!AMSG_ISSET(p->appbufsz)) {
p->appbufsz = dev_bufsz / dev_round * f->round;
- DPRINTF("sock_setpar: appbufsz -> %u\n", p->appbufsz);
}
- DPRINTF("sock_setpar: rate -> %u, round -> %u\n",
- p->rate, f->round);
}
if (AMSG_ISSET(p->xrun)) {
if (p->xrun != AMSG_IGNORE &&
p->xrun != AMSG_SYNC &&
p->xrun != AMSG_ERROR) {
- DPRINTF("sock_setpar: bad xrun: %u\n", p->xrun);
return 0;
}
f->xrun = p->xrun;
- DPRINTF("sock_setpar: xrun -> %u\n", f->xrun);
}
if (AMSG_ISSET(p->bufsz)) {
/*
* XXX: bufsz will become read-only, but for now
* allow old library to properly work
*/
- DPRINTF("sock_setpar: bufsz: %u\n", p->bufsz);
min = (dev_bufsz / dev_round) * f->round;
if (p->bufsz < min)
p->bufsz = min;
@@ -701,17 +644,7 @@ sock_setpar(struct sock *f)
if (p->appbufsz > max)
p->appbufsz = max;
f->bufsz = p->appbufsz;
- DPRINTF("sock_setpar: bufsz -> %u\n", f->bufsz);
- }
-#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "sock_setpar: %p: rpar=", f);
- aparams_print(&f->rpar);
- fprintf(stderr, ", wpar=");
- aparams_print(&f->wpar);
- fprintf(stderr, ", mode=%u, bufsz=%u\n", f->mode, f->bufsz);
}
-#endif
return 1;
}
@@ -739,11 +672,11 @@ sock_hello(struct sock *f)
{
struct amsg_hello *p = &f->rmsg.u.hello;
- DPRINTF("sock_hello: from <%s>, mode = %x\n", p->who, p->proto);
+ /* XXX : set file name to p->who */
+ /* XXX : dev_midi can no longer be NULL, right ? */
if (dev_midi && (p->proto & (AMSG_MIDIIN | AMSG_MIDIOUT))) {
if (p->proto & ~(AMSG_MIDIIN | AMSG_MIDIOUT)) {
- DPRINTF("sock_hello: %x: bad proto\n", p->proto);
return 0;
}
f->mode = p->proto;
@@ -760,20 +693,17 @@ sock_hello(struct sock *f)
f->rpar = f->opt->rpar;
if ((p->proto & ~(AMSG_PLAY | AMSG_REC)) != 0 ||
(p->proto & (AMSG_PLAY | AMSG_REC)) == 0) {
- DPRINTF("sock_hello: %x: unsupported proto\n", p->proto);
return 0;
}
f->mode = 0;
if (p->proto & AMSG_PLAY) {
if (!dev_mix) {
- DPRINTF("sock_hello: playback not supported\n");
return 0;
}
f->mode |= AMSG_PLAY;
}
if (p->proto & AMSG_REC) {
if (!dev_sub) {
- DPRINTF("sock_hello: recording not supported\n");
return 0;
}
f->mode |= AMSG_REC;
@@ -781,7 +711,6 @@ sock_hello(struct sock *f)
if (dev_midi) {
f->slot = ctl_slotnew(dev_midi, p->who, sock_setvol, f);
if (f->slot < 0) {
- DPRINTF("sock_hello: out of mixer slots\n");
return 0;
}
}
@@ -802,35 +731,28 @@ sock_execmsg(struct sock *f)
* XXX: allow old clients to work without hello on the default socket
*/
if (f->pstate == SOCK_HELLO && m->cmd != AMSG_HELLO && f->opt != NULL) {
- DPRINTF("sock_execmsg: legacy client\n");
f->pstate = SOCK_INIT;
}
switch (m->cmd) {
case AMSG_DATA:
- DPRINTFN(4, "sock_execmsg: %p: DATA\n", f);
if (f->pstate != SOCK_RUN && f->pstate != SOCK_START) {
- DPRINTF("sock_execmsg: %p: DATA, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
if (!(f->mode & AMSG_PLAY)) {
- DPRINTF("sock_execmsg: %p: DATA, not allowed\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
f->rstate = SOCK_RDATA;
f->rtodo = m->u.data.size;
if (f->rtodo == 0) {
- DPRINTF("sock_execmsg: zero-length data chunk\n");
aproc_del(f->pipe.file.rproc);
return 0;
}
break;
case AMSG_START:
- DPRINTFN(2, "sock_execmsg: %p: START\n", f);
if (f->pstate != SOCK_INIT) {
- DPRINTF("sock_execmsg: %p: START, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -839,9 +761,7 @@ sock_execmsg(struct sock *f)
f->rtodo = sizeof(struct amsg);
break;
case AMSG_STOP:
- DPRINTFN(2, "sock_execmsg: %p: STOP\n", f);
if (f->pstate != SOCK_RUN && f->pstate != SOCK_START) {
- DPRINTF("sock_execmsg: %p: STOP, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -854,9 +774,7 @@ sock_execmsg(struct sock *f)
f->rtodo = sizeof(struct amsg);
break;
case AMSG_SETPAR:
- DPRINTFN(2, "sock_execmsg: %p: SETPAR\n", f);
if (f->pstate != SOCK_INIT) {
- DPRINTF("sock_execmsg: %p: SETPAR, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -868,9 +786,7 @@ sock_execmsg(struct sock *f)
f->rstate = SOCK_RMSG;
break;
case AMSG_GETPAR:
- DPRINTFN(2, "sock_execmsg: %p: GETPAR\n", f);
if (f->pstate != SOCK_INIT) {
- DPRINTF("sock_execmsg: %p: GETPAR, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -893,9 +809,7 @@ sock_execmsg(struct sock *f)
f->rtodo = sizeof(struct amsg);
break;
case AMSG_GETCAP:
- DPRINTFN(2, "sock_execmsg: %p: GETCAP\n", f);
if (f->pstate != SOCK_INIT) {
- DPRINTF("sock_execmsg: %p: GETCAP, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -912,19 +826,15 @@ sock_execmsg(struct sock *f)
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, m->u.vol.ctl);
if (dev_midi && f->slot >= 0)
ctl_slotvol(dev_midi, f->slot, m->u.vol.ctl);
@@ -932,9 +842,7 @@ sock_execmsg(struct sock *f)
f->rstate = SOCK_RMSG;
break;
case AMSG_HELLO:
- DPRINTFN(2, "sock_execmsg: %p: HELLO\n", f);
if (f->pstate != SOCK_HELLO) {
- DPRINTF("sock_execmsg: %p: HELLO, bad state\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -948,13 +856,11 @@ sock_execmsg(struct sock *f)
f->rtodo = sizeof(struct amsg);
break;
case AMSG_BYE:
- DPRINTFN(2, "sock_execmsg: %p: BYE\n", f);
- if (f->pstate != SOCK_INIT)
- DPRINTF("sock_execmsg: %p: BYE, bad state\n", f);
+ if (f->pstate != SOCK_INIT) {
+ }
aproc_del(f->pipe.file.rproc);
return 0;
default:
- DPRINTF("sock_execmsg: %p bogus command\n", f);
aproc_del(f->pipe.file.rproc);
return 0;
}
@@ -962,7 +868,6 @@ sock_execmsg(struct sock *f)
if (f->wstate != SOCK_WIDLE ||
!sock_wmsg(f, &f->rmsg, &f->rtodo))
return 0;
- DPRINTF("sock_execmsg: %p RRET done\n", f);
if (f->pstate == SOCK_MIDI && (f->mode & AMSG_MIDIOUT)) {
f->rstate = SOCK_RDATA;
f->rtodo = 0;
@@ -984,7 +889,6 @@ sock_buildmsg(struct sock *f)
struct abuf *ibuf;
if (f->pstate == SOCK_MIDI) {
- DPRINTFN(4, "sock_buildmsg: %p: switched to midi\n", f);
f->wstate = SOCK_WDATA;
f->wtodo = 0;
return 1;
@@ -994,7 +898,6 @@ sock_buildmsg(struct sock *f)
* If pos changed, build a MOVE message.
*/
if (f->tickpending && f->delta >= 0) {
- DPRINTFN(4, "sock_buildmsg: %p: POS: %d\n", f, f->delta);
AMSG_INIT(&f->wmsg);
f->wmsg.cmd = AMSG_MOVE;
f->wmsg.u.ts.delta = f->delta;
@@ -1009,7 +912,6 @@ sock_buildmsg(struct sock *f)
* if volume changed build a SETVOL message
*/
if (f->pstate >= SOCK_START && f->vol != f->lastvol) {
- DPRINTFN(4, "sock_buildmsg: %p: SETVOL: %d\n", f, f->vol);
AMSG_INIT(&f->wmsg);
f->wmsg.cmd = AMSG_SETVOL;
f->wmsg.u.vol.ctl = f->vol;
@@ -1035,8 +937,6 @@ sock_buildmsg(struct sock *f)
f->wstate = SOCK_WMSG;
return 1;
}
-
- DPRINTFN(4, "sock_buildmsg: %p: idling...\n", f);
f->wstate = SOCK_WIDLE;
return 0;
}
@@ -1049,9 +949,6 @@ sock_buildmsg(struct sock *f)
int
sock_read(struct sock *f)
{
- DPRINTFN(4, "sock_read: %p; rstate = %u, rtodo = %u\n",
- f, f->rstate, f->rtodo);
-
switch (f->rstate) {
case SOCK_RMSG:
if (!sock_rmsg(f))
@@ -1070,10 +967,8 @@ sock_read(struct sock *f)
(void)sock_attach(f, 0);
break;
case SOCK_RRET:
- DPRINTF("sock_read: %p: blocked in RRET\n", f);
return 0;
}
- DPRINTFN(4, "sock_read: %p: done, rstate = %u\n", f, f->rstate);
return 1;
}
@@ -1088,7 +983,6 @@ sock_return(struct sock *f)
while (f->rstate == SOCK_RRET) {
if (!sock_wmsg(f, &f->rmsg, &f->rtodo))
return 0;
- DPRINTF("sock_return: %p: done\n", f);
if (f->pstate == SOCK_MIDI && (f->mode & AMSG_MIDIOUT)) {
f->rstate = SOCK_RDATA;
f->rtodo = 0;
@@ -1123,9 +1017,6 @@ sock_return(struct sock *f)
int
sock_write(struct sock *f)
{
- DPRINTFN(4, "sock_write: %p: wstate = %u, wtodo = %u\n",
- f, f->wstate, f->wtodo);
-
switch (f->wstate) {
case SOCK_WMSG:
if (!sock_wmsg(f, &f->wmsg, &f->wtodo))
@@ -1152,9 +1043,6 @@ sock_write(struct sock *f)
if (!sock_buildmsg(f))
return 0;
break;
- default:
- fprintf(stderr, "sock_write: unknown state\n");
- abort();
}
return 1;
}
diff --git a/usr.bin/aucat/sock.h b/usr.bin/aucat/sock.h
index 3f6c1f5e6d5..4a54abb2816 100644
--- a/usr.bin/aucat/sock.h
+++ b/usr.bin/aucat/sock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.h,v 1.10 2009/08/26 06:10:15 ratchov Exp $ */
+/* $OpenBSD: sock.h,v 1.11 2009/09/27 11:51:20 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -58,6 +58,7 @@ struct sock {
int lastvol; /* last volume */
int slot; /* mixer ctl slot number */
struct opt *opt; /* "subdevice" definition */
+ char who[12]; /* label, mostly for debugging */
};
struct sock *sock_new(struct fileops *, int fd);
diff --git a/usr.bin/aucat/wav.c b/usr.bin/aucat/wav.c
index 0b7bfba6f8c..f69a17a7ca7 100644
--- a/usr.bin/aucat/wav.c
+++ b/usr.bin/aucat/wav.c
@@ -14,13 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
-
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include "conf.h"
#include "wav.h"
@@ -186,7 +180,6 @@ wav_read(struct file *file, unsigned char *data, unsigned count)
if (f->rbytes >= 0 && count > f->rbytes) {
count = f->rbytes; /* file->rbytes fits in count */
if (count == 0) {
- DPRINTFN(2, "wav_read: %s: complete\n", f->pipe.file.name);
file_eof(&f->pipe.file);
return 0;
}
@@ -212,8 +205,6 @@ wav_write(struct file *file, unsigned char *data, unsigned count)
if (f->wbytes >= 0 && count > f->wbytes) {
count = f->wbytes; /* wbytes fits in count */
if (count == 0) {
- DPRINTFN(2, "wav_write: %s: complete\n",
- f->pipe.file.name);
file_hup(&f->pipe.file);
return 0;
}