From 4efdde5a1d2ee922bbc505542edf36562116656e Mon Sep 17 00:00:00 2001 From: Jacob Meuser Date: Tue, 17 Jul 2007 08:35:34 +0000 Subject: 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 ... --- sys/dev/auconv.c | 6 +++--- sys/dev/mulaw.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/auconv.c b/sys/dev/auconv.c index fdacfd764b4..d3d409a2c57 100644 --- a/sys/dev/auconv.c +++ b/sys/dev/auconv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auconv.c,v 1.6 2003/06/27 00:23:43 jason Exp $ */ +/* $OpenBSD: auconv.c,v 1.7 2007/07/17 08:35:33 jakemsr Exp $ */ /* $NetBSD: auconv.c,v 1.3 1999/11/01 18:12:19 augustss Exp $ */ /* @@ -200,7 +200,7 @@ linear16_to_ulinear8_le(void *v, u_char *p, int cc) { u_char *q = p; - while (--cc >= 0) { + while ((cc -= 2) >= 0) { *q++ = p[1] ^ 0x80; p += 2; } @@ -211,7 +211,7 @@ linear16_to_ulinear8_be(void *v, u_char *p, int cc) { u_char *q = p; - while (--cc >= 0) { + while ((cc -= 2) >= 0) { *q++ = p[0] ^ 0x80; p += 2; } 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; -- cgit v1.2.3