Bug 99425 - Dbus fallback sink not updating and blocking further action
Summary: Dbus fallback sink not updating and blocking further action
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: tools (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: 2017-01-15 22:28 UTC by getzze
Modified: 2017-02-17 17:53 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Output of `pactl list cards` with headset connected (10.73 KB, text/plain)
2017-02-17 11:42 UTC, getzze
Details
Output of `pactl list cards` with headset disconnected (10.74 KB, text/plain)
2017-02-17 15:26 UTC, getzze
Details

Description getzze 2017-01-15 22:28:54 UTC
Using PulseAudio 9.0 on ArchLinux, more specifically on Gnome 3.22 with the Laine extension (https://github.com/johnhoran/Laine). This extensions controls and monitors PulseAudio using DBus. It listens to the signal FallbackSinkUpdated and can change the property using Set FallbackSink.

I have an integrated sound card (Asus P5K Pro) with a front entry for headphone and mic.

Steps to reproduce:
1. Connect front headphone jack.
2. Set default sink to front headphone, using Laine or pavucontrol.
3. Disconnect headphone jack. 
4. Connect jack again. 

In pavucontrol, the fallback sunk is the front headphone again. In Laine, it cannot find a fallback. When calling the Get property on the interface org.PulseAudio.Core1 for FallbackSink, the answer is that there are no sinks, so no fallback sunk either. PulseAudio bus is somehow broken. Further calls to Set FallbackSink do not work either. The Fallback sink can be changed from pavucontrol though. 

When the headphone is disconnected, the RemovedSink signal is emitted and the org.PulseAudio.Core1.Device interface for the headphone is removed. Then the fallback sink is destroyed, but no FallbackSinkUpdated or FallbackSinkUnset signal is emitted. Furthermore, any further call to the FallbackSink property is broken.
Using pavucontrol or pacmd to change the fallback works and repairs the bus. 

When the fallback device is disconnected, I would expect a FallbackSinkUpdated signal to be emitted and the bus to continue working.
Comment 1 Tanu Kaskinen 2017-01-23 08:03:53 UTC
I'd like to try to reproduce this, but to get a better idea of how your hardware looks, could you attach the output of "pactl list" with and without headphones plugged in?
Comment 2 getzze 2017-01-23 17:51:52 UTC
I just display the sink that is changing:

With headphones disconnected ----->

Sink #3
	State: IDLE
	Name: alsa_output.pci-0000_00_1b.0.iec958-stereo
	Description: Built-in Audio Digital Stereo (IEC958)
	Driver: module-alsa-card.c
	Sample Specification: s16le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 8
	Mute: no
	Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	Base Volume: 65536 / 100% / 0.00 dB
	Monitor Source: alsa_output.pci-0000_00_1b.0.iec958-stereo.monitor
	Latency: 1842786 usec, configured 2000000 usec
	Flags: HARDWARE HW_MUTE_CTRL DECIBEL_VOLUME LATENCY SET_FORMATS 
	Properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC883 Digital"
		alsa.id = "ALC883 Digital"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "1"
		alsa.card = "0"
		alsa.card_name = "HDA Intel"
		alsa.long_card_name = "HDA Intel at 0xfe7f8000 irq 30"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "293e"
		device.product.name = "82801I (ICH9 Family) HD Audio Controller (P5K PRO Motherboard)"
		device.form_factor = "internal"
		device.string = "iec958:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "iec958-stereo"
		device.profile.description = "Digital Stereo (IEC958)"
		device.description = "Built-in Audio Digital Stereo (IEC958)"
		alsa.mixer_name = "Realtek ALC883"
		alsa.components = "HDA:10ec0883,1043829f,00100002"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	Ports:
		iec958-stereo-output: Digital Output (S/PDIF) (priority: 0)
	Active Port: iec958-stereo-output
	Formats:
		pcm


With headphone connected ----->

Sink #1
	State: SUSPENDED
	Name: alsa_output.pci-0000_00_1b.0.analog-stereo
	Description: Built-in Audio Analog Stereo
	Driver: module-alsa-card.c
	Sample Specification: s16le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 8
	Mute: no
	Volume: front-left: 36042 /  55% / -15.58 dB,   front-right: 36042 /  55% / -15.58 dB
	        balance 0.00
	Base Volume: 65536 / 100% / 0.00 dB
	Monitor Source: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
	Latency: 0 usec, configured 0 usec
	Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	Properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC883 Analog"
		alsa.id = "ALC883 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel"
		alsa.long_card_name = "HDA Intel at 0xfe7f8000 irq 30"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "293e"
		device.product.name = "82801I (ICH9 Family) HD Audio Controller (P5K PRO Motherboard)"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		alsa.mixer_name = "Realtek ALC883"
		alsa.components = "HDA:10ec0883,1043829f,00100002"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	Ports:
		analog-output-lineout: Line Out (priority: 9900, not available)
		analog-output-headphones: Headphones (priority: 9000, available)
	Active Port: analog-output-headphones
	Formats:
		pcm
Comment 3 Tanu Kaskinen 2017-01-26 11:03:43 UTC
Laine doesn't seem to listen for the FallbackSinkUnset signal, which is emitted when the default sink becomes unset. But mostly this is a PulseAudio bug. The dbus interface doesn't handle the case properly where there's no explicitly configured default sink, and that's the state that pulseaudio goes into when the configured default sink disappears.

I believe this patch fixes this bug:
https://patchwork.freedesktop.org/patch/109460/

The patch is pretty old already, but today I reminded Arun about it, and hopefully he'll review it tomorrow so that it can be merged.
Comment 4 getzze 2017-02-13 16:52:40 UTC
I could not test the patch yet.
The signal FallbackSinkUnset is emitted indeed (I modified Laine to listen to it). The only problem is that the pulseaudio dbus becomes broken after... 
The workaround I use is to call `pacmd` to reset the default sink, so pulseaudio dbus works again. I call:

/usr/bin/pacmd set-default-sink $(/usr/bin/pacmd list-sinks | awk '/* index:/ {print $3}')

So in `pacmd`, a new default sink is defined when I disconnect the headset. But not in DBus. There is something wrong there also, no?
Comment 5 getzze 2017-02-13 18:48:17 UTC
I compiled pulseaudio with the patch but it is not solving the problem. Now the pulseaudio dbus disconnects when unplugging the headset. Changing Fallback sink in pavucontrol brings back the bus.

Error I get from Laine:
<code>
Feb 13 18:06:46 server gnome-shell[1027]: JS ERROR: Gio.IOErrorEnum: The connection is closed
                                          Device<.setActiveDevice/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:512
                                          Device<._asyncDBusGetProperty/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:490
Feb 13 18:06:46 server org.gnome.Shell.desktop[1027]: read(): Connection reset by peer
Feb 13 18:06:46 server gnome-shell[1027]: JS ERROR: Gio.IOErrorEnum: The connection is closed
                                          Device<.setActiveDevice/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:520
                                          Device<._asyncDBusGetProperty/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:490
Feb 13 18:06:46 server org.gnome.Shell.desktop[1027]: No PulseAudio daemon running, or not running as session daemon.
Feb 13 18:06:46 server gnome-shell[1027]: JS ERROR: Gio.IOErrorEnum: The connection is closed
                                          Device<._init/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:442
                                          Device<._asyncDBusGetProperty/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:490
Feb 13 18:06:46 server gnome-shell[1027]: JS ERROR: Gio.IOErrorEnum: The connection is closed
                                          Device<._init/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:455
                                          Device<._asyncDBusGetProperty/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:490
Feb 13 18:06:46 server gnome-shell[1027]: JS ERROR: Gio.IOErrorEnum: The connection is closed
                                          PortMenu<._forceFallbackDevice/</<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:130
Feb 13 18:06:46 server gnome-shell[1027]: JS ERROR: Gio.IOErrorEnum: The connection is closed
                                          Device<.setActiveDevice/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:505
                                          Device<._asyncDBusGetProperty/<@/usr/share/gnome-shell/extensions/laine@knasher.gmail.com/portMenu.js:490
</code>


The line from portMenu.js do not correspond to the vanilla Laine, I use a fork.


I also have a python script using the python-dbus module, that I wrote for debugging. It continuously prints the answer to the signals `FallbackSink` and `InterfaceRevision`. Typically:
>>>pulse_properties.Get('org.PulseAudio.Core1', 'FallbackSink', reply_handler=handle_fallback_reply)
>>>pulse_properties.Get('org.PulseAudio.Core1', 'InterfaceRevision', reply_handler=handle_fallback_reply)

When I disconnect the headset I get:
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUpdated', 'interface': 'org.PulseAudio.Core1'}
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/freedesktop/DBus/Local'), 'member': 'Disconnected', 'interface': 'org.freedesktop.DBus.Local'}


Any further call to the bus do not work. And when I restart the python script again, the bus does not exists. The error I get (only the useful traceback):

<code>
     16     else:
     17         bus = dbus.SessionBus()
---> 18         server_lookup = bus.get_object("org.PulseAudio1", "/org/pulseaudio/server_lookup1")
     19         address = server_lookup.Get("org.PulseAudio.ServerLookup1", "Address", dbus_interface="org.freedesktop.DBus.Properties")
     20         print('\nPulseaudio dbus address: ', address, '\n')

DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.PulseAudio1 was not provided by any .service files
</code>
Comment 6 getzze 2017-02-13 18:54:20 UTC
And the pulseaudio server crashes...


Feb 13 18:49:37 server systemd-coredump[27281]: Process 17122 (pulseaudio) of user 1000 dumped core.
                                                
                                                Stack trace of thread 17122:
                                                #0  0x00007f467c63504f raise (libc.so.6)
                                                #1  0x00007f467c63647a abort (libc.so.6)
                                                #2  0x00007f4652db9a2a n/a (module-dbus-protocol.so)
                                                #3  0x00007f467d921c0c pa_hook_fire (libpulsecore-10.0.so)
                                                #4  0x00007f467d920d65 pa_core_update_default_sink (libpulsecore-10.0.so)
                                                #5  0x00007f467d943972 pa_sink_put (libpulsecore-10.0.so)
                                                #6  0x00007f4673ccf227 pa_alsa_sink_new (libalsa-util.so)
                                                #7  0x00007f4673ef1314 n/a (module-alsa-card.so)
                                                #8  0x00007f467d91daa6 pa_card_set_profile (libpulsecore-10.0.so)
                                                #9  0x00007f46742fe8a1 n/a (module-switch-on-port-available.so)
                                                #10 0x00007f46742feb11 n/a (module-switch-on-port-available.so)
                                                #11 0x00007f467d921c0c pa_hook_fire (libpulsecore-10.0.so)
                                                #12 0x00007f4673ef1ca3 n/a (module-alsa-card.so)
                                                #13 0x00007f4673cb71f8 n/a (libalsa-util.so)
                                                #14 0x00007f46739df363 n/a (libasound.so.2)
                                                #15 0x00007f46739d502d snd_hctl_handle_events (libasound.so.2)
                                                #16 0x00007f46739e0491 snd_mixer_handle_events (libasound.so.2)
                                                #17 0x00007f4673cbc807 n/a (libalsa-util.so)
                                                #18 0x00007f467d6c9a7c pa_mainloop_dispatch (libpulse.so.0)
                                                #19 0x00007f467d6c9e7c pa_mainloop_iterate (libpulse.so.0)
                                                #20 0x00007f467d6c9f20 pa_mainloop_run (libpulse.so.0)
                                                #21 0x000000000040715a main (pulseaudio)
                                                #22 0x00007f467c622291 __libc_start_main (libc.so.6)
                                                #23 0x0000000000407c7a _start (pulseaudio)
                                                
                                                Stack trace of thread 17200:
                                                #0  0x00007f467c6e1551 ppoll (libc.so.6)
                                                #1  0x00007f467d92cf38 pa_rtpoll_run (libpulsecore-10.0.so)
                                                #2  0x00007f465659cd1f n/a (module-null-sink.so)
                                                #3  0x00007f467d4764b8 n/a (libpulsecommon-10.0.so)
                                                #4  0x00007f467cbab454 start_thread (libpthread.so.0)
                                                #5  0x00007f467c6ea7df __clone (libc.so.6)
                                                
                                                Stack trace of thread 27278:
                                                #0  0x00007f467c6e1551 ppoll (libc.so.6)
                                                #1  0x00007f467d92cf38 pa_rtpoll_run (libpulsecore-10.0.so)
                                                #2  0x00007f4673ccd285 n/a (libalsa-util.so)
                                                #3  0x00007f467d4764b8 n/a (libpulsecommon-10.0.so)
                                                #4  0x00007f467cbab454 start_thread (libpthread.so.0)
                                                #5  0x00007f467c6ea7df __clone (libc.so.6)
                                                
                                                Stack trace of thread 17124:
                                                #0  0x00007f467c6e1551 ppoll (libc.so.6)
                                                #1  0x00007f467d92cf38 pa_rtpoll_run (libpulsecore-10.0.so)
                                                #2  0x00007f4673ccd15e n/a (libalsa-util.so)
                                                #3  0x00007f467d4764b8 n/a (libpulsecommon-10.0.so)
                                                #4  0x00007f467cbab454 start_thread (libpthread.so.0)
                                                #5  0x00007f467c6ea7df __clone (libc.so.6)
                                                
                                                Stack trace of thread 17125:
                                                #0  0x00007f467c6e1551 ppoll (libc.so.6)
                                                #1  0x00007f467d92cf38 pa_rtpoll_run (libpulsecore-10.0.so)
                                                #2  0x00007f4673cd3679 n/a (libalsa-util.so)
                                                #3  0x00007f467d4764b8 n/a (libpulsecommon-10.0.so)
                                                #4  0x00007f467cbab454 start_thread (libpthread.so.0)
                                                #5  0x00007f467c6ea7df __clone (libc.so.6)
Comment 7 getzze 2017-02-13 19:06:22 UTC
I cannot edit the last message, but before that I had:

Feb 13 19:02:55 server pulseaudio[628]: E: [pulseaudio] iface-core.c: Assertion '(device_iface = pa_hashmap_get(c->sinks_by_index, PA_UINT32_TO_PTR(c->fallback_sink->index)))' failed at modules/dbus/iface-core.c:1710, function default_sink_changed_cb(). Aborting.
Feb 13 19:03:05 server systemd[723]: pulseaudio.service: Main process exited, code=dumped, status=6/ABRT
Feb 13 19:03:05 server systemd[723]: pulseaudio.service: Unit entered failed state.
Feb 13 19:03:05 server systemd[723]: pulseaudio.service: Failed with result 'core-dump'.
Feb 13 19:03:06 server systemd[723]: pulseaudio.service: Service hold-off time over, scheduling restart.
Comment 8 getzze 2017-02-13 19:14:52 UTC
I also noticed that with the patched pulseaudio, the name of the sink is not changed when I disconnect the headset, it remains "Built-in Audio Analog Stereo", with two ports, "Line Out" and "Headphones". Then, after some more random manipulations, the PA server crashes.
Comment 9 Tanu Kaskinen 2017-02-16 10:16:34 UTC
Good that the crash was found now rather than after a release. I updated the patch, hopefully it doesn't crash any more:
https://patchwork.freedesktop.org/patch/139179/

I don't think the patch should affect the automatic switching to the iec958 profile when you unplug the headphones. Can you attach the output of "pactl list cards" when headphones are unplugged? (Use the "Add an attachment" link.)
Comment 10 getzze 2017-02-17 11:42:40 UTC
Created attachment 129688 [details]
Output of `pactl list cards` with headset connected
Comment 11 getzze 2017-02-17 11:46:06 UTC
Pulseaudio server still crashes with the new version of the patch, when the headset is selected as fallback sink and I unplug it (at time 11:30:30):
>>>journalctl --user -b -u pulseaudio

Feb 17 11:26:20 server systemd[699]: Started Sound Service.
Feb 17 11:30:30 server pulseaudio[705]: E: [pulseaudio] iface-core.c: Assertion '(device_iface = pa_hashmap_get(c->sinks_by_index, PA_UINT32_TO_PTR(c->fallback_sink->index)))' failed at modules/dbus/iface-core.c:1710, function default_sink_changed_cb(). Aborting.
Feb 17 11:30:38 server systemd[699]: pulseaudio.service: Main process exited, code=dumped, status=6/ABRT
Feb 17 11:30:38 server systemd[699]: pulseaudio.service: Unit entered failed state.
Feb 17 11:30:38 server systemd[699]: pulseaudio.service: Failed with result 'core-dump'.
Feb 17 11:30:39 server systemd[699]: pulseaudio.service: Service hold-off time over, scheduling restart.
Feb 17 11:30:42 server systemd-coredump[6068]: Process 705 (pulseaudio) of user 1000 dumped core.
                                               
                                               Stack trace of thread 705:
                                               #0  0x00007ff63fd2a04f raise (libc.so.6)
                                               #1  0x00007ff63fd2b47a abort (libc.so.6)
                                               #2  0x00007ff6065b8a2a n/a (module-dbus-protocol.so)
                                               #3  0x00007ff641016c0c pa_hook_fire (libpulsecore-10.0.so)
                                               #4  0x00007ff641015d65 pa_core_update_default_sink (libpulsecore-10.0.so)
                                               #5  0x00007ff641038972 pa_sink_put (libpulsecore-10.0.so)
                                               #6  0x00007ff6373c4227 pa_alsa_sink_new (libalsa-util.so)
                                               #7  0x00007ff6375e6314 n/a (module-alsa-card.so)
                                               #8  0x00007ff641012aa6 pa_card_set_profile (libpulsecore-10.0.so)
                                               #9  0x00007ff6379f38a1 n/a (module-switch-on-port-available.so)
                                               #10 0x00007ff6379f3b11 n/a (module-switch-on-port-available.so)
                                               #11 0x00007ff641016c0c pa_hook_fire (libpulsecore-10.0.so)
                                               #12 0x00007ff6375e6ca3 n/a (module-alsa-card.so)
                                               #13 0x00007ff6373ac1f8 n/a (libalsa-util.so)
                                               #14 0x00007ff6370d4363 n/a (libasound.so.2)
                                               #15 0x00007ff6370ca02d snd_hctl_handle_events (libasound.so.2)
                                               #16 0x00007ff6370d5491 snd_mixer_handle_events (libasound.so.2)
                                               #17 0x00007ff6373b1807 n/a (libalsa-util.so)
                                               #18 0x00007ff640dbea7c pa_mainloop_dispatch (libpulse.so.0)
                                               #19 0x00007ff640dbee7c pa_mainloop_iterate (libpulse.so.0)
                                               #20 0x00007ff640dbef20 pa_mainloop_run (libpulse.so.0)
                                               #21 0x000000000040715a main (pulseaudio)
                                               #22 0x00007ff63fd17291 __libc_start_main (libc.so.6)
                                               #23 0x0000000000407c7a _start (pulseaudio)
                                               
                                               Stack trace of thread 715:
                                               #0  0x00007ff63fdd6551 ppoll (libc.so.6)
                                               #1  0x00007ff641021f38 pa_rtpoll_run (libpulsecore-10.0.so)
                                               #2  0x00007ff6373c8679 n/a (libalsa-util.so)
                                               #3  0x00007ff640b6b4b8 n/a (libpulsecommon-10.0.so)
                                               #4  0x00007ff6402a0454 start_thread (libpthread.so.0)
                                               #5  0x00007ff63fddf7df __clone (libc.so.6)
                                               
                                               Stack trace of thread 6066:
                                               #0  0x00007ff63fdd6551 ppoll (libc.so.6)
                                               #1  0x00007ff641021f38 pa_rtpoll_run (libpulsecore-10.0.so)
                                               #2  0x00007ff6373c2285 n/a (libalsa-util.so)
                                               #3  0x00007ff640b6b4b8 n/a (libpulsecommon-10.0.so)
                                               #4  0x00007ff6402a0454 start_thread (libpthread.so.0)
                                               #5  0x00007ff63fddf7df __clone (libc.so.6)
                                               
                                               Stack trace of thread 714:
                                               #0  0x00007ff63fdd6551 ppoll (libc.so.6)
                                               #1  0x00007ff641021f38 pa_rtpoll_run (libpulsecore-10.0.so)
                                               #2  0x00007ff6373c215e n/a (libalsa-util.so)
                                               #3  0x00007ff640b6b4b8 n/a (libpulsecommon-10.0.so)
                                               #4  0x00007ff6402a0454 start_thread (libpthread.so.0)
                                               #5  0x00007ff63fddf7df __clone (libc.so.6)
                                               
                                               Stack trace of thread 784:
                                               #0  0x00007ff63fdd6551 ppoll (libc.so.6)
                                               #1  0x00007ff641021f38 pa_rtpoll_run (libpulsecore-10.0.so)
                                               #2  0x00007ff626fe003e n/a (module-pipe-sink.so)
                                               #3  0x00007ff640b6b4b8 n/a (libpulsecommon-10.0.so)
                                               #4  0x00007ff6402a0454 start_thread (libpthread.so.0)
                                               #5  0x00007ff63fddf7df __clone (libc.so.6)
                                               
                                               Stack trace of thread 1073:
                                               #0  0x00007ff63fdd6551 ppoll (libc.so.6)
                                               #1  0x00007ff641021f38 pa_rtpoll_run (libpulsecore-10.0.so)
                                               #2  0x00007ff609d9bd1f n/a (module-null-sink.so)
                                               #3  0x00007ff640b6b4b8 n/a (libpulsecommon-10.0.so)
                                               #4  0x00007ff6402a0454 start_thread (libpthread.so.0)
                                               #5  0x00007ff63fddf7df __clone (libc.so.6)
Comment 12 Tanu Kaskinen 2017-02-17 14:43:43 UTC
You seem to be still running a pulseaudio version with the old patch. The assertion that crashes was removed in the new patch.

The "pactl list cards" output shows that pulseaudio thinks that the headphones are still plugged in:

analog-output-headphones: Headphones (priority: 9000, latency offset: 0 usec, available)

That's why the card profile doesn't get changed any more. If the headphones are really unplugged, you can check if it's a pulseaudio bug by looking at what alsa reports. This command will show all jack elements in alsa:

amixer --card=0 | grep Jack

For example, on my laptop the command prints

numid=21,iface=CARD,name='Dock Headphone Jack'
numid=19,iface=CARD,name='Dock Mic Jack'
numid=22,iface=CARD,name='Headphone Jack'
numid=18,iface=CARD,name='Internal Mic Phantom Jack'
numid=17,iface=CARD,name='Mic Jack'
numid=23,iface=CARD,name='SPDIF Phantom Jack'
numid=20,iface=CARD,name='Speaker Phantom Jack'

Out of those "Headphone Jack" is the one that tells the headphone jack status. To check the status, I can just copy the whole line and use it in this command:

amixer --card=0 cget numid=22,iface=CARD,name='Headphone Jack'

That prints

numid=22,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on

If the headphones are unplugged, the last line says "values=off" instead.
Comment 13 Tanu Kaskinen 2017-02-17 14:45:49 UTC
(In reply to Tanu Kaskinen from comment #12)
> That's why the card profile doesn't get changed any more. If the headphones
> are really unplugged, you can check if it's a pulseaudio bug by looking at
> what alsa reports. This command will show all jack elements in alsa:
> 
> amixer --card=0 | grep Jack

Sorry, wrong command. This is the right command:

amixer --card=0 controls | grep Jack
Comment 14 getzze 2017-02-17 15:26:20 UTC
Created attachment 129691 [details]
Output of `pactl list cards` with headset disconnected
Comment 15 getzze 2017-02-17 15:34:28 UTC
The value changes in `pactl` (see new attachment). And it is correctly changed in Alsa:
[disconnected]
>>>amixer --card=0 cget numid=44,iface=CARD,name='Front Headphone Jack'
numid=44,iface=CARD,name='Front Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off

[connected]
>>>amixer --card=0 cget numid=44,iface=CARD,name='Front Headphone Jack'
numid=44,iface=CARD,name='Front Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on


I will check again, maybe one pulseaudio module was still using the old patch.
Comment 16 Tanu Kaskinen 2017-02-17 15:39:12 UTC
The new pactl output also shows that the card profile changed to iec958. If the UI still says that the analog profile is active, then that's a bug in the UI code.
Comment 17 getzze 2017-02-17 17:24:25 UTC
Yes, I had made a mistake, it's working correctly with the new version of the patch! Thanks

Now when I disconnect the headset, the fallback is changed to my hdmi card (sink0) and immediately after to the integrated card without headphone (sink26, number upgraded each time I connect/disconnect).
Laine doesn't like the two immediate changes of fallback (but the dbus is still responsive!), but more importantly, maybe there could be a problem if there is only one card, so it cannot fallback to sink0. Is there a way to deactivate the hdmi card so I can test that?

Output from python.dbus when disconnected:

State changed to (dbus.ObjectPath('/org/pulseaudio/core1/sink0'),)
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUpdated', 'interface': 'org.PulseAudio.Core1'}
State changed to (dbus.ObjectPath('/org/pulseaudio/core1/sink26'),)
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUpdated', 'interface': 'org.PulseAudio.Core1'}
State changed to (dbus.UInt32(2),)
Comment 18 Tanu Kaskinen 2017-02-17 17:39:28 UTC
You can set the HDMI card profile to "off" in pavucontrol or with this pactl command:

pactl set-card-profile alsa_card.pci-0000_01_00.1 off

module-always-sink will load a null sink when the last sink is going away, so when you unplug the headphones, I think the default sink will quickly change from the analog sink to the null sink, and then from the null sink to the digital sink.

You can unload module-always-sink (pactl unload-module module-always-sink) to avoid loading the null sink, to test the case where the default sink becomes momentarily unset.
Comment 19 getzze 2017-02-17 17:48:52 UTC
It's working perfectly!

With module-always-sink loaded  (I guess sink41 is the null sink):

State changed to (dbus.ObjectPath('/org/pulseaudio/core1/sink41'),)
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUpdated', 'interface': 'org.PulseAudio.Core1'}
State changed to (dbus.ObjectPath('/org/pulseaudio/core1/sink42'),)
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUpdated', 'interface': 'org.PulseAudio.Core1'}
S

With module-always-sink unloaded:

State changed to ()
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUnset', 'interface': 'org.PulseAudio.Core1'}
State changed to (dbus.ObjectPath('/org/pulseaudio/core1/sink53'),)
{'sender': None, 'destination': None, 'path': dbus.ObjectPath('/org/pulseaudio/core1'), 'member': 'FallbackSinkUpdated', 'interface': 'org.PulseAudio.Core1'}


Exactly as expected!
Thanks a lot, it's solved as far as I'm concerned.


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.