code: drawterm

Download patch

ref: bcbb3563b4341791753a50a6dff3f6cd2aab0620
parent: 5f074880c5c2cd8a23883271bb7e27939e769186
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jun 19 13:34:27 EDT 2019

devaudio: implement volume setting for win32 (thanks jsmoody)

--- a/kern/devaudio-win32.c
+++ b/kern/devaudio-win32.c
@@ -52,19 +52,24 @@
 void
 audiodevsetvol(int what, int left, int right)
 {
-	USED(what);
-	USED(left);
-	USED(right);
-	error("not supported");
+	DWORD v;
+
+	//Windows uses a 0-255 scale, plan9 uses 0-100
+	v = right*0xFF/100;
+	v = (v<<8)|left*0xFF/100;
+	if(waveOutSetVolume(waveout, v) != MMSYSERR_NOERROR)
+		oserror();
 }
 
 void
 audiodevgetvol(int what, int *left, int *right)
 {
-	USED(what);
-	USED(left);
-	USED(right);
-	error("not supported");
+	DWORD v;
+
+	if(waveOutGetVolume(waveout, &v) != MMSYSERR_NOERROR)
+		oserror();
+	*left = (v&0xFF)*100/0xFF;
+	*right = ((v>>8)&0xFF)*100/0xFF;
 }
 
 int