Bug 93903 - Unplugging headphones changes Build in Audio profile from analog to digital
Summary: Unplugging headphones changes Build in Audio profile from analog to digital
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
: 93986 96237 (view as bug list)
Depends on:
Blocks: 93823
  Show dependency treegraph
 
Reported: 2016-01-28 12:45 UTC by Apostolos B.
Modified: 2018-07-30 10:23 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments
log file (2.46 KB, text/plain)
2016-01-29 09:53 UTC, Apostolos B.
Details
correct log (339.93 KB, text/plain)
2016-01-29 12:23 UTC, Apostolos B.
Details
Routing change patch (2.01 KB, patch)
2016-01-29 19:32 UTC, David Henningsson
Details | Splinter Review
Pulse Log incorrect switching (648.56 KB, text/plain)
2017-01-06 19:48 UTC, flat
Details
digital/5.1 - stereo out/digital (1.33 MB, text/plain)
2017-01-17 13:57 UTC, flat
Details
0001-card-log-the-reason-for-profile-changes.patch (13.45 KB, patch)
2017-01-27 11:19 UTC, Tanu Kaskinen
Details | Splinter Review
pulse verbose log with 0001-card-log-the-reason-for-profile-changes.patch (1.28 MB, text/plain)
2017-01-27 19:38 UTC, flat
Details
0001-card-log-the-reason-for-profile-changes.patch (for 10.0) (16.29 KB, patch)
2017-01-30 09:11 UTC, Tanu Kaskinen
Details | Splinter Review
pulse audio verbose log with 0001-card-log-the-reason-for-profile-changes.patch 10.0 (1.06 MB, text/plain)
2017-02-01 00:47 UTC, flat
Details
pulse audio verbose log with 0001-card-log-the-reason-for-profile-changes.patch 10.0 (1.64 MB, text/plain)
2017-02-03 17:50 UTC, flat
Details
pulse audio verbose log (377.78 KB, text/plain)
2017-05-29 18:02 UTC, pablow.1422
Details

Description Apostolos B. 2016-01-28 12:45:17 UTC
After the update to Pulseaudio 8.0 i get the below behavior.

Plugging in headphones changes the Build in Analog stereo out from Line Out to Headphones. (as it should)

Unplugging it makes the Build in Analog stereo out disappear and changes it to Build in Digital stereo with SPDIF as an out option.

The only way to fix it -have sound again since there is nothing connected to spdif- is to change the configuration from pavucontrol Configuration > Build in Audio profile or log out and log in again in case you don't have pavucontrol installed.
Comment 1 Tanu Kaskinen 2016-01-28 14:45:01 UTC
That sounds like a pretty bad regression. I'll mark this as a release blocker for 9.0.
Comment 2 Apostolos B. 2016-01-28 15:24:06 UTC
Is this something that can be fixed in a point/bugfix release or it is something more difficult to solve?
Comment 3 Tanu Kaskinen 2016-01-28 15:42:25 UTC
It's not obvious to me how to fix this. It might turn out to be simple or it might be complex. I don't promise to start working on this quickly (there are other important bugs on my list first), but maybe David would be interested to work on this.
Comment 4 David Henningsson 2016-01-29 09:30:33 UTC
Thanks for the bug report, I will need a PulseAudio verbose log to research further. Could you attach one? 

https://wiki.ubuntu.com/PulseAudio/Log 

Please both plug and unplug headphones while the log is active. Thanks!
Comment 5 Apostolos B. 2016-01-29 09:53:36 UTC
Created attachment 121383 [details]
log file

