9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Jacob Moody <jsmoody@iastate.edu>
To: 9front@9front.org
Subject: [drawterm] windows devaudio volume control
Date: Wed, 19 Jun 2019 10:12:08 -0500	[thread overview]
Message-ID: <CA+gzr0KrLd=5wVkfrt+zin0FXBK8FN3yYD_iOBwkNe9ayOCbOQ@mail.gmail.com> (raw)

All,

I worked on a quick patch for drawterm devaudio-win32.c to allow for
setting the application volume.

diff -r 5c953ddd29fa kern/devaudio-win32.c
--- a/kern/devaudio-win32.c    Sat Mar 09 20:51:48 2019 +0100
+++ b/kern/devaudio-win32.c    Wed Jun 19 10:07:37 2019 -0500
@@ -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


Thanks,
Moody


                 reply	other threads:[~2019-06-19 15:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+gzr0KrLd=5wVkfrt+zin0FXBK8FN3yYD_iOBwkNe9ayOCbOQ@mail.gmail.com' \
    --to=jsmoody@iastate.edu \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).