Bug 84334 - Unplugging headphone does not correctly fallback to external speakers
Summary: Unplugging headphone does not correctly fallback to external speakers
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (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-09-25 19:23 UTC by Earnest
Modified: 2018-07-30 09:36 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Output from pactl list when unplugged (19.59 KB, text/plain)
2014-09-26 10:30 UTC, Earnest
Details
Output from pactl list when plugged (19.62 KB, text/plain)
2014-09-26 10:31 UTC, Earnest
Details
Output from alsa-info.sh when unplugged (36.17 KB, text/plain)
2014-09-26 10:32 UTC, Earnest
Details
Output from alsa-info.sh when plugged (36.17 KB, text/plain)
2014-09-26 10:33 UTC, Earnest
Details
Output from pactl list when broken and unplugged (19.61 KB, text/plain)
2014-09-27 13:44 UTC, Earnest
Details
Output from pactl list when broken and plugged (19.64 KB, text/plain)
2014-09-27 13:45 UTC, Earnest
Details
Output from pactl list when patched and unplugged (19.58 KB, text/plain)
2014-09-28 10:58 UTC, Earnest
Details
Output from pactl list when patched and plugged (19.61 KB, text/plain)
2014-09-28 10:59 UTC, Earnest
Details

Description Earnest 2014-09-25 19:23:49 UTC
== System Information

* Lenovo Thinkpad X220 without Dock
* Linux 3.16.3
* PulseAudio 5.0.r273.g1ff4f1b
* Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)

== Description

When the headphones are plugged in the "Output Devices" tab in pavucontrol will
list "Headphones (unplugged)", "Analog Output" and "Speakers (unavailable)"
with "Analog Output" being selected.

If I unplug the headphones I would expect it to fallback to the Speakers, however
it doesn't (no sound) and returns the following error:

    Availability of port 'analog-output-headphones' is inconsistent!

If I manually set the sink-port to the Speakers it will work however pavucontrol
will continue to mark the as "unavailable".

When plugging the headphones back in pavucontrol switches to "Analog Output" and
I can hear sound through the headphones again.

== Resolution Attempts

Looking at the git logs I came across this commit:

    alsa-mixer: recognize Dock headphone jack
    http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=594da41d07edce

Reverting this fixes the issue on my machine and restores normal functionality.
Comment 1 Raymond 2014-09-26 08:24:03 UTC
post output of 

pactl list

alsa-info.sh

when you plug and unplug headphone
Comment 2 Earnest 2014-09-26 10:30:53 UTC
Created attachment 106913 [details]
Output from pactl list when unplugged
Comment 3 Earnest 2014-09-26 10:31:20 UTC
Created attachment 106914 [details]
Output from pactl list when plugged
Comment 4 Earnest 2014-09-26 10:32:39 UTC
Created attachment 106915 [details]
Output from alsa-info.sh when unplugged
Comment 5 Earnest 2014-09-26 10:33:03 UTC
Created attachment 106916 [details]
Output from alsa-info.sh when plugged
Comment 6 Earnest 2014-09-26 10:36:50 UTC
Note that the above output is while having fixed PulseAudio.

Sorry for the attachment spam but I was unable to find a function which would let me upload these files all at once.  They were too long to paste directly.
Comment 7 Raymond 2014-09-27 05:00:29 UTC
you have to post output of 

pactl list

without your fix


do you mean the availabltity of headphone is not  OR  values of headphone jack / dock headphone jack controls since headphone and dock headphone share the same volume control ?



