<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Unable to properly switch between Speakers and Headphones (has "workaround")"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=105654">105654</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unable to properly switch between Speakers and Headphones (has "workaround")
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>PulseAudio
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>alsa
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>pulseaudio-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gbr@protonmail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>pulseaudio-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>lennart@poettering.net
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=138239" name="attach_138239" title="pactl list sinks">attachment 138239</a> <a href="attachment.cgi?id=138239&action=edit" title="pactl list sinks">[details]</a></span>
pactl list sinks

===
OS: Arch Linux x64
Kernel: 4.15.10
PulseAudio 11.1
Motherboard: B75M-DGS R2.0 (5.1 CH HD Audio (Realtek ALC662 Audio Codec)) [1]
===

Hi,

I was having trouble making PulseAudio switch the audio output between my
headphones and speakers, and most importantly, play audio in them exclusively.
My headphone is plugged into the front panel and my speakers are using the rear
green connection, and both of them are 2 channel. I was able to find a
workaround, which I will demonstrate later, but as of now I'll write like I
didn't know of that workaround:

I'm using both ALSA and PulseAudio's default options (although I'm not sure if
Arch Linux changes any configuration file).

I have two sinks (see attachment for the output of "pactl list sinks"), but the
relevant one is the latter, which holds my headphones and speakers (they're
split into two ports).

I'll do my best to reproduce the issue I'm having. I apologize in advance
bacause English is not my first language. So, for now let's assume I have only
my speakers plugged in (a port identified as "Line Out" in pavucontrol). When I
decide to plug in my headphones, here's what happens in pavucontrol:

1. The "Line Out" port is set to unplugged and outputs no audio anymore
2. The "Headphones" port is set to plugged in and successfully outputs audio 

The only problem I see here is that the "Line Out" port was set to "unplugged"
(this is about semantics, but it really wasn't phisically unplugged), but no
big deal since I'm getting audio exclusively in my headphones, which is exactly
what I wanted.

Okay, now that I have both speakers and headphones plugged in, let's say I want
to switch back to my speakers. All I would have to do is change the "Port" to
"Line Out (unplugged)", but here's what really happens:

1. The "Headphones" port gets muted (ok)
2. The "Line Out" port DOES NOT get unmuted
3. I get no audio output in both of them

Strangely, the "Headphones" port WAS NOT set to "unplugged" like it happened
before with "Line Out".

---

WORKAROUND:

Here's the "workaround" (not sure if you can call it that) I found while
messing with alsamixer:

Assuming we're still are in the previous scenario where I had no audio output,
if I open "alsamixer -c0" and set the "Auto-Mute Mode" control to "Disabled", I
get exclusive audio output in my speakers (which is perfect and exactly what I
wanted). Now, let's say I'd switch back to my headphones. The audio does output
to my headphones, but not exclusively. So I still hear audio coming from my
speakers as well (I don't want that). That's it.

Speaking of that "Auto-Mute Mode" control, the documentation for Linux v4.5
states [2]:

<span class="quote">>When both headphone and line-out jacks are present, it gives "Disabled", "Speaker Only" and "Line-Out+Speaker".</span >

Well, I do have both of them present, but I the only options I get are:
"Disabled" and "Enabled". So there's that as well...

---

I will be honest to you guys, I've been searching for a solution to this
problem for a long time. At the same time, I'm not an expert (not even close to
that) about Linux / PulseAudio / ALSA, so there's a high possibility that I
might have missed some PulseAudio configuration (I'm really sorry if that's the
case).

But based on a lot of Google searches [3][4][5][6], I'm definitely not the only
person dealing with that issue, and while I found some possible solutions, none
of them really worked for me... There's even a guy saying he has given up [5].
That "workaround" I found was by accident, while I was fiddling with alsamixer.
I mean, it does work perfectly for me, but it's very inconvenient having to
disable "Auto-Mute Mode" in alsamixer when I want to use my speakers, and then
enable it again when I want to use my headphones. If there isn't a solution
within PulseAudio or if this is not a bug at all, let me know. I'm sure this
could be automated with scripts, but I'm not a programmer, so any help on would
be appreciated as well.

Thank you very much.

TL;DR: I wanted to switch between speakers and headphones and output the audio
in them EXCLUSIVELY, like you do on Windows [7], but I couldn't do it by
default; But I've found a workaround (which is a tad inconvenient when you do
it by hand); And I was not sure if this was a bug or not, so I decided to
report here just in case.

===

REFERENCES:

[1] <a href="http://www.asrock.com/mb/Intel/B75M-DGS%20R2.0/">http://www.asrock.com/mb/Intel/B75M-DGS%20R2.0/</a>
[2]
<a href="https://github.com/torvalds/linux/blob/v4.15/Documentation/sound/hd-audio/controls.rst#realtek-codecs">https://github.com/torvalds/linux/blob/v4.15/Documentation/sound/hd-audio/controls.rst#realtek-codecs</a>
[3]
<a href="https://wiki.archlinux.org/index.php/PulseAudio/Examples#Having_both_speakers_and_headphones_plugged_in_and_switching_in_software_on-the-fly">https://wiki.archlinux.org/index.php/PulseAudio/Examples#Having_both_speakers_and_headphones_plugged_in_and_switching_in_software_on-the-fly</a>
(this was the most promising one, unfortunately it didn't work)
[4] <a href="https://bbs.archlinux.org/viewtopic.php?id=187828">https://bbs.archlinux.org/viewtopic.php?id=187828</a>
[5] <a href="https://bbs.archlinux.org/viewtopic.php?id=226651">https://bbs.archlinux.org/viewtopic.php?id=226651</a>
[6] <a href="https://bbs.archlinux.org/viewtopic.php?id=161296">https://bbs.archlinux.org/viewtopic.php?id=161296</a>
[7] <a href="https://i.imgur.com/gfKkQcS.png">https://i.imgur.com/gfKkQcS.png</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>