diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2007-07-17 08:35:34 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2007-07-17 08:35:34 +0000 |
commit | 4efdde5a1d2ee922bbc505542edf36562116656e (patch) | |
tree | 78cbe7354d6e9f106b6444ad21275aebc4a208fa /sys/dev/mulaw.c | |
parent | 4d3fa876369d0d30db6f16ec46ac4091f9e1477c (diff) |
when looping through an array and advancing your pointer to the array
2x on each loop, only loop .5x times
fixes hard hangs on i386 and "hiccups" on sgi when these functions are
used through e.g. dd if=/dev/audio of=foo, since mulaw is the default
encoding.
the commit history wrt this code is interesting. I am responsible for
introducing this braindamage to OpenBSD ... and note that
linear16_to_linear8_[lb]e had it right ...
Diffstat (limited to 'sys/dev/mulaw.c')
-rw-r--r-- | sys/dev/mulaw.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c index 11d636643d5..3b7d09b240b 100644 --- a/sys/dev/mulaw.c +++ b/sys/dev/mulaw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mulaw.c,v 1.12 2005/04/14 01:24:20 pascoe Exp $ */ +/* $OpenBSD: mulaw.c,v 1.13 2007/07/17 08:35:33 jakemsr Exp $ */ /* $NetBSD: mulaw.c,v 1.15 2001/01/18 20:28:20 jdolecek Exp $ */ /* @@ -363,7 +363,7 @@ slinear16_to_mulaw_le(void *v, u_char* p, int cc) { u_char *q = p + 1; /* q points higher byte. */ - while (--cc >= 0) { + while ((cc-= 2) >= 0) { *p++ = lintomulaw[*q ^ 0x80]; q +=2 ; } @@ -490,7 +490,7 @@ slinear16_to_alaw_le(void *v, u_char *p, int cc) { u_char *q = p; - while (--cc >= 0) { + while ((cc -= 2) >= 0) { *p = lintoalaw[q[1] ^ 0x80]; ++p; q += 2; @@ -503,7 +503,7 @@ slinear16_to_alaw_be(void *v, u_char *p, int cc) { u_char *q = p; - while (--cc >= 0) { + while ((cc -= 2) >= 0) { *p = lintoalaw[q[0] ^ 0x80]; ++p; q += 2; |