aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2003-08-23 13:00:48 +0000
committerIan Dowse <iedowse@FreeBSD.org>2003-08-23 13:00:48 +0000
commit3944d0ff3582457fa84132004a56479eae7f5a6b (patch)
tree0a5a92f86327e05b9b16db73c231f1c91a5b8eed /sys
parent72d173fa8f2ee3065520232d19204b4e17a87c10 (diff)
downloadsrc-3944d0ff3582457fa84132004a56479eae7f5a6b.tar.gz
src-3944d0ff3582457fa84132004a56479eae7f5a6b.zip
When calculating the block size to use for a particular sample rate,
round the result up to a multiple of 4 bytes so that it will always be a multiple of the sample size. Also use the actual buffer size from sc->bufsz instead of the default DS1_BUFFSIZE. This fixes panics and bad distortion I have seen on Yamaha DS-1 hardware, mainly when playing certain Real Audio media. Reviewed by: orion (an earlier version of the patch)
Notes
Notes: svn path=/head/; revision=119362
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/sound/pci/ds1.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/dev/sound/pci/ds1.c b/sys/dev/sound/pci/ds1.c
index 4acec376d7f0..dad3015215a5 100644
--- a/sys/dev/sound/pci/ds1.c
+++ b/sys/dev/sound/pci/ds1.c
@@ -526,12 +526,13 @@ static int
ds1pchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
{
struct sc_pchinfo *ch = data;
+ struct sc_info *sc = ch->parent;
int drate;
/* irq rate is fixed at 187.5hz */
drate = ch->spd * sndbuf_getbps(ch->buffer);
- blocksize = (drate << 8) / DS1_IRQHZ;
- sndbuf_resize(ch->buffer, DS1_BUFFSIZE / blocksize, blocksize);
+ blocksize = roundup2((drate << 8) / DS1_IRQHZ, 4);
+ sndbuf_resize(ch->buffer, sc->bufsz / blocksize, blocksize);
return blocksize;
}
@@ -653,12 +654,13 @@ static int
ds1rchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
{
struct sc_rchinfo *ch = data;
+ struct sc_info *sc = ch->parent;
int drate;
/* irq rate is fixed at 187.5hz */
drate = ch->spd * sndbuf_getbps(ch->buffer);
- blocksize = (drate << 8) / DS1_IRQHZ;
- sndbuf_resize(ch->buffer, DS1_BUFFSIZE / blocksize, blocksize);
+ blocksize = roundup2((drate << 8) / DS1_IRQHZ, 4);
+ sndbuf_resize(ch->buffer, sc->bufsz / blocksize, blocksize);
return blocksize;
}