Bug 79911 - incoherent muting of ALSA channels (mutes master, headphone and speaker, but unmutes only master, when adjusting in alsamixer or equivalent)
Summary: incoherent muting of ALSA channels (mutes master, headphone and speaker, but ...
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-11 09:12 UTC by Horst Schirmeier
Modified: 2018-07-30 10:38 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
pcm_playback_switch need to be on instead of mute (562 bytes, patch)
2014-06-15 05:25 UTC, Raymond
Details | Splinter Review

Description Horst Schirmeier 2014-06-11 09:12:53 UTC
This is a summary of the Ubuntu bug reported at <https://bugs.launchpad.net/ubuntu/+source/xfce4-volumed/+bug/1254884>.  It already has a duplicate at <https://bugs.launchpad.net/ubuntu/+source/xfce4-volumed/+bug/1258782>.

With certain audio hardware (those where alsamixer shows separate "headphone" and "speaker" channels) pressing of the mute button on laptop keyboards causes mute of all three channels: master, headphone and speaker.  Pressing the button again to unmute unmutes only the master channel, leaving headphone and speaker muted.

Workaround: There is no other way than opening alsamixer in a terminal (or open mixer controls from the applet) and manually clicking the two remaining channels to unmute.

Details:

- We already tracked this down not to be an issue with ALSA or xfce4-volumed: The problem also occurs using a different window manager, and it disappears when deinstalling PulseAudio.

- This issue has already been seen on "Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 03)" (Dell Latitude E6400) and "Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)".

- This issue appeared with Ubuntu 13.10 (AMD64), and persists in 14.04.  I don't know which PulseAudio versions were involved.

- "Raymond" in the original bug report flooded the discussion with lots of technical information I do not know how to act upon.  Maybe you do.

- In comments #15 to #18 on <https://bugs.launchpad.net/ubuntu/+source/xfce4-volumed/+bug/1254884> we posted the "alsa-info" for a few systems with similar symptoms.

- In comment #28 I successfully implemented a fix (or workaround?) for the problem on my machine:

----
[...] changing "switch" from "mute" to "on" under [Element PCM] in /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common (see below) did have an effect -- pressing the "mute" button now only mutes Master and Headphone (not PCM anymore), pressing it again only unmutes Master. Changing the same for [Element Headphone] in /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf fixes the Headphone mixer behaviour for me, too.

[Element PCM]
#switch = mute
switch = on
----
Comment 1 Tanu Kaskinen 2014-06-11 10:27:38 UTC
I suppose this has nothing to do with GStreamer. Can you reproduce this simpy by muting and unmuting the sink with pactl? The command to use is "set-sink-mute", see man pactl for details.

Changing "switch = mute" to "switch = on" is not a proper fix. "switch = mute" means that the switch state should follow the sink mute state, so unmuting the sink in pulseaudio should unmute the switch in alsa too.
Comment 2 Horst Schirmeier 2014-06-11 10:35:17 UTC
No, I cannot reproduce the behavior with "pactl set-sink-mute 0 toggle".  Running this once mutes "Master", "Headphone" and "PCM" in alsamixer.  Running this a second time correctly unmutes all three.
Comment 3 Tanu Kaskinen 2014-06-11 10:46:44 UTC
Ok, then I guess xfce4-volumed is accessing alsa directly, instead of doing the muting through pulseaudio.

Explanation for the inconsistency between muting and unmuting: xfce4-volumed sets the Master switch to muted. PulseAudio notices that something happened in the alsa mixer, and sees that one of the switches is muted, so PulseAudio concludes that the device is muted and sets the internal device state to mute. While setting the internal state, pulseaudio also mutes the rest of the switches marked as "switch = mute", including PCM. When xfce4-volumed unmutes the Master switch, PulseAudio again notices that something happened, but since the PCM switch is still muted, PulseAudio concludes that the device is still muted and does nothing.

xfce4-volumed should be changed to talk to pulseaudio instead of accessing the alsa mixer directly.
Comment 4 Tanu Kaskinen 2014-06-11 10:53:49 UTC
Or another solution would be to change pulseaudio so that it caches the alsa mixer state, so when one switch is unmuted, pulseaudio would be able to figure out that unmuting happened. Without caching this is not possible, because the only notification we get from alsa is that "something changed".

But from architecture point of view I think there should be only one component that is controlling the alsa mixers, and that component should be pulseaudio, so changing xfce4-volumed makes more sense than changing pulseaudio to cope with other components fiddling with the alsa mixers.
Comment 5 Horst Schirmeier 2014-06-11 11:04:09 UTC
As I said in the description:  We think we tracked this down not to be an issue with ALSA or xfce4-volumed.  The problem also occurs using a different window manager (I tried it with Unity IIRC), and it disappears when deinstalling PulseAudio.

I may be drawing wrong conclusions here, though.  Please instruct me on which experiments to conduct to gather more information.
Comment 6 Tanu Kaskinen 2014-06-11 11:43:51 UTC
Unmuting via pulseaudio works fine, so whatever does the unmuting when you press the mute button on your laptop is, with very very high probability, not using pulseaudio.

I had a look at xfce4-volumed code, and it seems to rely on GstMixer. xfce4-volumed doesn't seem to care about the mixer implementation, it will just use the first mixer implementation that it finds. That might very well be an implementation based on alsa, not pulseaudio.
Comment 7 Raymond 2014-06-12 09:23:30 UTC
you need  to log the changes of alsa playback volume and switch made by pulseaudio when it switch path

only the driver know which control belong to the audio path of headphone, line out and speaker for business desktop, notebook or home desktop

https://launchpadlibrarian.net/166342784/alsa-info.txt.q27ddho7BC



Node 0x0a [Pin Complex] wcaps 0x400181: Stereo
  Control: name="Headphone Jack", index=0, device=0
  Pincap 0x0000001c: OUT HP Detect
  Pin Default 0x0421101f: [Jack] HP Out at Ext Right
    Conn = 1/8, Color = Black
    DefAssociation = 0x1, Sequence = 0xf
  Pin-ctls: 0xc0: OUT HP
  Unsolicited: tag=01, enabled=1
  Connection: 3
     0x10 0x11* 0x17

Node 0x0d [Pin Complex] wcaps 0x400181: Stereo
  Control: name="Speaker Phantom Jack", index=0, device=0
  Pincap 0x00000014: OUT Detect
  Pin Default 0x90170110: [Fixed] Speaker at Int N/A
    Conn = Analog, Color = Unknown
    DefAssociation = 0x1, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=00, enabled=0
  Connection: 3
     0x10* 0x11 0x17

Node 0x0f [Pin Complex] wcaps 0x400181: Stereo
  Control: name="Dock Line Out Jack", index=0, device=0
  Pincap 0x00000014: OUT Detect
  Pin Default 0x23011050: [Jack] Line Out at Sep Left
    Conn = 1/8, Color = Black
    DefAssociation = 0x5, Sequence = 0x0
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=02, enabled=1
  Connection: 3
     0x10* 0x11 0x17
Node 0x10 [Audio Output] wcaps 0xd0c05: Stereo Amp-Out R/L
  Control: name="PCM Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="PCM Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Device: name="92HD71B7X Analog", type="Audio", device=0
  Amp-Out caps: N/A
  Amp-Out vals:  [0x6d 0x6d]
  Converter: stream=8, channel=0
  Power states: 
  Power: setting=D0, actual=D0
  Delay: 13 samples
Node 0x11 [Audio Output] wcaps 0xd0c05: Stereo Amp-Out R/L
  Control: name="Headphone Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Headphone Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: N/A
  Amp-Out vals:  [0x6d 0x6d]
  Converter: stream=8, channel=0
  Power states: 
  Power: setting=D0, actual=D0
  Delay: 13 samples
Comment 8 Raymond 2014-06-15 05:25:21 UTC
Created attachment 101077 [details] [review]
pcm_playback_switch need to be on instead of mute

as pcm playback switch is regarded by pulseaudio as common to all paths, it should be on instead of mute
Comment 9 Tanu Kaskinen 2014-06-16 16:07:13 UTC
I don't follow. PulseAudio uses PCM for all paths, but why does that imply that PCM should not be muted when the sink is muted?
Comment 10 Raymond 2014-06-26 05:36:59 UTC
https://launchpadlibrarian.net/178486562/PulseList.txt

e.g  hda codec cs4213 has only one hardware volume control for both headphone and speaker

when did pulseaudio setup those control which is common To all paths ?
Comment 11 Tanu Kaskinen 2014-06-26 09:11:07 UTC
When the port changes from headphones to speakers, for example, alsa mixer is updated at that point to reflect the previously saved state of the speakers port.
Comment 12 Horst Schirmeier 2014-11-03 10:32:48 UTC
BTW, I'm seeing this on a Dell Latitude E4300, too.  (Not surprising, as it's also using a 82801I.)

