diff options
author | cg <cg@FreeBSD.org> | 2002-01-23 05:49:41 +0000 |
---|---|---|
committer | cg <cg@FreeBSD.org> | 2002-01-23 05:49:41 +0000 |
commit | cf26ea42fd009af35fc31eb00100c30d6f19c6f7 (patch) | |
tree | f8e3fae9bef0d458b7de7ce9e63748bdfdb93395 | |
parent | 90da3073ce3856f4f7cf564f8c5ec13826dc3024 (diff) | |
download | FreeBSD-src-cf26ea42fd009af35fc31eb00100c30d6f19c6f7.zip FreeBSD-src-cf26ea42fd009af35fc31eb00100c30d6f19c6f7.tar.gz |
print warnings if a pcm*.buffersize hint is out of range or a non-power-of-2
-rw-r--r-- | sys/dev/sound/pcm/sound.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index ddbf662..215e288 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -567,13 +567,27 @@ unsigned int pcm_getbuffersize(device_t dev, unsigned int min, unsigned int deflt, unsigned int max) { struct snddev_info *d = device_get_softc(dev); - int sz; + int sz, x; sz = 0; - if (resource_int_value(device_get_name(dev), device_get_unit(dev), "buffersize", &sz) == 0) + if (resource_int_value(device_get_name(dev), device_get_unit(dev), "buffersize", &sz) == 0) { + x = sz; RANGE(sz, min, max); - else + if (x != sz) + device_printf(dev, "'buffersize=%d' hint is out of range (%d-%d), using %d\n", x, min, max, sz); + x = min; + while (x < sz) + x <<= 1; + if (x > sz) + x >>= 1; + if (x != sz) { + device_printf(dev, "'buffersize=%d' hint is not a power of 2, using %d\n", sz, x); + sz = x; + } + } else { sz = deflt; + } + d->bufsz = sz; return sz; |