diff options
Diffstat (limited to 'sys/dev/sound/pcm/sound.c')
-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; |