Subject: Re: eap(4) and ess(4) and mixer volume values
To: Matthias Scheler <tron@zhadum.de>
From: Lennart Augustsson <lennart@augustsson.net>
List: tech-kern
Date: 08/16/2000 08:20:43
Matthias Scheler wrote:

> 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))

Could you try ddoing that change so that it uses only integer arithmetic?
There are two places where OSS emulation happens, one is liboss which is
used for packages bbuilt on NetBSD the other is in the kernel for running
Linux binaries.  We can't have floating point used in the kernel.>> 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.

Yes, you are right.


> Any objection to commit the patch above?

Yes, see above.

    -- Lennart