Module Name:    src
Committed By:   jmcneill
Date:           Sun Nov 23 12:23:25 UTC 2014

Modified Files:
        src/sys/dev: auvolconv.c

Log Message:
When this code was split from dev/pad, the "volume" member size was changed
from u_int to uint8_t. This had the unfortunate side-effect of introducing
an integer overflow when adjusting samples as the largest type used was now
int16_t. This change copies the volume level to a temporary u_int and uses
that in the calculation. Should fix recent failures with the
dev/audio/t_pad/pad_output test.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/auvolconv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/auvolconv.c
diff -u src/sys/dev/auvolconv.c:1.1 src/sys/dev/auvolconv.c:1.2
--- src/sys/dev/auvolconv.c:1.1	Tue Nov 18 01:53:17 2014
+++ src/sys/dev/auvolconv.c	Sun Nov 23 12:23:25 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: auvolconv.c,v 1.1 2014/11/18 01:53:17 jmcneill Exp $ */
+/* $NetBSD: auvolconv.c,v 1.2 2014/11/23 12:23:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvolconv.c,v 1.1 2014/11/18 01:53:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvolconv.c,v 1.2 2014/11/23 12:23:25 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -49,10 +49,12 @@ auvolconv_slinear16_le_fetch_to(struct a
 	stream_filter_t *this;
 	int16_t j, *wp;
 	int m, err;
+	u_int vol;
 
 	pf = (auvolconv_filter_t *)self;
 	this = &pf->base;
 	max_used = (max_used + 1) & ~1;
+	vol = *pf->vol;
 
 	if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used)))
 		return err;
@@ -61,7 +63,7 @@ auvolconv_slinear16_le_fetch_to(struct a
 	FILTER_LOOP_PROLOGUE(this->src, 2, dst, 2, m) {
 		j = le16dec(s);
 		wp = (int16_t *)d;
-		le16enc(wp, (j * *pf->vol) / 255);
+		le16enc(wp, (j * vol) / 255);
 	} FILTER_LOOP_EPILOGUE(this->src, dst);
 
 	return 0;
@@ -75,10 +77,12 @@ auvolconv_slinear16_be_fetch_to(struct a
 	stream_filter_t *this;
 	int16_t j, *wp;
 	int m, err;
+	u_int vol;
 
 	pf = (auvolconv_filter_t *)self;
 	this = &pf->base;
 	max_used = (max_used + 1) & ~1;
+	vol = *pf->vol;
 
 	if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used)))
 		return err;
@@ -87,7 +91,7 @@ auvolconv_slinear16_be_fetch_to(struct a
 	FILTER_LOOP_PROLOGUE(this->src, 2, dst, 2, m) {
 		j = be16dec(s);
 		wp = (int16_t *)d;
-		be16enc(wp, (j * *pf->vol) / 255);
+		be16enc(wp, (j * vol) / 255);
 	} FILTER_LOOP_EPILOGUE(this->src, dst);
 
 	return 0;

Reply via email to