summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2014-03-17 17:16:07 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2014-03-17 17:16:07 +0000
commit34459019cb82907ca1edf96e0721ad6636ad098d (patch)
tree57463334de07055844858614df580a237a82d6bd /usr.bin/sndiod
parent6f93e46107fcb9be9e862c8dc375614a24cdaaff (diff)
unbreak monitoring mode, which was shifted in time by 1 block
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r--usr.bin/sndiod/dev.c25
-rw-r--r--usr.bin/sndiod/dev.h3
-rw-r--r--usr.bin/sndiod/siofile.c4
3 files changed, 20 insertions, 12 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index 7f9c8fe1baa..a3f6cd5c7ab 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.14 2014/03/07 10:23:05 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.15 2014/03/17 17:16:06 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -739,9 +739,15 @@ void
dev_sub_bcopy(struct dev *d, struct slot *s)
{
adata_t *idata, *odata;
- int ocount;
+ int ocount, moffs;
- idata = (s->mode & MODE_MON) ? DEV_PBUF(d) : d->rbuf;
+ if (s->mode & MODE_MON) {
+ moffs = d->poffs + d->round;
+ if (moffs == d->psize)
+ moffs = 0;
+ idata = d->pbuf + moffs * d->pchan;
+ } else
+ idata = d->rbuf;
odata = (adata_t *)abuf_wgetblk(&s->sub.buf, &ocount);
#ifdef DEBUG
if (ocount < s->round * s->sub.bpf) {
@@ -863,11 +869,6 @@ dev_full_cycle(struct dev *d)
}
continue;
}
- if (s->mode & MODE_PLAY) {
- dev_mix_badd(d, s);
- if (s->pstate != SLOT_STOP)
- s->ops->fill(s->arg);
- }
if ((s->mode & MODE_RECMASK) && !(s->pstate == SLOT_STOP)) {
if (s->sub.prime == 0) {
dev_sub_bcopy(d, s);
@@ -884,6 +885,11 @@ dev_full_cycle(struct dev *d)
s->sub.prime--;
}
}
+ if (s->mode & MODE_PLAY) {
+ dev_mix_badd(d, s);
+ if (s->pstate != SLOT_STOP)
+ s->ops->fill(s->arg);
+ }
ps = &s->next;
}
if ((d->mode & MODE_PLAY) && d->encbuf) {
@@ -1094,8 +1100,9 @@ dev_open(struct dev *d)
/*
* Create device <-> mixer buffer
*/
- d->pbuf = xmalloc(d->bufsz * d->pchan * sizeof(adata_t));
d->poffs = 0;
+ d->psize = d->bufsz + d->round;
+ d->pbuf = xmalloc(d->psize * d->pchan * sizeof(adata_t));
d->mode |= MODE_MON;
/*
diff --git a/usr.bin/sndiod/dev.h b/usr.bin/sndiod/dev.h
index cc2f51ea59a..da4edb673b5 100644
--- a/usr.bin/sndiod/dev.h
+++ b/usr.bin/sndiod/dev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.h,v 1.7 2014/03/07 10:23:05 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.8 2014/03/17 17:16:06 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -113,6 +113,7 @@ struct dev {
adata_t *pbuf; /* array of play buffers */
#define DEV_PBUF(d) ((d)->pbuf + (d)->poffs * (d)->pchan)
int poffs; /* index of current play buf */
+ int psize; /* size of play buffer */
struct conv enc; /* native->device format */
struct conv dec; /* device->native format */
unsigned char *encbuf; /* buffer for encoding */
diff --git a/usr.bin/sndiod/siofile.c b/usr.bin/sndiod/siofile.c
index da95e611fe8..ff7818775f4 100644
--- a/usr.bin/sndiod/siofile.c
+++ b/usr.bin/sndiod/siofile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siofile.c,v 1.3 2013/11/18 17:37:45 ratchov Exp $ */
+/* $OpenBSD: siofile.c,v 1.4 2014/03/17 17:16:06 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -415,7 +415,7 @@ dev_sio_run(void *arg)
}
#endif
d->poffs += d->round;
- if (d->poffs == d->bufsz)
+ if (d->poffs == d->psize)
d->poffs = 0;
if ((d->mode & MODE_REC) && d->prime == 0) {
d->sio.cstate = DEV_SIO_READ;