alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: David Henningsson <david.henningsson@canonical.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: alsactl adds volume controls?
Date: Fri, 03 Sep 2010 09:03:15 +0200	[thread overview]
Message-ID: <4C809DB3.9090201@canonical.com> (raw)
In-Reply-To: <s5hmxs0h437.wl%tiwai@suse.de>

2010-09-02 11:44, Takashi Iwai skrev:
> At Thu, 02 Sep 2010 11:24:45 +0200,
> David Henningsson wrote:
>>
>> 2010-09-02 10:06, Takashi Iwai skrev:
>>> At Wed, 01 Sep 2010 15:26:54 +0200,
>>> David Henningsson wrote:
>>>>
>>>> 2010-08-30 15:08, Takashi Iwai skrev:
>>>>> At Mon, 30 Aug 2010 15:01:29 +0200,
>>>>> David Henningsson wrote:
>>>>>>
>>>>>> 2010-08-30 10:01, Takashi Iwai skrev:
>>>>>>> At Sat, 28 Aug 2010 06:58:20 +0800,
>>>>>>> Raymond Yau wrote:
>>>>>>>>
>>>>>>>> 2010/8/28 David Henningsson <david.henningsson@canonical.com>
>>>>>>>>
>>>>>>>>> 2010-08-27 17:43, Clemens Ladisch skrev:
>>>>>>>>>> David Henningsson wrote:
>>>>>>>>>>> So I've discovered that my sound card has a "PCM Playback Volume"
>>>>>>>>>>> control, but changing that control does not alter the volume.
>>>>>>>>>>>
>>>>>>>>>>> Interestingly enough, this control does not come from the HDA parser, it
>>>>>>>>>>> is added by alsactl at boot time...!
>>>>>>>>>>
>>>>>>>>>> This control was created by the software volume plugin.  When not using
>>>>>>>>>> this plugin, the control does not have any effect.
>>>>>>>>>>
>>>>>>>>>> To get rid of it, delete its entry from /etc/asound.state.
>>>>>>>>>
>>>>>>>>> Hmm, I wonder if this is an Ubuntu-specific bug then? Because when I run
>>>>>>>>> Maverick (the upcoming Ubuntu release) from a Live-CD, the "PCM Playback
>>>>>>>>> Volume" control is still there (and there is no asound.state, neither in
>>>>>>>>> /etc or in /var/lib/alsa).
>>>>>>>>> When I use the plughw interface, the "PCM Playback Volume" does not
>>>>>>>>> affect volume output. Should I use another device string to test the
>>>>>>>>> softvol plugin, to see if it's there or not?
>>>>>>>>
>>>>>>>> The softvol plugin it is defined in "front" device in
>>>>>>>> /usr/share/alsa/cards/HDA-Intel.conf
>>>>>>>>
>>>>>>>> reason is some HDA codec does not has any hardware volume control (analog)
>>>>>>>>
>>>>>>>> this user-defined control only effective when the application use "front"
>>>>>>>> device
>>>>>>>
>>>>>>> Hm, but if PA opens the device with SND_PCM_NO_SOFTVOL flag, the
>>>>>>> softvol should be skipped.
>>>>>>
>>>>>> But that does not apply to the mixer controls as well, does it?
>>>>>
>>>>> It does.  The mixer element is created when this kind of PCM stream is
>>>>> opened without SND_PCM_NO_SOFTVOL flag.  Then it leaves the control
>>>>> for the later use, and alsactl saves/restores it.  So, it's a chicken-
>>>>> and-egg problem.
>>>>
>>>> Sounds a little strange to me. Thinking in general, if something is
>>>> created when a stream is opened, that something should be destroyed when
>>>> the stream is closed.
>>>
>>> It's not about the stream-level volume.  It's about the global volume.
>>> There have been bunch of machines that have no h/w volume control.
>>> This is the mechanism for such environment.  You certainly don't want
>>> to reset the system-level volume at each time you close the stream.
>>
>> So if it's about the global volume it should be created on startup
>> rather than when the stream is opened for the first time.
> 
> Ideally yes.  But pragmatically, no, it didn't work like that at that
> time.  The change had to be seamless.
> 
>>>>> Of course, it's possible that it wasn't PA who opened the PCM stream.
>>>>> But, something opened the stream and it created the mixer element.
>>>>> This is the correct behavior.
>>>>
>>>> And once created, it stays there forever...
>>>
>>> Not necessarily forever.  It's alsactl who saves/restores the element
>>>
>>>> So even if PA does not
>>>> create it, we'll just transform a persistent problem to an suddenly
>>>> appearing problem?
>>>
>>> Yes, it's just because you started an app that doesn't cope with PA.
>>> And, it's PA who doesn't cope with softvol setup.  This is the
>>> conflicting situation.
>>
>> So as I understand it PA should call snd_pcm_open with the
>> SND_PCM_NO_SOFTVOL, which it currently does not. It still puzzles me
>> however how PA manages to open without that flag, which creates a mixer
>> control, and later on that softvol control has no effect.
> 
> PA opens the "hw" device in general.  This skips the whole things.

