All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Guthrie <gmane@colin.guthr.ie>
To: alsa-devel@alsa-project.org
Subject: Re: Bug in alsa-lib or alsamixer and amixer
Date: Wed, 16 Jun 2010 22:47:38 +0100	[thread overview]
Message-ID: <hvbgo6$3fg$1@dough.gmane.org> (raw)
In-Reply-To: <AANLkTimeqs9dKkCemPzmrdYCboH-uxW5FkfLgiWFZEPl@mail.gmail.com>

'Twas brillig, and Raymond Yau at 16/06/10 07:33 did gyre and gimble:
> 2010/6/16 Colin Guthrie <gmane@colin.guthr.ie>
> 
>> The fact that any key changes it back to 100% is kinda expected. It's
>> not designed to handle values >100% so it makes sense that it clamps it.
>> Annoying, but it makes sense.
>>
>>> The volume range is only from 0 to  65536
>>>
>>> why did alsa-lib allow alsa-pulse plugin to set it outside the range ,
>>> alsamixer and amixer also display 150% ?
>>>
>>> amixer -D pulse
>>> Simple mixer control 'Master',0
>>>   Capabilities: pvolume pswitch pswitch-joined
>>>   Playback channels: Front Left - Front Right
>>>   Limits: Playback 0 - 65536
>>>   Mono:
>>>   Front Left: Playback 98304 [150%] [on]
>>>   Front Right: Playback 98304 [150%] [on]
>>
>>
>> While I agree this could be thought of as a bug, it's actually the
>> nicest possible display for a system that has no concept of volumes > 100%.
>>
>> That said, the correct fix would be a nice mechanism for marking the
>> 100% mark. e.g. specifying the limits as a triplet, lower, normal (aka
>> 100%) and max.
>>
>> AFAIK, no such system is currently in place.
>>
>> An alternative would be to scale the alsa volume control to the full
>> range, e.g. make 0 - 98304[1] the range it accepts. But this sucks as
>> the percentage shown in alsa is not the same as the percentage shown in
>> other GUIs.
>>
>> In a practical sense, the current setup is probably less problematic
>> than the latter suggestion.
>>
>> Col
>>
>> [1] FWIW, this precice value will likely change. I've not yet actioned
>> it but it's likely to be fixed at +11dB which IIRC is slightly above
>> 150%. 11dB is just a figure that we felt was "sensible" with regards to
>> GUI consistency and I'll try and push this out ot all the UIs I can.
>>
>>
>>
> You have made a big mistake , please study the source code of alsamixer and
> amixer

I don't see my "big mistake" to be honest. I'm just describing the
behaviour and stating the fact that I think it's preferable to the
alternatives.

> Simple mixer control 'PCM',0
>   Capabilities: pvolume pswitch pswitch-joined
>   Playback channels: Front Left - Front Right
>   Limits: Playback 0 - 31
>   Mono:
>   Front Left: Playback 31 [100%] [12.00dB] [on]
>   Front Right: Playback 31 [100%] [12.00dB] [on]
> 
> 
>     control.39 {
>         comment.access 'read write'
>         comment.type INTEGER
>         comment.count 2
>         comment.range '0 - 31'
>         comment.dbmin -3450
>         comment.dbmax 1200
>         iface MIXER
>         name 'PCM Playback Volume'
>         value.0 31
>         value.1 31
>     }
> 
> ---------------------------------------------------------------------
> 
> Simple mixer control 'PCM',0
>   Capabilities: pvolume pswitch pswitch-joined
>   Playback channels: Front Left - Front Right
>   Limits: Playback 0 - 31
>   Mono:
>   Front Left: Playback 23 [74%] [0.00dB] [on]
>   Front Right: Playback 23 [74%] [0.00dB] [on]
> 
> 
>     control.39 {
>         comment.access 'read write'
>         comment.type INTEGER
>         comment.count 2
>         comment.range '0 - 31'
>         comment.dbmin -3450
>         comment.dbmax 1200
>         iface MIXER
>         name 'PCM Playback Volume'
>         value.0 23
>         value.1 23
>     }

Like much of the content in many of your posts I don't really see why
the above is especially needed but hey....

> The percentage displayed below the vertical slider in alsamixer and the
> percentage after the dB values are the percentage of the current step / the
> total number of step

Right, so the standard definition of a percentage....

> so you cannot get any percentage > 100% in alsamixer and amixer

I know, that's what I said.

> snd_mixer_selem_get_playback_volume_range()  of PCM return min =0 and max=
> 31
> at 0dB the percentage is 23/32  about 74%  since 0dB is step 23 in  step 0
> -34.5dB , step31 is 12dB (the difference between step is 1.5dB

OK, so in short, you'd be of the opinon that we should scale things so
that the alsa mixer %age display is different to that in PA clients.
That's fine, that's your opinion. Personally, I'm off the opposite
opinion but hey.

> This percentage in alsamixer and amixer is not those volume scale which you
> described  BASE_VOLUME  or PA_NORM

It is PA_VOLUME_NORM. When the value is PA_VOLUME_NORM, the alsamixer is
at 100%. When you go above that, alsa cannot handle it (which is fine,
it wasn't designed to).

So as I said in my original mail there two approaches to this. Scale the
full range of PA volumes to the 100% scale and be done with it (tho' PA
allows a significant amount > PA_VOLUME_NORM (although sensible values
are of course limited - like I said before about +11dB/~150% is about as
much as you'd likely want to go) so that PA_VOUME_NORM in alsa != 100%
unlike in PA clients.... or you add the ability to define different
points on the scale in alsa (e.g. min, base, norm, max) where base ==
norm = max when only two are given for backwards compatibility.

That said, I doubt very much it's worth the effort just to maintain
compatibility with the PA plugin... doesn't really seem worth it to me
as it's just a compatibility layer really and most mixer GUIs that care
about pulse (i.e. the ones you should be using on a system that has
pulse enabled) wont use this layer for their mixer functionality anyway.
I certainly wouldn't loose much sleep over it.


Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

  reply	other threads:[~2010-06-16 21:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 22:29 Bug in alsa-lib or alsamixer and amixer Raymond Yau
2010-06-15 23:07 ` Colin Guthrie
2010-06-16  0:41   ` Raymond Yau
2010-06-16  6:33   ` Raymond Yau
2010-06-16 21:47     ` Colin Guthrie [this message]
2010-06-16 22:09       ` Raymond Yau
2010-06-16 22:36         ` Colin Guthrie
2010-06-16 23:34           ` Raymond Yau
2010-06-17  7:15             ` James Courtier-Dutton
2010-06-19  0:39               ` Raymond Yau
2010-06-19  8:13                 ` Colin Guthrie

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='hvbgo6$3fg$1@dough.gmane.org' \
    --to=gmane@colin.guthr.ie \
    --cc=alsa-devel@alsa-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.