diff options
author | cg <cg@FreeBSD.org> | 2001-03-05 16:45:38 +0000 |
---|---|---|
committer | cg <cg@FreeBSD.org> | 2001-03-05 16:45:38 +0000 |
commit | e4893b3d9ab8138f263835b4a903109b61661390 (patch) | |
tree | 15f272289c88edf3b8a75662fc82aab3a39de4b4 /sys/dev/sound | |
parent | 8da20439de98748cb1ee9d2bd1b2f5d7cbd8332c (diff) | |
download | FreeBSD-src-e4893b3d9ab8138f263835b4a903109b61661390.zip FreeBSD-src-e4893b3d9ab8138f263835b4a903109b61661390.tar.gz |
MFS: don't pagefault in sndbuf_clear
Diffstat (limited to 'sys/dev/sound')
-rw-r--r-- | sys/dev/sound/pcm/buffer.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c index 81b4037..9a28054 100644 --- a/sys/dev/sound/pcm/buffer.c +++ b/sys/dev/sound/pcm/buffer.c @@ -94,37 +94,27 @@ void sndbuf_clear(snd_dbuf *b, int length) { int i; - u_int16_t data, *p; + u_char data, *p; if (length == 0) return; + if (length > b->bufsize) + length = b->bufsize; if (b->fmt & AFMT_SIGNED) data = 0x00; else data = 0x80; - if (b->fmt & AFMT_16BIT) - data <<= 8; - else - data |= data << 8; - - if (b->fmt & AFMT_BIGENDIAN) - data = ((data >> 8) & 0x00ff) | ((data << 8) & 0xff00); - i = b->fp; - p = (u_int16_t *)(b->buf + b->fp); - while (length > 1) { - *p++ = data; - length -= 2; - i += 2; - if (i >= b->bufsize) { - p = (u_int16_t *)b->buf; + p = b->buf; + while (length > 0) { + p[i] = data; + length--; + i++; + if (i >= b->bufsize) i = 0; - } } - if (length == 1) - *(b->buf + i) = data & 0xff; } void |