Re: New meaning oss_sysinfo.nummixers

From: Alfonso Sabato Siciliano <alfix86_at_gmail.com>
Date: Sat, 05 Oct 2024 19:52:58 UTC
Hello,

On Sat, 5 Oct 2024 at 20:11, Christos Margiolis <christos@freebsd.org>
wrote:

> Hello Alfonso,
>
> Alfonso Sabato Siciliano wrote:
> > I was inactive for months, one week ago I reinstalled CURRENT on my main
> > laptop (and others). The meaning of "struct oss_sysinfo.nummixers"
> > changed. Let's say:
> >
> > [...]
> >
> > Output "nummixers: 7", But
> >
> > % sysctl dev.pcm
> > ... prints 6 devices dev.pcm.[0-5].*
> >
> > % ls /dev/mixer*
> > /dev/mixer0 /dev/mixer1 /dev/mixer2 /dev/mixer3 /dev/mixer4 /dev/mixer5
> >
> > 6 mixers from 0 to 5. But now oss_sysinfo.nummixers is 7, it was 6 until
> > some months ago.
> >
> > I thought the new value could be the max index, in the case some mixers
> > are closed, example /dev/mixer0 /dev/mixer2 /dev/mixer5. But in this
> > case 'nummixers' should be 5 not 7.
> >
> > Maybe the hidden /dev/mixer is in the count (6 + 1 = 7).
> >
> > Same situation on 3 laptops. So, what is the new meaning for
> > oss_sysinfo.nummixers?
>
> The behavior changed in the following commit of mine: 5d980fadf73d
> ("sound: Handle unavailable devices in various OSS IOCTLs") [1].
> The commit message explains the rationale behind changing this
> behavior. I am aware it's a bit quite unintuitive, but it solves quite a
> few bugs we have with people using nummixers to loop through mixer
> devices, which I suppose is the most typical use.
>
>
Ok, I understood the point of the commit.


> oss_sysinfo.nummixers now is simply populated with whatever
> devclass_get_maxunit(pcm_devclass) returns, which should be the _next_
> maximum unit number that will be allocated for an audio device, hence
> the 7 you get (this is how devclass_get_maxunit() works in general).
>
>
Here is my doubt, (probably) I don't understand "_next_ maximum unit
number", in this case my _next_ should be 6 not 7. Same on other 2 laptops.
Actually, I was referred to this change because I am receiving several
private emails for mixertui, when users run F6 can see a suddenly
extra pcm (unreal /dev/mixer<n+1>).

Anyway, now it is not a problem, I am going to handle it in userspace.
I'll take a look at devclass_get_maxunit() in the future.

Although a bit tedious, you can count the actual number of mixers in the
> system by issuing open(2) for each /dev/mixer<n> and seeing which ones
> succeed. This way you know the total number, but also which mixers
> specifically are present.
>
> Christos
>
> [1]
> https://cgit.freebsd.org/src/commit/?id=5d980fadf73df64a1e0eda40a93170ed76ce6f14



OK.

Best regards,
Alfonso