Not sure the method on the link gives the results you would expect but here goes.
Comment 6 David Henningsson 2016-01-29 12:11:32 UTC
(In reply to Apostolos B. from comment #5)
> Created attachment 121383 [details]
> log file
> 
> Not sure the method on the link gives the results you would expect but here
> goes.

No, apparently pulseaudio either failed to kill or respawned for some reason. Not sure how ARCH spawns pulseaudio, but make sure pulseaudio is not running before starting the log. Thanks!
Comment 7 Tanu Kaskinen 2016-01-29 12:17:26 UTC
This should stop pulseaudio and prevent respawns on Arch:

systemctl --user stop pulseaudio.socket pulseaudio.service

To restore the system back to normal functioning, run this:

systemctl --user start pulseaudio.socket
Comment 8 Apostolos B. 2016-01-29 12:23:47 UTC
Created attachment 121389 [details]
correct log

That will do it i believe.
Comment 9 David Henningsson 2016-01-29 15:08:10 UTC
(   0.178|   0.000) D: [pulseaudio] module-alsa-card.c: Jack 'Line Out Front Jack' is now unplugged
(   0.178|   0.000) D: [pulseaudio] module-alsa-card.c: Jack 'Line Out CLFE Jack' is now unplugged
(   0.178|   0.000) D: [pulseaudio] module-alsa-card.c: Jack 'Line Out Surround Jack' is now unplugged
(   0.178|   0.000) D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged

Since your line-out jack (the front/main one) is unplugged, I believe we're doing the right thing by switching to something else (i e, in your case the digital output, for which do not know the jack status).

Do you actually have something plugged into your line out jack, or why do you want analog line out to be selected?
Comment 10 Apostolos B. 2016-01-29 15:48:21 UTC
I have nothing connected true but if i unplug and plug the headphones again it stays to the digital out (which also has nothing connected to it) and i have no sound on the headphones.
Comment 11 David Henningsson 2016-01-29 19:31:39 UTC
Ah, so the problem is that it does not switch to headphones rather than it switches from them; although this happened to be less of a problem in earlier versions because it stayed on the same profile.

I'm going to attach a patch now, can you test it? And if it does not work, could you submit another pulseaudio log which also includes you plugging in headphones while on the digital profile?

Thanks!
Comment 12 David Henningsson 2016-01-29 19:32:18 UTC
Created attachment 121395 [details] [review]
Routing change patch
Comment 13 Nick Sarnie 2016-01-30 17:26:21 UTC
(In reply to David Henningsson from comment #12)
> Created attachment 121395 [details] [review] [review]
> Routing change patch

This patch fixes the issue for me.

Tested-by: Nick Sarnie <commendsarnex@gmail.com>
Comment 14 Björn Lindqvist 2016-01-30 17:37:27 UTC
Can you please note my bug report filed here: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1521987 ?

It is supposedly about the same problem, and I've produced a lot of logs and description of how the problem works.
Comment 15 Apostolos B. 2016-02-02 14:05:05 UTC
@David

I can't test right now on the system i get the bug (its my stable one) and on my other system i don't have HW (digital out) to test. 

@sarnes reported it fixed his issue (assuming it was the same as mine) so it believe it works. 

Maybe others can chime in.
Comment 16 Tanu Kaskinen 2016-02-03 15:02:29 UTC
*** Bug 93986 has been marked as a duplicate of this bug. ***
Comment 17 Benjamin Robin 2016-02-03 17:49:09 UTC
The patch (Routing change patch) https://bugs.freedesktop.org/attachment.cgi?id=121395 fixes the problem (at least for my reported bug: sorry for the duplicate...)
Comment 18 Tanu Kaskinen 2016-02-26 13:46:42 UTC
The fix is now in master.
Comment 19 Tanu Kaskinen 2016-05-27 10:47:03 UTC
*** Bug 96237 has been marked as a duplicate of this bug. ***
Comment 20 Heinz 2016-07-02 13:25:12 UTC
Just to let you know: 

I had a similar bug with Fedora 24 which drove me nuts. Analog output was always switched back to digital, losing sound. Changing it in pavucontrol didn't last longer than a few seconds. With the patch from comment 12, my problem is fixed!
Comment 21 Eugene Crosser 2016-08-01 08:16:11 UTC
I am not sure that the suggested patch is a good fix for the problem.
As I understand it, with the patch, when the currently active destination becomes unavailable, new destination is chosen on the basis of its priority.

Now consider my own use case:
I have S/PDIF and Analog outputs on the chip, but S/PDIF is not connected to anywhere (there is no connector on the box). I have speakers permanently connected to the analog "line out" socket. And I use headphones intermittently. Normally, desktop's audio widget configures "line out" as active, which is what I want. When I plug the headphones, they automatically become active, and speakers are muted, which is what I want, again. But, when I unplug the headphones, (unconnected) S/PDIF becomes active instead of the speakers, and I lose sound until I manually reconfigure the output via the audio widget.

I think that my scenario is quite typical (it happens both on my desktop and notebook computers), and should be addressed better.

Thank you.
Comment 22 Tanu Kaskinen 2016-08-07 15:56:19 UTC
I believe PulseAudio 9.0 will handle your use case well. Please report back if it doesn't.
Comment 23 Eugene Crosser 2016-10-16 19:43:17 UTC
(In reply to Tanu Kaskinen from comment #22)
> I believe PulseAudio 9.0 will handle your use case well. Please report back
> if it doesn't.

It does not.
Version: 1:9.0-2ubuntu2
Same behavior: after plugging and unplugging the headset some nonexistent device becomes active, and I have no sound until I manually select "line out".
Comment 24 Tanu Kaskinen 2016-10-21 11:58:11 UTC
Do you happen to have the audio settings application open? If you do, it can mess up the device selection: https://bugzilla.gnome.org/show_bug.cgi?id=762932
Comment 25 Eugene Crosser 2016-10-21 14:16:11 UTC
(In reply to Tanu Kaskinen from comment #24)
> Do you happen to have the audio settings application open? If you do, it can
> mess up the device selection:
> https://bugzilla.gnome.org/show_bug.cgi?id=762932

It happens when audio control application running and not running likewise, but desktop's audio widget in the panel is indeed running (Cinnamon and Unity, same manifestations). It is possible that this audio widget is indeed the culprit.
Comment 26 Tanu Kaskinen 2016-10-24 15:02:49 UTC
(In reply to Eugene Crosser from comment #25)
> It happens when audio control application running and not running likewise,
> but desktop's audio widget in the panel is indeed running (Cinnamon and
> Unity, same manifestations). It is possible that this audio widget is indeed
> the culprit.

It's possible, but I don't think it's likely.

Can you attach a log file that shows what happens when you start with analog output selected and headphones plugged in, and then unplug them and plug them back in? Instructions for getting the log: https://wiki.ubuntu.com/PulseAudio/Log
Comment 27 flat 2017-01-06 19:48:57 UTC
Created attachment 128797 [details]
Pulse Log incorrect switching

Log that should show pulse incorrectly switching to digital when it should switch back to the previous configuration for speakers.
Comment 28 flat 2017-01-06 19:50:20 UTC
In my case speakers should be set to Analog Surround 5.1 Output + Analog Stereo Input, however after unplugging headphones they are switched to digital out.
Comment 29 Tanu Kaskinen 2017-01-17 03:50:13 UTC
The log doesn't match your problem description. The digital profile is not activated at all. The log shows switching between headphones and lineout in 2.1 mode. You wanted to use 5.1, so is your problem actually that you get 2.1 audio instead of 5.1?
Comment 30 flat 2017-01-17 13:57:17 UTC
Created attachment 128999 [details]
digital/5.1 - stereo out/digital

Sorry, this bug isn't consistent so that last log may not have reflected the issue. This _should_ show that it starts my headphones as digital out, upon unplugging the line out should be switched to 5.1. Again plugging in headphones changes the output to digital. After setting the headphones to stereo out via pulse audio volume control, unplugging the headphones sets the configuration back to digital.
Comment 31 Tanu Kaskinen 2017-01-24 06:53:21 UTC
Thanks, the log is interesting. At line 5943 the headphones are plugged in. Pulseaudio then decides to switch from the 5.1 profile to the analog stereo profile, as expected. After switching the profile, however, pulseaudio decides to immediately switch to digital output instead. Unfortunately the log doesn't show why this happens.

If I write a patch that adds better logging, will you be able to apply and test it? Here are some instructions for building and installing pulseaudio from source: https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/PulseAudioFromGit/
Comment 32 flat 2017-01-24 15:39:39 UTC
Sure, if you write a patch I will compile and test it.
Comment 33 Tanu Kaskinen 2017-01-27 11:19:24 UTC
Created attachment 129175 [details] [review]
0001-card-log-the-reason-for-profile-changes.patch

Here's the patch. It's written against the git master branch. If you need it for some other PulseAudio version, let me know and I'll rebase it.
Comment 34 flat 2017-01-27 19:38:33 UTC
Created attachment 129184 [details]
pulse verbose log with 0001-card-log-the-reason-for-profile-changes.patch

So interestingly enough I can't reproduce the issue using git master. Attached are two logs as one attachment. The second log starts at line 5308 (Didn't want to spam attachments). The first log shows pulse crashing upon disconnecting the headphones. The second log shows pulse switching between 5.1-stereo and Analog Stereo working fine. If you rebase the patch on 10.0 I can try it again to see what was going on. Version 10.0 is the current version from Arch Linux's repos. I assume a commit since then must have fixed something either intentionally or unintentionally.
Comment 35 Tanu Kaskinen 2017-01-30 08:24:32 UTC
(In reply to flat from comment #34)
> Created attachment 129184 [details]
> pulse verbose log with 0001-card-log-the-reason-for-profile-changes.patch
> 
> So interestingly enough I can't reproduce the issue using git master.

The first log with the crash shows a switch to the digital profile. Unfortunately, the crash happens before the log message I added is printed.

The first log shows four "audio-volume-change" sounds being played in quick succession during the crash. The volume changes are initiated by gnome-settings-daemon. Did you change the volume manually while disconnecting the headphones, or is this something that gnome-settings-daemon does automatically?

> Attached are two logs as one attachment. The second log starts at line 5308
> (Didn't want to spam attachments). The first log shows pulse crashing upon
> disconnecting the headphones. The second log shows pulse switching between
> 5.1-stereo and Analog Stereo working fine. If you rebase the patch on 10.0 I
> can try it again to see what was going on. Version 10.0 is the current
> version from Arch Linux's repos. I assume a commit since then must have
> fixed something either intentionally or unintentionally.

I don't think it's fixed in master, but I can anyway make a patch for 10.0. I'll change it so that the profile change reason is printed in an earlier phase. I'll also add some logging in an attempt to make it easier to track down the reason for the crash if it happens again.
Comment 36 Tanu Kaskinen 2017-01-30 09:11:20 UTC
Created attachment 129226 [details] [review]
0001-card-log-the-reason-for-profile-changes.patch (for 10.0)

Here's the updated patch.
Comment 37 flat 2017-02-01 00:47:39 UTC
Created attachment 129265 [details]
pulse audio verbose log with 0001-card-log-the-reason-for-profile-changes.patch 10.0

Here is the log from the new rebased patch. The bug did occur in git master but not as often.

>The first log shows four "audio-volume-change" sounds being played in quick
>succession during the crash. The volume changes are initiated by gnome-settings-daemon.
>Did you change the volume manually while disconnecting the headphones, or is this something that gnome-settings-daemon does automatically?

I'm not sure if that was me or not. I usually tap the volume key a couple times to see what output configuration it is set on because it's quick. This time I didn't touch the volume manually.

The log should show it switching from 5.1 to digital then digital to 5.1 and then 5.1 to stereo duplex and then stereo duplex to digital.
Comment 38 Tanu Kaskinen 2017-02-01 09:01:41 UTC
The new log doesn't seem to have the patch applied. Can you try again? You can check that pulseaudio is running with the patch by searching the log for messages that contain "XXX" that are printed whenever the card profile changes.
Comment 39 flat 2017-02-03 17:50:05 UTC
Created attachment 129322 [details]
pulse audio verbose log with 0001-card-log-the-reason-for-profile-changes.patch 10.0

Sorry it took a couple days for it to happen again. Guess it helps when you compile to actually apply the patch... haha. Here's a log from it switching between digital and normal, even after I set it to the correct configurations it seems to switch. Looking through the log I think it might have to do with budgie-panel, but I'm not sure. Also got another crash so that's the first log. Second log starts on line 4424
Comment 40 flat 2017-02-05 17:54:24 UTC
Same issue on xfce4, so it's not budgie.
Comment 41 Tanu Kaskinen 2017-04-04 08:28:01 UTC
Sorry for the long delay, I have trouble keeping up with all email...

(In reply to flat from comment #39)
> Created attachment 129322 [details]
> pulse audio verbose log with
> 0001-card-log-the-reason-for-profile-changes.patch 10.0
> 
> Sorry it took a couple days for it to happen again. Guess it helps when you
> compile to actually apply the patch... haha. Here's a log from it switching
> between digital and normal, even after I set it to the correct
> configurations it seems to switch. Looking through the log I think it might
> have to do with budgie-panel, but I'm not sure.

Yes, "Budgie Volume Control" changes the profile to digital.

> Also got another crash so
> that's the first log. Second log starts on line 4424

It's not a crash, it's a failure to start the daemon. module-esound-protocol-unix can't setup itself, because the socket it needs is reserved by some other process (probably another pulseaudio instance). I'm not sure why this happens, but you can safely remove module-esound-protocol-unix from /etc/pulse/default.pa. It's extremely unlikely that you have any applications that still use esound.
Comment 42 Tanu Kaskinen 2017-04-04 08:30:07 UTC
(In reply to flat from comment #40)
> Same issue on xfce4, so it's not budgie.

It certainly was Budgie according to the log. Maybe xfce4 has a similar bug in its volume control thingy.
Comment 43 flat 2017-04-04 23:50:47 UTC
(In reply to Tanu Kaskinen from comment #42)
> (In reply to flat from comment #40)
> > Same issue on xfce4, so it's not budgie.
> 
> It certainly was Budgie according to the log. Maybe xfce4 has a similar bug
> in its volume control thingy.

No problem on the delay, thanks for taking the time to look into this. I'll file a bug report with budgie.
Comment 44 pablow.1422 2017-05-29 18:02:34 UTC
Created attachment 131569 [details]
pulse audio verbose log

Same problem and use case: analog line-out speakers, headphone plugged-in, headphone unplugged, digital output profile set instead of analog line-out (Analog Duplex to be precise). 

It happens on Fedora 25 (10.0-2.fc25) and openSUSE tumbleweed (can't have access to that PC right now), both running KDE Plasma desktop (5.9.5).

KDE devs said it should be reported here [https://bugs.kde.org/show_bug.cgi?id=380316#add_comment]
Comment 45 pablow.1422 2017-06-01 15:10:14 UTC
(In reply to pablow.1422 from comment #44)
> Created attachment 131569 [details]
> pulse audio verbose log
> 
> Same problem and use case: analog line-out speakers, headphone plugged-in,
> headphone unplugged, digital output profile set instead of analog line-out
> (Analog Duplex to be precise). 
> 
> It happens on Fedora 25 (10.0-2.fc25) and openSUSE tumbleweed (can't have
> access to that PC right now), both running KDE Plasma desktop (5.9.5).
> 
> KDE devs said it should be reported here
> [https://bugs.kde.org/show_bug.cgi?id=380316#add_comment]

Never mind. Something in the miniplug speaker contact was preventing the detection of the port as being connected. Sorry for the useless reply.
Comment 46 GitLab Migration User 2018-07-30 10:23:22 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/390.


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.