control.16 {
		iface CARD
		name 'Dock Headphone Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
	control.17 {
		iface CARD
		name 'Headphone Jack'
		value true
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
Comment 8 Earnest 2014-09-27 13:44:48 UTC
Created attachment 106958 [details]
Output from pactl list when broken and unplugged
Comment 9 Earnest 2014-09-27 13:45:14 UTC
Created attachment 106959 [details]
Output from pactl list when broken and plugged
Comment 10 Earnest 2014-09-27 13:53:53 UTC
> do you mean the availabltity of headphone is not  OR  values of headphone 
> jack / dock headphone jack controls since headphone and dock headphone share 
> the same volume control ?

I'm sorry, but I don't understand this question.  I said I don't have a dock.

What pavucontrol lists as "unavailable" does not reflect whatever reality is on
my machine, that's the confusion. (It seems to get "stuck" on "Analog Output".)

As described above my issue is that when using that commit which adds a 
"Phantom" Jack, PA no longer switches to external speakers when unplugging my
headphones, however, PA does switch back to the headphones when I plug them
back in.

If I want audio to play on external speakers is I have to manually and
explicitly switch the sink port to the analog-output-speakers in order to get
sound on external speakers every time.  

Removing the changes in commit "fixes" this.  I.e. I get sound via external
speakers when unplugging my headphones.

Sorry if I'm being unclear as I'm probably repeating myself.
Comment 11 Earnest 2014-09-27 14:05:14 UTC
For what it's worth, I experimented removing only the changes to
`analog-output-headphones.conf`:

```diff
--- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
@@ -25,6 +25,14 @@ description-key = analog-output-headphones
[Properties]
device.icon_name = audio-headphones
+# [Jack Dock Headphone]
+# required-any = any
+# 
+# [Jack Dock Headphone Phantom]
+# required-any = any
+# state.plugged = unknown
+# state.unplugged = unknown

[Jack Front Headphone]
required-any = any
```
PA seems to be working correctly at least with my setup.  I can't test with
docks obviously, but it seems that the changes made to
`analog-output-speakers.conf` is fine.
Comment 12 Raymond 2014-09-27 23:47:20 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda?id=a555bb8c6bf6932c5706745bfdbad22df26324d9



Sysfs Files
!!-----------

/sys/class/sound/hwC0D0/init_pin_configs:
0x19 0x04211040
0x1a 0x61a19050
0x1b 0x04a11060
0x1c 0x6121401f
0x1d 0x40f001f0
0x1e 0x40f001f0
0x1f 0x90170110
0x20 0x40f001f0
0x22 0x40f001f0
0x23 0x90a60170

/sys/class/sound/hwC0D0/driver_pin_configs:
0x19 0x042110ff
0x1a 0x21a190f0
0x1c 0x212140ff


it is unlikely for the driver to support four channels when notebook without dock station since driver won't set different channel tag to speaker and headphone

the driver also cannot support four channels when headphone and dock headphone share same dac 






	output:analog-surround-40: Analog Surround 4.0 Output (sinks: 1, sources: 0, priority: 700, available: yes)
		output:analog-surround-40+input:analog-stereo: Analog Surround 4.0 Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 760, available: yes)




seem bug of pulseaudio since active port cannot be not available

module-switch-on-available-port ensure active port is available or unknown

but cannot be not available


Ports:
		analog-output: Analog Output (priority: 9900)
		analog-output-speaker: Speakers (priority: 10000)
		analog-output-headphones: Headphones (priority: 9000, not available)
	Active Port: analog-output-headphones
Comment 13 Alexander E. Patrakov 2014-09-28 07:41:45 UTC
Your report has also some influence from bug 74609, which makes it difficult to analyze. Recently there were two patches posted by Tanu Kaskinen against that bug, could you please perform all the tests again with these patches applied, so that we see what remains?

http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=facfd3a6644711d32ecfd755d30a351b8ee61620

http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/20915/focus=20916
Comment 14 Raymond 2014-09-28 07:52:57 UTC

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda/hda_generic.c?id=a07a949be6eb1c9aab06adaadce72dbd27b7d9cb

Ports:
		analog-output: Analog Output (priority: 9900)
		analog-output-speaker: Speakers (priority: 10000)
		analog-output-headphones: Headphones (priority: 9000, not available)


if analog-output: Analog Output (priority: 9900) is related to surround40

you need to fix the driver by



-	if (cfg->line_out_type != AUTO_PIN_HP_OUT)
+	if (cfg->line_out_type == AUTO_PIN_HP_OUT)
 	spec->const_channel_count = max(spec->const_channel_count,
						cfg->hp_outs * 2);
Comment 15 Earnest 2014-09-28 10:58:31 UTC
> could you please perform all the tests again with these patches applied, so 
> that we see what remains?
> 
> http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/20915/focus=20916

I've applied both of those patches to HEAD and it didn't resolve the situation.

However pavucontrol doesn't mark my "Speakers" as (unavailable) anymore, it
still doesn't switch when unplugging though.
Comment 16 Earnest 2014-09-28 10:58:54 UTC
Created attachment 106994 [details]
Output from pactl list when patched and unplugged
Comment 17 Earnest 2014-09-28 10:59:13 UTC
Created attachment 106995 [details]
Output from pactl list when patched and plugged
Comment 18 Raymond 2014-09-28 13:09:58 UTC
Ports:
		analog-output: Analog Output (priority: 9900)
		analog-output-speaker: Speakers (priority: 10000)
		analog-output-headphones: Headphones (priority: 9000, not available)
	Active Port: analog-output

at least the unavailable headphone is no longer active port 

but speaker is still not active port
Comment 19 Raymond 2014-09-30 03:47:07 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=1101278#c22

for desktop which front panel hp does not support jack detection

Ports:
                analog-output: Analog Output (priority: 9900)
                analog-output-lineout: Line Out (priority: 9900, available)
                analog-output-headphones: Headphones (priority: 9000)
        Active Port: analog-output

pulseaudio does use jack state of line out to switch active port to lineout
Comment 20 Raymond 2014-10-01 23:24:41 UTC
for desktop with internal speaker,  line out and headphone

https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1376342

control.13 {
		iface MIXER
		name 'Auto-Mute Mode'
		value 'Line Out+Speaker'
		comment {
			access 'read write'
			type ENUMERATED
			count 1
			item.0 Disabled
			item.1 'Speaker Only'
			item.2 'Line Out+Speaker'
		}
	}



https://launchpadlibrarian.net/186316042/PulseList.txt


ports:
		analog-output: Salida analógica (priority 9900, latency offset 0 usec, available: unknown)
			properties:
				
		analog-output-speaker: Altavoces (priority 10000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Auriculares analógicos (priority 9000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-speaker>
Comment 21 GitLab Migration User 2018-07-30 09:36:17 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/44.


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.