summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm/channel.c
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2001-01-24 01:15:50 +0000
committercg <cg@FreeBSD.org>2001-01-24 01:15:50 +0000
commit2cc907a0c75b3a8e08c1f544e6012dbdf1caf5d9 (patch)
tree817cceca2616ab9dfe5b92efadfbb38d6d6febe6 /sys/dev/sound/pcm/channel.c
parentfa0d2b97b0799d27897da985f1129e635785cd1e (diff)
downloadFreeBSD-src-2cc907a0c75b3a8e08c1f544e6012dbdf1caf5d9.zip
FreeBSD-src-2cc907a0c75b3a8e08c1f544e6012dbdf1caf5d9.tar.gz
prevent excessively small buffer sizes resulting in hundreds of irqs per
second
Diffstat (limited to 'sys/dev/sound/pcm/channel.c')
-rw-r--r--sys/dev/sound/pcm/channel.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index 36a1e72..f11ac07 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1211,17 +1211,20 @@ chn_setblocksize(pcm_channel *c, int blkcnt, int blksz)
if (blksz == 0 || blksz == -1) {
if (blksz == -1)
c->flags &= ~CHN_F_HAS_SIZE;
- if (c->flags & CHN_F_HAS_SIZE)
- return 0;
- blksz = (bs->bps * bs->spd) / CHN_DEFAULT_HZ;
- tmp = 32;
- while (tmp <= blksz)
- tmp <<= 1;
- tmp >>= 1;
- blksz = tmp;
-
- RANGE(blksz, 16, CHN_2NDBUFMAXSIZE / 2);
- RANGE(blkcnt, 2, CHN_2NDBUFMAXSIZE / blksz);
+ if (!(c->flags & CHN_F_HAS_SIZE)) {
+ blksz = (bs->bps * bs->spd) / CHN_DEFAULT_HZ;
+ tmp = 32;
+ while (tmp <= blksz)
+ tmp <<= 1;
+ tmp >>= 1;
+ blksz = tmp;
+
+ RANGE(blksz, 16, CHN_2NDBUFMAXSIZE / 2);
+ RANGE(blkcnt, 2, CHN_2NDBUFMAXSIZE / blksz);
+ } else {
+ blksz = bs->blksz;
+ blkcnt = bs->blkcnt;
+ }
} else {
if ((blksz < 16) || (blkcnt < 2) || (blkcnt * blksz > CHN_2NDBUFMAXSIZE))
return EINVAL;
@@ -1247,8 +1250,7 @@ chn_setblocksize(pcm_channel *c, int blkcnt, int blksz)
/* adjust for different hw format/speed */
irqhz = (bs->bps * bs->spd) / bs->blksz;
- if (irqhz < 16)
- irqhz = 16;
+ RANGE(irqhz, 16, 512);
b->blksz = (b->bps * b->spd) / irqhz;
OpenPOWER on IntegriCloud