unbreak monitoring mode (was 1 block off)

This commit is contained in:
Alexandre Ratchov 2014-03-17 18:13:11 +01:00
parent 559d953ef6
commit 0c70f95bd5
3 changed files with 17 additions and 9 deletions

View File

@ -740,9 +740,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) {
@ -864,11 +870,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);
@ -885,6 +886,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) {
@ -1095,8 +1101,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;
/*

View File

@ -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 */

View File

@ -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;