Subject: Re: eap(4) and ess(4) and mixer volume values
To: None <tech-kern@netbsd.org>
From: Matthias Scheler <tron@zhadum.de>
List: tech-kern
Date: 08/16/2000 07:28:38
In article <8ndd8h$hsl$1@colwyn.zhadum.de>,
tron@zhadum.de (Matthias Scheler) writes:
> Yes, and that happens:
>
> i TO_OSSVOL(i) FROM_OSSVOL(TO_OSSVOL(i))
> 000 000 000
> 001 000 000
> 002 000 000(*)
> 003 001 002
> 004 001 002
> 005 001 002(*)
> 006 002 005
> 007 002 005(*)
> 008 003 007
> 009 003 007
> 010 003 007
> 011 004 010
> [...]
>
> We should improve the conversion formula so that the values marked
> with (*) return the value of the next conversion.
Ok, here is my fix:
Index: ossaudio.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libossaudio/ossaudio.c,v
retrieving revision 1.11
diff -u -r1.11 ossaudio.c
--- ossaudio.c 2000/07/04 09:56:14 1.11
+++ ossaudio.c 2000/08/16 07:25:37
@@ -54,8 +54,8 @@
#define GET_DEV(com) ((com) & 0xff)
-#define TO_OSSVOL(x) ((x) * 100 / 255)
-#define FROM_OSSVOL(x) (((x) > 100 ? 100 : (x)) * 255 / 100)
+#define TO_OSSVOL(x) ((int)(((x) * 100.0 / 255.0) + 0.5))
+#define FROM_OSSVOL(x) ((int)((((x) > 100 ? 100 : (x)) * 255.0 / 100.0) + 0.5))
static struct audiodevinfo *getdevinfo(int);
After the patch the above table looks like this:
i TO_OSSVOL(i) FROM_OSSVOL(TO_OSSVOL(i))
000 000 000
001 000 000
002 001 003
003 001 003
004 002 005
005 002 005
006 002 005
007 003 008
008 003 008
009 004 010
010 004 010
011 004 010
The conversion is stable now, an endless loop iteration of "TO_OSSVOL"
and "FROM_OSSVOL" will lead to a value > 0.
>> Maybe the right thing to do is to let the OSS emulation remember what
>> values you have set and return them.
>
> How do you want to do that? The OSS library would have to track the used
> audio devices.
After giving that idea some thought I consider it bad. As a result an
application wouldn't notice any more that another application changed
the volume.
Any objection to commit the patch above?
Kind regards
--
Matthias Scheler http://www.sighardstrasse.de/~tron/