shithub: drawterm

Download patch

ref: 748142a97c32cd48a8df7e354b40d9638e27ae38
parent: bcbb3563b4341791753a50a6dff3f6cd2aab0620
author: 23hiro <23hiro@gmail.com>
date: Tue Sep 24 18:53:20 EDT 2019

win32: audio scale fix (thanks Jacob Moody)

--- a/kern/devaudio-win32.c
+++ b/kern/devaudio-win32.c
@@ -54,9 +54,9 @@
 {
 	DWORD v;
 
-	//Windows uses a 0-255 scale, plan9 uses 0-100
-	v = right*0xFF/100;
-	v = (v<<8)|left*0xFF/100;
+	//Windows uses a 0-0xFFFF scale, plan9 uses 0-100
+	v = right*0xFFFF/100;
+	v = (v<<16)|(left*0xFFFF/100);
 	if(waveOutSetVolume(waveout, v) != MMSYSERR_NOERROR)
 		oserror();
 }
@@ -68,8 +68,8 @@
 
 	if(waveOutGetVolume(waveout, &v) != MMSYSERR_NOERROR)
 		oserror();
-	*left = (v&0xFF)*100/0xFF;
-	*right = ((v>>8)&0xFF)*100/0xFF;
+	*left = (v&0xFFFF)*100/0xFFFF;
+	*right = ((v>>16)&0xFFFF)*100/0xFFFF;
 }
 
 int