Right, so it tries both, which has the side effect of creating a volume
control, and then prefers hw.

>>> Now the system doesn't know whether you'll start the non-PA app
>>> again.  So, the volume has to be retained.
>>>
>>>> Anyway, do we want softvol at all for HDA? Wouldn't that be such an
>>>> unusual use case, that those people that can't adjust volume any other
>>>> way, can add that softvol themselves in .asoundrc?
>>>
>>> The softvol itself does nothing if the corresponding h/w volume
>>> control exists.  It's activated only when the corresponding volume
>>> element is unavailable.
>>
>> Right, but I have a "Master" volume, a "Front" volume, "Headphone"
>> volume and so on, so I have all the HW volumes I need, it's just that
>> none of them happen to be labeled "PCM".
> 
> That's the problem.  The front playback stream is supposed to have
> a PCM volume control.

May I kindly ask you to reconsider that statement? AFAIK, for Realtek
chips it is more common not to have a PCM volume control (and I haven't
checked the rest). So that would mean we have tons of bugs in the HDA
driver(s).

So, this softvol is only useful if all these three conditions are met:

1) you're opening "front:x" (or the "surround:x" variants), not
"plughw:x", "hw:x", "default:x", "dmix:x" or anything else.

2) you have no playback volume what so ever

3) you're not using PA or another sound server with its own software
volume mechanism

And so far I haven't came across a single HDA that fulfills condition
2), and I find the combination even more unlikely, but YMMV.

>>>>>> I think
>>>>>> we still have a problem with PA assuming that it can change the PCM
>>>>>> volume control to change the output volume.
>>>>>
>>>>> PA can check whether it's a user-defined control or not.
>>>>
>>>> Would that be safe - I mean, can't there be user-defined controls PA
>>>> *should* care about?
>>>
>>> It depends on the driver implementation, but as long as PA does
>>> software volume control by itself, and as long as the control elements
>>> are mixer elements, they can be ignored.
>>
>> Interesting. I went looking into the snd_mixer_selem_* documentation (PA
>> uses the simple mixer interface), but I couldn't find a function for
>> determining whether a control is user-defined or not, would you mind
>> pointing me to it? Thanks!
> 
> There seems no direct access from the mixer API.
> But you can parse the mixer element to get hcontrol, then snd_ctl_elem
> can be checked for its attribute.
> 
> Yeah, a new function could be added for controlling it.
> Or, as an easier option, we can make snd_mixer_open() or
> snd_ctl_open() for skipping the user-defined controls with some flag
> like snd_pcm_open().

What would be really helpful would be if snd_mixer_open() took an
optional pcm handle, and then only returned the mixer controls that
affects the signal path of that pcm.

