Bug 392117 - Checking "Automatically switch all running streams when a new output becomes available" unconditionally loads switch-on-connect module without looking to see if it's already loaded
Summary: Checking "Automatically switch all running streams when a new output becomes ...
Status: RESOLVED UPSTREAM
Alias: None
Product: plasma-pa
Classification: Plasma
Component: general (show other bugs)
Version: 5.12.3
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: David Rosca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-21 04:33 UTC by Nate Graham
Modified: 2018-10-08 20:07 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2018-03-21 04:33:47 UTC
The PulseAudio switch-on-connect module can only be loaded once in PulseAudio <= 11, or else PulseAudio will crash (https://bugs.freedesktop.org/show_bug.cgi?id=95104). This PulseAudio bug was recently fixed in the upcoming PulseAudio 12 release (https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=f0dfddead3cf1ff7af4c9c09a8027fde26065003), but that's still unreleased and a long way off for many of our users.

Plasma-pa has a checkbox for "Automatically switch all running streams when a new output becomes available" that loads the module when checked. But it does so unconditionally, without first checking to see if the module is already loaded. If the module is already loaded, checking this checkbox will crash PulseAudio 11 and earlier.

This caused a downstream bug in Kubuntu for many users after the Ubuntu devs tried loading the switch-on-connect module by default to improve usability: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1720519

Likely for this reason, plasma-pa has the checkbox unchecked by default, to avoid crashing PulseAudio in any distros that enable the module by default.

However, this means that by default, users don't get the generally desirable switch-on-connect behavior unless their distro loads the module by default--and even then, the users need to avoid touching the checkbox in plasma-pa or else they'll break PulseAudio on their systems.
Comment 1 David Edmundson 2018-03-21 12:02:20 UTC
>Likely for this reason, plasma-pa has the checkbox unchecked by default

That isn't the reason. I know because I wrote the switch on connect UI.
It is not a better setting, merely a different one..
Comment 2 David Edmundson 2018-03-21 12:42:36 UTC
I rechecked the code, we don't load the module directly.

We update gconf, which we know pulseaudio has a module to follow, which in turn loads the module. I don't think there's any way we can avoid the double load at our level. Sorry
Comment 3 David Rosca 2018-03-21 12:58:49 UTC
Also this is an issue that comes from distribution-specific patch, it should be fixed there.

module-switch-on-connect is not enabled by default upstream for a reason. If it ever becomes enabled by default, then I assume it will be either only for non-KDE session or module-device-manager won't be loaded in KDE session anymore. 

Certainly not the way it was done by Ubuntu patch.
Comment 4 Nate Graham 2018-03-21 13:08:00 UTC
Upstream says we shouldn't be using gconf in the first place: https://bugs.freedesktop.org/show_bug.cgi?id=95104#c11
Comment 5 David Edmundson 2018-03-21 13:14:20 UTC
Two lines later

> but no such API exists at the moment (apart from GConf)

We're limited into using things that exist. If pulseuadio add an alternative, I'd happily do the port
Comment 6 David Rosca 2018-03-21 13:24:41 UTC
> Upstream says we shouldn't be using gconf in the first place:

gconf is not to blame here, ubuntu is.

Alternative to pulseaudio gconf module, as suggested, is to effectively reimplement what it is doing (eg. manually track loaded modules and load/unload what we want on each pulseaudio startup). It may be necessary in future, but right now we can still use gconf.