summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/aucat/aproc.c35
-rw-r--r--usr.bin/aucat/aproc.h6
-rw-r--r--usr.bin/aucat/aucat.c4
-rw-r--r--usr.bin/aucat/dev.c112
-rw-r--r--usr.bin/aucat/dev.h6
-rw-r--r--usr.bin/aucat/safile.c105
-rw-r--r--usr.bin/aucat/safile.h4
-rw-r--r--usr.bin/aucat/sock.c47
8 files changed, 78 insertions, 241 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index 246cf6ebeac..794a2b130b4 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.25 2008/11/16 17:08:32 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.26 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -831,11 +831,11 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
{
unsigned inch;
short *idata;
- unsigned ipos, orate;
+ unsigned ipos, oblksz;
unsigned ifr;
unsigned onch;
short *odata;
- unsigned opos, irate;
+ unsigned opos, iblksz;
unsigned ofr;
unsigned c;
short *ctxbuf, *ctx;
@@ -859,10 +859,10 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
*/
inch = ibuf->cmax - ibuf->cmin + 1;
ipos = p->u.resamp.ipos;
- irate = p->u.resamp.irate;
+ iblksz = p->u.resamp.iblksz;
onch = obuf->cmax - obuf->cmin + 1;
opos = p->u.resamp.opos;
- orate = p->u.resamp.orate;
+ oblksz = p->u.resamp.oblksz;
ctxbuf = p->u.resamp.ctx;
/*
@@ -879,7 +879,7 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
odata++;
ctx++;
}
- opos += irate;
+ opos += iblksz;
ofr--;
} else {
if (ifr == 0)
@@ -890,7 +890,7 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
idata++;
ctx++;
}
- ipos += orate;
+ ipos += oblksz;
ifr--;
}
}
@@ -962,8 +962,8 @@ resamp_ipos(struct aproc *p, struct abuf *ibuf, int delta)
DPRINTFN(3, "resamp_ipos: %d\n", delta);
- ifac = p->u.resamp.irate;
- ofac = p->u.resamp.orate;
+ ifac = p->u.resamp.iblksz;
+ ofac = p->u.resamp.oblksz;
ipos = p->u.resamp.idelta + (long long)delta * ofac;
delta = (ipos + ifac - 1) / ifac;
p->u.resamp.idelta = ipos - (long long)delta * ifac;
@@ -979,8 +979,8 @@ resamp_opos(struct aproc *p, struct abuf *obuf, int delta)
DPRINTFN(3, "resamp_opos: %d\n", delta);
- ifac = p->u.resamp.irate;
- ofac = p->u.resamp.orate;
+ ifac = p->u.resamp.iblksz;
+ ofac = p->u.resamp.oblksz;
opos = p->u.resamp.odelta + (long long)delta * ifac;
delta = (opos + ofac - 1) / ofac;
p->u.resamp.odelta = opos - (long long)delta * ofac;
@@ -1001,14 +1001,14 @@ struct aproc_ops resamp_ops = {
};
struct aproc *
-resamp_new(char *name, struct aparams *ipar, struct aparams *opar)
+resamp_new(char *name, unsigned iblksz, unsigned oblksz)
{
struct aproc *p;
unsigned i;
p = aproc_new(&resamp_ops, name);
- p->u.resamp.irate = ipar->rate;
- p->u.resamp.orate = opar->rate;
+ p->u.resamp.iblksz = iblksz;
+ p->u.resamp.oblksz = oblksz;
p->u.resamp.ipos = 0;
p->u.resamp.opos = 0;
p->u.resamp.idelta = 0;
@@ -1016,11 +1016,8 @@ resamp_new(char *name, struct aparams *ipar, struct aparams *opar)
for (i = 0; i < NCHAN_MAX; i++)
p->u.resamp.ctx[i] = 0;
#ifdef DEBUG
- if (debug_level > 0) {
- fprintf(stderr, "resamp_new: %s: ", p->name);
- aparams_print2(ipar, opar);
- fprintf(stderr, "\n");
- }
+ if (debug_level > 0)
+ fprintf(stderr, "resamp_new: %u/%u\n", iblksz, oblksz);
#endif
return p;
}
diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h
index f9bd82ed65e..ffb33f93b58 100644
--- a/usr.bin/aucat/aproc.h
+++ b/usr.bin/aucat/aproc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.h,v 1.12 2008/11/09 16:26:07 ratchov Exp $ */
+/* $OpenBSD: aproc.h,v 1.13 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -143,7 +143,7 @@ struct aproc {
} sub;
struct {
short ctx[NCHAN_MAX];
- unsigned irate, orate;
+ unsigned iblksz, oblksz;
int ipos, opos;
int idelta, odelta; /* reminder of conv_[io]pos */
} resamp;
@@ -182,7 +182,7 @@ void wpipe_hup(struct aproc *, struct abuf *);
struct aproc *mix_new(char *, int);
struct aproc *sub_new(char *, int);
-struct aproc *resamp_new(char *, struct aparams *, struct aparams *);
+struct aproc *resamp_new(char *, unsigned, unsigned);
struct aproc *cmap_new(char *, struct aparams *, struct aparams *);
struct aproc *enc_new(char *, struct aparams *);
struct aproc *dec_new(char *, struct aparams *);
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index ae7d7bcf90f..2099b4df5a5 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.47 2008/11/23 12:29:32 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.48 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -497,7 +497,7 @@ main(int argc, char **argv)
dev_init(devpath,
(mode & MODE_REC) ? &dipar : NULL,
(mode & MODE_PLAY) ? &dopar : NULL,
- bufsz, l_flag);
+ bufsz);
/*
* Create buffers for all input and output pipes.
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c
index e1548490b86..637eaa65a7f 100644
--- a/usr.bin/aucat/dev.c
+++ b/usr.bin/aucat/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.19 2008/11/16 17:08:32 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.20 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -26,65 +26,14 @@
#include "safile.h"
unsigned dev_bufsz, dev_round, dev_rate;
-unsigned dev_rate_div, dev_round_div;
struct aparams dev_ipar, dev_opar;
struct aproc *dev_mix, *dev_sub, *dev_rec, *dev_play;
struct file *dev_file;
-/*
- * supported rates
- */
-#define NRATES (sizeof(dev_rates) / sizeof(dev_rates[0]))
-unsigned dev_rates[] = {
- 6400, 7200, 8000, 9600, 11025, 12000,
- 12800, 14400, 16000, 19200, 22050, 24000,
- 25600, 28800, 32000, 38400, 44100, 48000,
- 51200, 57600, 64000, 76800, 88200, 96000,
- 102400, 115200, 128000, 153600, 176400, 192000
-};
-
-/*
- * factors of supported rates
- */
-#define NPRIMES (sizeof(dev_primes) / sizeof(dev_primes[0]))
-unsigned dev_primes[] = {2, 3, 5, 7};
-
-int
-dev_setrate(unsigned rate)
-{
- unsigned i, r, p;
-
- r = 1000 * rate;
- for (i = 0; i < NRATES; i++) {
- if (i == NRATES) {
- fprintf(stderr, "dev_setrate: %u, unsupported\n", rate);
- return 0;
- }
- if (r > 996 * dev_rates[i] &&
- r < 1004 * dev_rates[i]) {
- dev_rate = dev_rates[i];
- break;
- }
- }
-
- dev_rate_div = dev_rate;
- dev_round_div = dev_round;
- for (i = 0; i < NPRIMES; i++) {
- p = dev_primes[i];
- while (dev_rate_div % p == 0 && dev_round_div % p == 0) {
- dev_rate_div /= p;
- dev_round_div /= p;
- }
- }
- return 1;
-}
-
-void
-dev_roundrate(unsigned *newrate, unsigned *newround)
+unsigned
+dev_roundof(unsigned newrate)
{
- *newrate += dev_rate_div - 1;
- *newrate -= *newrate % dev_rate_div;
- *newround = *newrate * dev_round_div / dev_rate_div;
+ return (dev_round * newrate + dev_rate / 2) / dev_rate;
}
/*
@@ -94,14 +43,13 @@ dev_roundrate(unsigned *newrate, unsigned *newround)
*/
void
dev_init(char *devpath,
- struct aparams *dipar, struct aparams *dopar,
- unsigned bufsz, int blkio)
+ struct aparams *dipar, struct aparams *dopar, unsigned bufsz)
{
struct aparams ipar, opar;
struct aproc *conv;
struct abuf *buf;
unsigned nfr, ibufsz, obufsz;
-
+
/*
* ask for 1/4 of the buffer for the kernel ring and
* limit the block size to 1/4 of the requested buffer
@@ -109,13 +57,10 @@ dev_init(char *devpath,
dev_bufsz = (bufsz + 3) / 4;
dev_round = (bufsz + 3) / 4;
dev_file = (struct file *)safile_new(&safile_ops, devpath,
- dipar, dopar, &dev_bufsz, &dev_round, blkio);
+ dipar, dopar, &dev_bufsz, &dev_round);
if (!dev_file)
exit(1);
- if (!dev_setrate(dipar ? dipar->rate : dopar->rate))
- exit(1);
if (dipar) {
- dipar->rate = dev_rate;
#ifdef DEBUG
if (debug_level > 0) {
fprintf(stderr, "dev_init: hw recording ");
@@ -123,9 +68,9 @@ dev_init(char *devpath,
fprintf(stderr, "\n");
}
#endif
+ dev_rate = dipar->rate;
}
if (dopar) {
- dopar->rate = dev_rate;
#ifdef DEBUG
if (debug_level > 0) {
fprintf(stderr, "dev_init: hw playing ");
@@ -133,6 +78,7 @@ dev_init(char *devpath,
fprintf(stderr, "\n");
}
#endif
+ dev_rate = dopar->rate;
}
ibufsz = obufsz = dev_bufsz;
bufsz = (bufsz > dev_bufsz) ? bufsz - dev_bufsz : 0;
@@ -406,14 +352,14 @@ dev_attach(char *name,
struct abuf *pbuf = NULL, *rbuf = NULL;
struct aparams ipar, opar;
struct aproc *conv;
- unsigned nfr;
-
+ unsigned round, nblk;
+
if (ibuf) {
ipar = *sipar;
- pbuf = LIST_FIRST(&dev_mix->obuflist);
+ pbuf = LIST_FIRST(&dev_mix->obuflist);
+ nblk = (dev_bufsz / dev_round + 3) / 4;
+ round = dev_roundof(ipar.rate);
if (!aparams_eqenc(&ipar, &dev_opar)) {
- nfr = (dev_bufsz + 3) / 4 + dev_round - 1;
- nfr -= nfr % dev_round;
conv = dec_new(name, &ipar);
ipar.bps = dev_opar.bps;
ipar.bits = dev_opar.bits;
@@ -421,26 +367,23 @@ dev_attach(char *name,
ipar.le = dev_opar.le;
ipar.msb = dev_opar.msb;
aproc_setin(conv, ibuf);
- ibuf = abuf_new(nfr, &ipar);
+ ibuf = abuf_new(nblk * round, &ipar);
aproc_setout(conv, ibuf);
}
if (!aparams_subset(&ipar, &dev_opar)) {
- nfr = (dev_bufsz + 3) / 4 + dev_round - 1;
- nfr -= nfr % dev_round;
conv = cmap_new(name, &ipar, &dev_opar);
ipar.cmin = dev_opar.cmin;
ipar.cmax = dev_opar.cmax;
aproc_setin(conv, ibuf);
- ibuf = abuf_new(nfr, &ipar);
+ ibuf = abuf_new(nblk * round, &ipar);
aproc_setout(conv, ibuf);
}
if (!aparams_eqrate(&ipar, &dev_opar)) {
- nfr = (dev_bufsz + 3) / 4 + dev_round - 1;
- nfr -= nfr % dev_round;
- conv = resamp_new(name, &ipar, &dev_opar);
+ conv = resamp_new(name, round, dev_round);
ipar.rate = dev_opar.rate;
+ round = dev_round;
aproc_setin(conv, ibuf);
- ibuf = abuf_new(nfr, &ipar);
+ ibuf = abuf_new(nblk * round, &ipar);
aproc_setout(conv, ibuf);
}
aproc_setin(dev_mix, ibuf);
@@ -452,9 +395,9 @@ dev_attach(char *name,
if (obuf) {
opar = *sopar;
rbuf = LIST_FIRST(&dev_sub->ibuflist);
+ round = dev_roundof(opar.rate);
+ nblk = (dev_bufsz / dev_round + 3) / 4;
if (!aparams_eqenc(&opar, &dev_ipar)) {
- nfr = (dev_bufsz + 3) / 4 + dev_round - 1;
- nfr -= nfr % dev_round;
conv = enc_new(name, &opar);
opar.bps = dev_ipar.bps;
opar.bits = dev_ipar.bits;
@@ -462,26 +405,23 @@ dev_attach(char *name,
opar.le = dev_ipar.le;
opar.msb = dev_ipar.msb;
aproc_setout(conv, obuf);
- obuf = abuf_new(nfr, &opar);
+ obuf = abuf_new(nblk * round, &opar);
aproc_setin(conv, obuf);
}
if (!aparams_subset(&opar, &dev_ipar)) {
- nfr = (dev_bufsz + 3) / 4 + dev_round - 1;
- nfr -= nfr % dev_round;
conv = cmap_new(name, &dev_ipar, &opar);
opar.cmin = dev_ipar.cmin;
opar.cmax = dev_ipar.cmax;
aproc_setout(conv, obuf);
- obuf = abuf_new(nfr, &opar);
+ obuf = abuf_new(nblk * round, &opar);
aproc_setin(conv, obuf);
}
if (!aparams_eqrate(&opar, &dev_ipar)) {
- nfr = (dev_bufsz + 3) / 4 + dev_round - 1;
- nfr -= nfr % dev_round;
- conv = resamp_new(name, &dev_ipar, &opar);
+ conv = resamp_new(name, dev_round, round);
opar.rate = dev_ipar.rate;
+ round = dev_round;
aproc_setout(conv, obuf);
- obuf = abuf_new(nfr, &opar);
+ obuf = abuf_new(nblk * round, &opar);
aproc_setin(conv, obuf);
}
aproc_setout(dev_sub, obuf);
diff --git a/usr.bin/aucat/dev.h b/usr.bin/aucat/dev.h
index a131064d2c1..5933f5c7f46 100644
--- a/usr.bin/aucat/dev.h
+++ b/usr.bin/aucat/dev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.h,v 1.7 2008/11/16 16:30:22 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.8 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -27,8 +27,8 @@ extern unsigned dev_rate_div, dev_round_div;
extern struct aparams dev_ipar, dev_opar;
extern struct aproc *dev_mix, *dev_sub, *dev_rec, *dev_play;
-void dev_roundrate(unsigned *, unsigned *);
-void dev_init(char *, struct aparams *, struct aparams *, unsigned, int);
+unsigned dev_roundof(unsigned);
+void dev_init(char *, struct aparams *, struct aparams *, unsigned);
void dev_start(void);
void dev_stop(void);
void dev_run(int);
diff --git a/usr.bin/aucat/safile.c b/usr.bin/aucat/safile.c
index 0f4d2673e2a..775d451a6aa 100644
--- a/usr.bin/aucat/safile.c
+++ b/usr.bin/aucat/safile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safile.c,v 1.4 2008/11/08 10:40:52 ratchov Exp $ */
+/* $OpenBSD: safile.c,v 1.5 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -61,101 +61,6 @@ struct fileops safile_ops = {
safile_revents
};
-/*
- * list of (rate, block-size) pairs ordered by frequency preference and
- * then by block size preference (except for jumbo block sizes that are
- * less prefered than anything else).
- */
-struct blkdesc {
- unsigned rate; /* sample rate */
- unsigned round; /* usable block sizes */
-} blkdesc[] = {
- { 44100, 882 },
- { 44100, 840 },
- { 44100, 441 },
- { 44100, 420 },
- { 44100, 1764 },
- { 44100, 1680 },
- { 48000, 960 },
- { 48000, 768 },
- { 48000, 480 },
- { 48000, 384 },
- { 48000, 1920 },
- { 48000, 1536 },
- { 32000, 640 },
- { 32000, 512 },
- { 32000, 320 },
- { 32000, 256 },
- { 32000, 1280 },
- { 32000, 1024 },
- { 44100, 2940 },
- { 48000, 2976 },
- { 32000, 3200 },
- { 8000, 320 },
- { 8000, 256 },
- { 0, 0 }
-};
-
-
-int
-safile_trypar(struct sio_hdl *hdl, struct sio_par *par, int blkio)
-{
- struct blkdesc *d;
- struct sio_par np;
- unsigned rate = par->rate;
- unsigned round = par->round;
-
- if (!blkio) {
- DPRINTF("safile_trypar: not setting block size\n");
- if (!sio_setpar(hdl, par))
- return 0;
- if (!sio_getpar(hdl, par))
- return 0;
- return 1;
- }
-
- /*
- * find the rate we want to use
- */
- for (d = blkdesc;; d++) {
- if (d->rate == 0) {
- d = blkdesc;
- break;
- }
- if (d->rate == rate)
- break;
- }
-
- /*
- * find the first matching entry, (the blkdesc array is)
- * sorted by order of preference)
- */
- for (;; d++) {
- if (d->rate == 0)
- break;
- if (d->round > round)
- continue;
- par->rate = d->rate;
- par->round = d->round;
- if (!sio_setpar(hdl, par))
- return 0;
- if (!sio_getpar(hdl, &np))
- return 0;
- if (np.rate == d->rate && np.round == d->round) {
- *par = np;
- if (d->round >= d->rate / 15)
- fprintf(stderr,
- "Warning: using jumbo block size, "
- "try to use another sample rate.\n");
- return 1;
- }
- DPRINTF("safile_trypar: %uHz/%ufr failed, got %uHz/%ufr\n",
- d->rate, d->round, np.rate, np.round);
- }
- fprintf(stderr, "Couldn't set block size to <%u frames.\n", round);
- return 0;
-}
-
void
safile_cb(void *addr, int delta)
{
@@ -180,7 +85,7 @@ safile_cb(void *addr, int delta)
struct safile *
safile_new(struct fileops *ops, char *path,
struct aparams *ipar, struct aparams *opar,
- unsigned *bufsz, unsigned *round, int blkio)
+ unsigned *bufsz, unsigned *round)
{
struct sio_par par;
struct sio_hdl *hdl;
@@ -222,8 +127,10 @@ safile_new(struct fileops *ops, char *path,
par.pchan = opar->cmax - opar->cmin + 1;
par.bufsz = *bufsz;
par.round = *round;
- if (!safile_trypar(hdl, &par, blkio))
- exit(1);
+ if (!sio_setpar(hdl, &par))
+ return 0;
+ if (!sio_getpar(hdl, &par))
+ return 0;
if (ipar) {
ipar->bits = par.bits;
ipar->bps = par.bps;
diff --git a/usr.bin/aucat/safile.h b/usr.bin/aucat/safile.h
index ff1eb65eb6e..795e59b376e 100644
--- a/usr.bin/aucat/safile.h
+++ b/usr.bin/aucat/safile.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: safile.h,v 1.2 2008/11/07 21:01:15 ratchov Exp $ */
+/* $OpenBSD: safile.h,v 1.3 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -23,7 +23,7 @@ struct safile;
struct aparams;
struct safile *safile_new(struct fileops *, char *,
- struct aparams *, struct aparams *, unsigned *, unsigned *, int);
+ struct aparams *, struct aparams *, unsigned *, unsigned *);
extern struct fileops safile_ops;
diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c
index c3e652b0ade..a924bc89e01 100644
--- a/usr.bin/aucat/sock.c
+++ b/usr.bin/aucat/sock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.c,v 1.8 2008/11/17 07:04:13 ratchov Exp $ */
+/* $OpenBSD: sock.c,v 1.9 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -567,7 +567,7 @@ int
sock_setpar(struct sock *f)
{
struct amsg_par *p = &f->rmsg.u.par;
- unsigned minbuf, maxbuf;
+ unsigned min, max, rate;
if (AMSG_ISSET(p->mode)) {
if ((p->mode & ~(AMSG_PLAY | AMSG_REC)) || p->mode == 0) {
@@ -632,13 +632,12 @@ sock_setpar(struct sock *f)
p->rate = RATE_MIN;
if (p->rate > RATE_MAX)
p->rate = RATE_MAX;
- dev_roundrate(&p->rate, &f->round);
+ f->round = dev_roundof(p->rate);
f->rpar.rate = f->wpar.rate = p->rate;
- if (f->mode & AMSG_PLAY)
- f->bufsz = 2 * dev_bufsz * f->rpar.rate / dev_rate;
- else
- f->bufsz = 2 * dev_bufsz * f->wpar.rate / dev_rate;
- DPRINTF("sock_setpar: rate -> %u\n", p->rate);
+ if (!AMSG_ISSET(p->bufsz))
+ p->bufsz = 2 * dev_bufsz / dev_round * f->round;
+ DPRINTF("sock_setpar: rate -> %u, round -> %u\n",
+ p->rate, f->round);
}
if (AMSG_ISSET(p->xrun)) {
if (p->xrun != AMSG_IGNORE &&
@@ -651,24 +650,18 @@ sock_setpar(struct sock *f)
DPRINTF("sock_setpar: xrun -> %u\n", f->xrun);
}
if (AMSG_ISSET(p->bufsz)) {
- minbuf = 3 * dev_bufsz / 2;
- minbuf -= minbuf % dev_round;
- maxbuf = dev_bufsz;
- if (f->mode & AMSG_PLAY) {
- minbuf = minbuf * f->rpar.rate / dev_rate;
- maxbuf = maxbuf * f->rpar.rate / dev_rate;
- maxbuf += f->rpar.rate;
- } else {
- minbuf = minbuf * f->wpar.rate / dev_rate;
- maxbuf = maxbuf * f->wpar.rate / dev_rate;
- maxbuf += f->wpar.rate;
- }
- if (p->bufsz < minbuf)
- p->bufsz = minbuf;
- if (p->bufsz > maxbuf)
- p->bufsz = maxbuf;
- f->bufsz = p->bufsz + f->round - 1;
- f->bufsz -= f->bufsz % f->round;
+ rate = (f->mode & AMSG_PLAY) ? f->rpar.rate : f->wpar.rate;
+ min = (3 * (dev_bufsz / dev_round) + 1) / 2;
+ max = (dev_bufsz + rate + dev_round - 1) / dev_round;
+ min *= f->round;
+ max *= f->round;
+ p->bufsz += f->round - 1;
+ p->bufsz -= p->bufsz % f->round;
+ if (p->bufsz < min)
+ p->bufsz = min;
+ if (p->bufsz > max)
+ p->bufsz = max;
+ f->bufsz = p->bufsz;
DPRINTF("sock_setpar: bufsz -> %u\n", f->bufsz);
}
#ifdef DEBUG
@@ -786,7 +779,7 @@ sock_execmsg(struct sock *f)
AMSG_INIT(m);
m->cmd = AMSG_GETCAP;
m->u.cap.rate = dev_rate;
- m->u.cap.rate_div = dev_rate_div;
+ m->u.cap.rate_div = dev_rate;
m->u.cap.pchan = dev_mix ?
(f->templ_rpar.cmax - f->templ_rpar.cmin + 1) : 0;
m->u.cap.rchan = dev_sub ?