summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/aucat/abuf.c4
-rw-r--r--usr.bin/aucat/aproc.c61
-rw-r--r--usr.bin/aucat/aproc.h4
-rw-r--r--usr.bin/aucat/aucat.c3
-rw-r--r--usr.bin/aucat/dev.c24
-rw-r--r--usr.bin/aucat/dev.h3
-rw-r--r--usr.bin/aucat/safile.c10
-rw-r--r--usr.bin/aucat/sock.c6
8 files changed, 91 insertions, 24 deletions
diff --git a/usr.bin/aucat/abuf.c b/usr.bin/aucat/abuf.c
index 9c39c470dea..4d14626ee7f 100644
--- a/usr.bin/aucat/abuf.c
+++ b/usr.bin/aucat/abuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abuf.c,v 1.17 2010/01/10 21:47:41 ratchov Exp $ */
+/* $OpenBSD: abuf.c,v 1.18 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -249,7 +249,7 @@ abuf_wgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs)
#ifdef DEBUG
if (end >= buf->len) {
abuf_dump(buf);
- dbg_puts(": rgetblk: bad ofs = ");
+ dbg_puts(": wgetblk: bad ofs = ");
dbg_putu(ofs);
dbg_puts("\n");
dbg_panic();
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index c0a6010bfb4..8b1e7f09979 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.42 2010/01/10 21:47:41 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.43 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -349,7 +349,7 @@ rfile_hup(struct aproc *p, struct abuf *obuf)
}
struct aproc_ops rfile_ops = {
- "rpipe",
+ "rfile",
rfile_in,
rfile_out,
rfile_eof,
@@ -451,7 +451,7 @@ wfile_hup(struct aproc *p, struct abuf *obuf_dummy)
}
struct aproc_ops wfile_ops = {
- "wpipe",
+ "wfile",
wfile_in,
wfile_out,
wfile_eof,
@@ -514,10 +514,10 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf)
#ifdef DEBUG
if (debug_level >= 4) {
abuf_dbg(ibuf);
- dbg_puts(": badd: todo = ");
- dbg_putu(obuf->w.mix.todo);
- dbg_puts("/");
+ dbg_puts(": badd: done = ");
dbg_putu(ibuf->r.mix.done);
+ dbg_puts("/");
+ dbg_putu(obuf->w.mix.todo);
dbg_puts("\n");
}
#endif
@@ -633,10 +633,10 @@ mix_in(struct aproc *p, struct abuf *ibuf)
dbg_putu(ibuf->used);
dbg_puts("/");
dbg_putu(ibuf->len);
- dbg_puts(", todo = ");
- dbg_putu(obuf->w.mix.todo);
- dbg_puts("/");
+ dbg_puts(", done = ");
dbg_putu(ibuf->r.mix.done);
+ dbg_puts("/");
+ dbg_putu(obuf->w.mix.todo);
dbg_puts("\n");
}
#endif
@@ -898,6 +898,49 @@ mix_clear(struct aproc *p)
obuf->w.mix.todo = 0;
}
+void
+mix_prime(struct aproc *p)
+{
+ struct abuf *obuf = LIST_FIRST(&p->obuflist);
+ unsigned todo, count;
+
+#ifdef DEBUG
+ if (debug_level >= 3) {
+ aproc_dbg(p);
+ dbg_puts(": prime1: lat/maxlat=");
+ dbg_puti(p->u.mix.lat);
+ dbg_puts("/");
+ dbg_puti(p->u.mix.maxlat);
+ dbg_puts("\n");
+ }
+#endif
+ for (;;) {
+ if (!ABUF_WOK(obuf))
+ break;
+ todo = (p->u.mix.maxlat - p->u.mix.lat) * obuf->bpf;
+ if (todo == 0)
+ break;
+ mix_bzero(obuf, obuf->len);
+ count = obuf->w.mix.todo;
+ if (count > todo)
+ count = todo;
+ obuf->w.mix.todo -= count;
+ p->u.mix.lat += count / obuf->bpf;
+ abuf_wcommit(obuf, count);
+ abuf_flush(obuf);
+ }
+#ifdef DEBUG
+ if (debug_level >= 3) {
+ aproc_dbg(p);
+ dbg_puts(": prime: lat/maxlat=");
+ dbg_puti(p->u.mix.lat);
+ dbg_puts("/");
+ dbg_puti(p->u.mix.maxlat);
+ dbg_puts("\n");
+ }
+#endif
+}
+
/*
* Copy data from ibuf to obuf.
*/
diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h
index e5565614e1d..7128dac55ab 100644
--- a/usr.bin/aucat/aproc.h
+++ b/usr.bin/aucat/aproc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.h,v 1.28 2010/01/05 10:18:12 ratchov Exp $ */
+/* $OpenBSD: aproc.h,v 1.29 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -219,9 +219,9 @@ struct aproc *cmap_new(char *, struct aparams *, struct aparams *);
struct aproc *enc_new(char *, struct aparams *);
struct aproc *dec_new(char *, struct aparams *);
-void mix_pushzero(struct aproc *);
void mix_setmaster(struct aproc *);
void mix_clear(struct aproc *);
+void mix_prime(struct aproc *);
void sub_clear(struct aproc *);
#endif /* !defined(APROC_H) */
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 873cd4771ef..e43e43eeec4 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.78 2010/01/10 21:47:41 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.79 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -587,6 +587,7 @@ aucat_main(int argc, char **argv)
suspend = 1;
dev_stop();
dev_clear();
+ dev_prime();
}
}
if ((dev_mix && dev_mix->u.mix.idle == 0) ||
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c
index e749531d742..87dd6028e59 100644
--- a/usr.bin/aucat/dev.c
+++ b/usr.bin/aucat/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.39 2010/01/10 21:47:41 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.40 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -227,7 +227,7 @@ dev_init(char *devpath,
* Append a "sub" to which clients will connect.
* Link it to the controller only in record-only mode
*/
- dev_sub = sub_new("rec", nfr, dopar ? NULL : dev_midi);
+ dev_sub = sub_new("rec", ibufsz, dopar ? NULL : dev_midi);
dev_sub->refs++;
aproc_setin(dev_sub, buf);
} else {
@@ -264,7 +264,7 @@ dev_init(char *devpath,
/*
* Append a "mix" to which clients will connect.
*/
- dev_mix = mix_new("play", nfr, dev_midi);
+ dev_mix = mix_new("play", obufsz, dev_midi);
dev_mix->refs++;
aproc_setout(dev_mix, buf);
} else {
@@ -741,3 +741,21 @@ dev_clear(void)
sub_clear(dev_sub);
}
}
+
+/*
+ * Fill with silence play buffers and schedule the same amount of recorded
+ * samples to drop
+ */
+void
+dev_prime(void)
+{
+ if (dev_mix) {
+#ifdef DEBUG
+ if (!LIST_EMPTY(&dev_mix->ibuflist)) {
+ dbg_puts("play end not idle, can't prime device\n");
+ dbg_panic();
+ }
+#endif
+ mix_prime(dev_mix);
+ }
+}
diff --git a/usr.bin/aucat/dev.h b/usr.bin/aucat/dev.h
index ae8eda32164..c346bb26719 100644
--- a/usr.bin/aucat/dev.h
+++ b/usr.bin/aucat/dev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.h,v 1.16 2010/01/05 10:18:12 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.17 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -43,5 +43,6 @@ void dev_attach(char *,
struct abuf *, struct aparams *, unsigned, int);
void dev_setvol(struct abuf *, int);
void dev_clear(void);
+void dev_prime(void);
#endif /* !define(DEV_H) */
diff --git a/usr.bin/aucat/safile.c b/usr.bin/aucat/safile.c
index 2d5b5516261..2cbc7e47a54 100644
--- a/usr.bin/aucat/safile.c
+++ b/usr.bin/aucat/safile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safile.c,v 1.20 2010/01/10 21:47:41 ratchov Exp $ */
+/* $OpenBSD: safile.c,v 1.21 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -210,7 +210,7 @@ safile_read(struct file *file, unsigned char *data, unsigned count)
struct safile *f = (struct safile *)file;
unsigned n;
- n = sio_read(f->hdl, data, count);
+ n = f->started ? sio_read(f->hdl, data, count) : 0;
if (n == 0) {
f->file.state &= ~FILE_ROK;
if (sio_eof(f->hdl)) {
@@ -239,7 +239,7 @@ safile_write(struct file *file, unsigned char *data, unsigned count)
struct safile *f = (struct safile *)file;
unsigned n;
- n = sio_write(f->hdl, data, count);
+ n = f->started ? sio_write(f->hdl, data, count) : 0;
if (n == 0) {
f->file.state &= ~FILE_WOK;
if (sio_eof(f->hdl)) {
@@ -270,6 +270,10 @@ safile_nfds(struct file *file)
int
safile_pollfd(struct file *file, struct pollfd *pfd, int events)
{
+ struct safile *f = (struct safile *)file;
+
+ if (!f->started)
+ events &= ~(POLLIN | POLLOUT);
return sio_pollfd(((struct safile *)file)->hdl, pfd, events);
}
diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c
index d11ffe0b8ed..0707d9a9712 100644
--- a/usr.bin/aucat/sock.c
+++ b/usr.bin/aucat/sock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.c,v 1.37 2010/01/10 21:47:41 ratchov Exp $ */
+/* $OpenBSD: sock.c,v 1.38 2010/01/11 13:06:32 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -834,8 +834,8 @@ sock_setpar(struct sock *f)
}
if (AMSG_ISSET(p->appbufsz)) {
rate = (f->mode & AMSG_PLAY) ? f->rpar.rate : f->wpar.rate;
- min = 1;
- max = 1 + rate / dev_round;
+ min = 2;
+ max = 2 + rate / dev_round;
min *= f->round;
max *= f->round;
p->appbufsz += f->round - 1;