What else do you need to fix this?
Comment 13 Raymond 2014-11-03 15:39:53 UTC
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-October/082334.html

 pcm volume of some hda codecs seem to be renamed but the name of ac97 codecs are unlikely to be changed
Comment 14 Horst Schirmeier 2014-11-03 15:52:54 UTC
Raymond, your comment is, again, very cryptic.  How is this related to my problem, what am I supposed to do about it, and what needs to be changed to fix the issue?

I'm not into PulseAudio details, so please tell me exactly what to do (if the comment was directed to me at all, and not rather another PulseAudio developer).  For example, if I am supposed to provide log output, tell me how to enable logging (for the particular tool/daemon), where to find the log file, and what action I need to trigger to provoke something interesting to be logged (e.g., press the "mute" button twice).
Comment 15 Raymond 2014-11-03 16:14:21 UTC
you have to follow  if your dell e430 use stac9200 which is a two channel hda codec 



http://mailman.alsa-project.org/pipermail/alsa-devel/2014-October/083128.html
Comment 16 Horst Schirmeier 2014-11-03 16:56:24 UTC
I don't think the Dell Latitude E4300 has a stac9200.  Again, if you talk about some funny ALSA or PulseAudio details, please tell me on what information to provide here, and how to gather it.  I'm just *guessing* the output of "aplay -l" or alsamixer may be relevant here (is it?):

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: 92HD71B7X Analog [92HD71B7X Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

alsamixer says "Card: HDA Intel" and "Chip: Intel Cantiga HDMI".
Comment 17 Horst Schirmeier 2014-11-03 16:58:52 UTC
And, just to reiterate my initial bug report (as you're pointing me to an ALSA mailing list thread):

"- We already tracked this down not to be an issue with ALSA or xfce4-volumed: The problem also occurs using a different window manager, and it disappears when deinstalling PulseAudio."
Comment 18 Raymond 2014-11-04 02:18:32 UTC
it is because your notebook have speaker, headphone and dock line out with two audio output

david 's patch is to change "pcm" to "speaker+LO" for those with 2+2 HDA codec and three ports

for those notebook with dock headphone,  you need to follow up with Tiwai 


Node 0x10 [Audio Output] wcaps 0xd0c05: Stereo Amp-Out R/L
  Control: name="PCM Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="PCM Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Device: name="92HD71B7X Analog", type="Audio", device=0
  Amp-Out caps: N/A
  Amp-Out vals:  [0x6d 0x6d]
  Converter: stream=8, channel=0
  Power states: 
  Power: setting=D0, actual=D0
  Delay: 13 samples
Comment 19 Raymond 2014-11-04 02:42:22 UTC
for those two channel ac97 codec and some for channel ac97 codec

ac97 analog mixer have many input : DAC, mic , line in,  CD, Aux, 

pcm playback volume/switch control the DAC input to AC97 analog mixer

ac97 analog mixer has it own ouput volume controls which are master playback volume/switch and mono playback
Comment 20 Raymond 2014-11-04 15:10:45 UTC


for those hda codecs which have ac97 like analog mixer (e.g. ad1986a, vt1708,...) 

the alsa driver already removed the corresponding "PCM" playback volume and playback switch when those codec use hda_generic.c to create the controls

it use set volume to 0dB and unmute without creating any control


the remaing hda codecs are those without analog mixer need change of control name to indicate whether it is shared by two or more ports

http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-November/022241.html
Comment 21 Horst Schirmeier 2014-11-04 16:00:24 UTC
What are you saying?  That the core reason for the bug is known and worked on?  Or do you need more input from me to analyze the issue?
Comment 22 Raymond 2014-11-05 00:44:26 UTC
you need to add some code in alsa-sink.c or alsa-util.c to  log all the mute switch/volume events when pulseaudio change those alsa playback switch/volume to prove the mute of pcm playback switch is done by pulseaudio instead of driver or other alsa application
Comment 23 Raymond 2014-11-05 08:34:47 UTC
You need to log e->alsa_name and value of b for snd_mixer_selem_set_playback_switch_all in 



http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/alsa-mixer.c


static int element_set_switch(pa_alsa_element *e, snd_mixer_t *m, bool b) {
    snd_mixer_elem_t *me;
    snd_mixer_selem_id_t *sid;
    int r;

    pa_assert(m);
    pa_assert(e);

    SELEM_INIT(sid, e->alsa_name);
    if (!(me = snd_mixer_find_selem(m, sid))) {
        pa_log_warn("Element %s seems to have disappeared.", e->alsa_name);
        return -1;
    }



    if (e->direction == PA_ALSA_DIRECTION_OUTPUT)
        r = snd_mixer_selem_set_playback_switch_all(me, b);
    else
        r = snd_mixer_selem_set_capture_switch_all(me, b);
Comment 24 Raymond 2014-11-05 08:41:10 UTC
and log the path name




int pa_alsa_path_set_mute(pa_alsa_path *p, snd_mixer_t *m, bool muted) {
    pa_alsa_element *e;

    pa_assert(m);
    pa_assert(p);

    if (!p->has_mute)
        return -1;

    PA_LLIST_FOREACH(e, p->elements) {

        if (e->switch_use != PA_ALSA_SWITCH_MUTE)
            continue;

        if (element_set_switch(e, m, !muted) < 0)
            return -1;
    }

    return 0;
}
Comment 25 Raymond 2014-11-05 11:32:39 UTC
this mean that when pulseaudio switch from path A to path B, the mute switch which is common to both path should not set to PA_ALSA_SWITCH_MUTE

this also imply those elements in output.common should not set to PA_ALSA_SWITCH_MUTE

you should send your patch to pulseaudio-discuss mailing list for review
Comment 26 Raymond 2015-02-12 03:34:04 UTC
seem new bug as the driver already changed by this patch, this create a Line out playback volume when the computer only have speaker and header

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda/hda_generic.c?id=3abb4f4d0e7aaad0d12004b5057f4486a688752b
Comment 27 Jarno Suni 2015-03-26 12:36:25 UTC
Please note, that if you use Indicator Plugin or pavucontrol to unmute, it also unmutes several channels.
Comment 28 Jarno Suni 2015-03-26 12:40:13 UTC
(In reply to Raymond from comment #26)
> seem new bug as the driver already changed by this patch, this create a Line
> out playback volume when the computer only have speaker and header
> 
> https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/
> pci/hda/hda_generic.c?id=3abb4f4d0e7aaad0d12004b5057f4486a688752b

Yes, different bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1433568
Comment 29 Jarno Suni 2015-03-26 13:00:51 UTC
Suggestion in the last paragraph: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1436269/comments/5
Comment 30 Jarno Suni 2015-03-26 13:08:51 UTC
Update: another workaround when using xfce4-mixer (or Xfce Audio Mixer in panel): Choose Playback:...(PulseAudio Mixer) instead of (Alsa mixer) as sound card in properties.
Comment 31 Horst Schirmeier 2015-03-26 13:35:59 UTC
(In reply to Jarno Suni from comment #30)
> Update: another workaround when using xfce4-mixer (or Xfce Audio Mixer in
> panel): Choose Playback:...(PulseAudio Mixer) instead of (Alsa mixer) as
> sound card in properties.

Confirmed.  This works around the symptoms for me.  Thanks!
Comment 32 GitLab Migration User 2018-07-30 10:38:05 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/540.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.