-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic

  reply	other threads:[~2010-09-03  7:03 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-27 14:39 alsactl adds volume controls? David Henningsson
2010-08-27 15:43 ` Clemens Ladisch
2010-08-27 18:36   ` David Henningsson
2010-08-27 22:58     ` Raymond Yau
2010-08-30  8:01       ` Takashi Iwai
2010-08-30  9:30         ` Raymond Yau
2010-08-30 11:09           ` Takashi Iwai
2010-08-30 13:01         ` David Henningsson
2010-08-30 13:08           ` Takashi Iwai
2010-09-01 13:26             ` David Henningsson
2010-09-01 14:06               ` Raymond Yau
2010-09-02  8:06               ` Takashi Iwai
2010-09-02  9:24                 ` David Henningsson
2010-09-02  9:44                   ` Takashi Iwai
2010-09-03  7:03                     ` David Henningsson [this message]
2010-09-03  7:07                       ` Jaroslav Kysela
2010-10-02  0:51                         ` Raymond Yau
2010-09-03  7:23                       ` Raymond Yau
2010-09-02 14:10                   ` Jaroslav Kysela
2010-09-02 14:21                     ` Clemens Ladisch
2010-09-02 15:24                       ` Jaroslav Kysela
2010-09-02 15:52                         ` Clemens Ladisch
2010-09-02 17:28                           ` Jaroslav Kysela
2010-09-02 20:28                             ` Sebastian H.
2010-09-29 14:26                             ` Colin Guthrie
2010-09-29 18:09                               ` Mark Brown
2010-09-30  9:17                               ` Raymond Yau
2010-09-30 11:03                               ` Clemens Ladisch
2010-09-30 15:09                                 ` Colin Guthrie
2010-09-30 15:56                                   ` Clemens Ladisch
2010-09-30 16:47                                   ` Mark Brown
2010-09-30 18:09                                     ` Takashi Iwai
2010-09-30 18:20                                       ` Colin Guthrie
2010-09-30 20:36                                       ` Mark Brown
2010-10-01  6:44                                       ` Clemens Ladisch
2010-10-01  8:19                                         ` Colin Guthrie
2010-10-01  9:02                                           ` Clemens Ladisch
2010-10-04 11:35                                             ` Colin Guthrie
2010-10-04 12:26                                               ` Clemens Ladisch
2010-10-04 14:01                                                 ` Takashi Iwai
2010-10-07  8:05                                               ` Clemens Ladisch
2010-10-08 13:21                                                 ` Colin Guthrie
2010-10-08 13:41                                                   ` Clemens Ladisch
2010-10-08 14:05                                                     ` Colin Guthrie
2010-10-08 14:16                                                       ` Colin Guthrie
2010-10-08 14:42                                                         ` Clemens Ladisch
2010-10-08 15:25                                                           ` Colin Guthrie
2010-10-08 15:29                                                             ` Colin Guthrie
2010-10-08 15:49                                                               ` Colin Guthrie
2010-10-12  8:51                                                                 ` Colin Guthrie
2010-10-15  8:32                                                                   ` Clemens Ladisch
2010-10-15  8:32                                                                     ` [PATCH 1/2] ALSA: HDA: Sigmatel: work around incorrect master muting Clemens Ladisch
2010-10-15  8:33                                                                     ` [PATCH 2/2] tlv: fix returned dB information for min-is-mute controls Clemens Ladisch
2010-10-15  8:39                                                                     ` alsactl adds volume controls? Colin Guthrie
2010-10-16 15:49                                                                       ` Colin Guthrie
2010-10-17  8:50                                                                         ` Takashi Iwai
2010-10-17 11:22                                                                           ` Colin Guthrie
2010-10-08 15:49                                                             ` Clemens Ladisch
2010-10-11  1:34                                                               ` Raymond Yau
2010-10-11  8:25                                                                 ` Colin Guthrie
2010-10-12  8:37                                                                   ` Raymond Yau
2010-10-17  3:39                                                       ` Raymond Yau
2010-10-17 11:18                                                         ` Colin Guthrie
2010-10-04 14:18                                           ` Alexander E. Patrakov
2010-10-04 11:09                                         ` Raymond Yau
2010-10-04 11:38                                           ` Colin Guthrie
2010-10-06  0:05                                             ` Raymond Yau
2010-10-06 23:29                                               ` Colin Guthrie
2010-10-01  5:38                                     ` Raymond Yau
2010-10-03  7:37                               ` Raymond Yau
2010-10-23 11:51   ` Raymond Yau
2010-10-23 13:00     ` Colin Guthrie
2010-10-24 11:49       ` Raymond Yau
2010-08-29  1:35 ` Raymond Yau

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=4C809DB3.9090201@canonical.com \
    --to=david.henningsson@canonical.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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).