Bug 95104 - [PATCH] KDE specific rule in start-pulseaudio-x11 should go
Summary: [PATCH] KDE specific rule in start-pulseaudio-x11 should go
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: daemon (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: 2016-04-24 13:20 UTC by markg85
Modified: 2018-07-30 10:34 UTC (History)
6 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch (724 bytes, patch)
2017-11-11 05:32 UTC, Nate Graham
Details | Splinter Review

Description markg85 2016-04-24 13:20:27 UTC
Hi,

PulseAudio 8.0 introduced a vastly improved "module-switch-on-connect" which i like to use in KDE/Plasma 5. However, switching input to other devies as they get connected doesn't seem to work under Plasma 5. It works just fine under GNOME.

So i investigated this issue a bit.
It turns out that "start-pulseaudio-x11" detects a full KDE session and does some specific module loading:

    if [ x"$KDE_FULL_SESSION" = x"true" ]; then
       /usr/bin/pactl load-module module-device-manager "do_routing=1" > /dev/null
    fi

In my case that very line was breaking module-switch-on-connect. Removing it made it work just as advertised in the PulseAudio 8.0 release notes.

I would like to ask to remove that line in the next release of PulseAudio. Perhaps it had it's reasons to be there in the past, but i can't seem to find any reason for that to still be needed. These days Plasma 5 also has a default volume applet that is meant for PulseAudio management. In fact, kmix isn't even part of the default install anymore (on ArchLinux at least).

Cheers,
Mark
Comment 1 Arun Raghavan 2016-04-25 12:47:54 UTC
Is there someone from KDE upstream who might be able to tell us what their preference in this case is?
Comment 2 David Rosca 2016-04-25 16:11:19 UTC
module-device-manager is used to set device priority per-role and can be configured from System Settings -> Multimedia -> Audio and Video. It has nothing to do with kmix nor plasma-pa.

I would prefer to keep this module loaded from start-pulseaudio-x11 when KDE_FULL_SESSION is true, otherwise that settings page (and routing with the configured priority) will not work at all.

I am maintainer of plasma-pa.
Comment 3 markg85 2016-04-25 17:52:30 UTC
(In reply to David Rosca from comment #2)
> module-device-manager is used to set device priority per-role and can be
> configured from System Settings -> Multimedia -> Audio and Video. It has
> nothing to do with kmix nor plasma-pa.
> 
> I would prefer to keep this module loaded from start-pulseaudio-x11 when
> KDE_FULL_SESSION is true, otherwise that settings page (and routing with the
> configured priority) will not work at all.
> 
> I am maintainer of plasma-pa.

If that is how it should be done, then why doesn't input switching workout of the box with PLasma 5? That should just work, right?
Comment 4 Störm Poorun 2016-06-25 08:42:20 UTC
(In reply to David Rosca from comment #2)
> module-device-manager is used to set device priority per-role and can be
> configured from System Settings -> Multimedia -> Audio and Video. It has
> nothing to do with kmix nor plasma-pa.
> 
> I would prefer to keep this module loaded from start-pulseaudio-x11 when
> KDE_FULL_SESSION is true, otherwise that settings page (and routing with the
> configured priority) will not work at all.
> 
> I am maintainer of plasma-pa.

So what's the alternative?

At the moment this behaviour apparently breaks automatic input switching as users plug/unplug audio devices. This is horrendous for the majority of users.

If the settings page doesn't work that it needs designing to, in the meantime it should be disabled by default (for the majority) and an option to enable it on for those users who need it.
Comment 5 markg85 2016-06-25 11:27:58 UTC
@Störm Poorun

Even if this weird module is pulled out from the pulseaudio startup, it still won't give input switching to usb devices. 

Unity (Ubuntu) loads the module-switch-on-connect and gives in my opinion the best user experience. That's for jack and usb headsets.

Plasma 5 has more than one issue to fix when it comes to usb input audio devices.
What does work with PLasma 5 at this moment is plugging in a jack headset. Then audio is redirected to that.
The fixes it needs to do to get USB working as well is:
1.Get rid of the module-device-manager in pulseaudio startup.
 -- now it still doesn't load module-switch-on-connect since it's not loaded by default --
2. Load module-switch-on-connect.

Then it's on par with Unity in terms of loaded modules and gives a wonderful user experience when plugging in a usb headset.

I'd also like to know why David Rosca is persistent in keeping this module. Even if the module would remain as is then your audio should still go to the usb headset when plugged in, so at the very least there would be a bug in the plasma-pa handling usb audio.


Lastly, i just looked for the module-device-manager code. It's not made by plasma (my bad there). It's a module of pulseaudio. So it might be the case that module-switch-on-connect and module-device-manager conflict with each other somehow. In that case it's "exposed" by plasma, but not a bug in plasma. It might as well be exposed by any other platform that happened to load both modules. So, ehh, pulseaudio devs, could someone please load those modules at the same time, plugin a usb headset and debug if the issue is within those modules? I'd be happy to do that, but i have no clue where to start. Could it be a wrong priority order when "do_routing=1" is defined?
Comment 6 Tanu Kaskinen 2016-06-28 15:18:22 UTC
(In reply to markg85 from comment #5)
> So, ehh, pulseaudio devs, could someone please load those
> modules at the same time, plugin a usb headset and debug if the issue is
> within those modules? I'd be happy to do that, but i have no clue where to
> start. Could it be a wrong priority order when "do_routing=1" is defined?

Unfortunately, there's no way to quickly test module-device-manager outside a KDE environment, because we lack command line tools to configure the device priorities. I can only say that I'm not surprised at all if module-device-manager doesn't play nicely with module-switch-on-connect, because both modules try to control the stream routing using different logic. The two modules aren't designed to be used together.
Comment 7 Rudd-O 2016-09-19 18:13:04 UTC
It would seem that module-device-manager would need to swallow module-switch-on-connect (and the KDE GUI updated to support policy setting for on-connect devices).
Comment 8 Horst Schirmeier 2017-10-21 19:23:20 UTC
This bug now made it to Ubuntu 17.10: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1720519
Comment 9 Nate Graham 2017-11-11 05:32:45 UTC
Created attachment 135391 [details] [review]
Patch

Trivial patch attached. We should remove this workaround since it's breaking PulseAudio in Kubuntu. There are no known regressions with these lines removed.
Comment 10 Woden Cafe 2017-11-24 15:43:10 UTC
I have now encountered this too after upgrading to Kubuntu 17.10:

E: [pulseaudio] module.c: Module "module-switch-on-connect" should be loaded once at most. Refusing to load.
E: [pulseaudio] main.c: Module load failed.
E: [pulseaudio] main.c: Failed to initialize daemon.
Comment 11 Tanu Kaskinen 2017-12-02 15:00:05 UTC
So KDE has started to use GConf for loading module-switch-on-connect. That's not good. The GConf interface will be removed as soon as someone ports paprefs away from it. The "should be loaded once at most" error will be gone in PulseAudio 12.0, but that doesn't change the fact that KDE is using an unsupported interface that may go away at any moment.

This is the patch that removes the "should be loaded once at most" error, in case e.g. Kubuntu wants to apply it before the 12.0 release: https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=f0dfddead3cf1ff7af4c9c09a8027fde26065003

It's a bit unclear to me whether KDE plans to continue using module-device-manager. I hope David Rosca can comment on that. As long as KDE depends on that module, it can't be removed from start-pulseaudio-x11.
Comment 12 David Rosca 2017-12-02 15:49:50 UTC
module-device-manager is used in KDE Phonon Audio and Video settings, which was already discussed about removing it in past and there are also some other issues with it. I maintain only plasma-pa, not the Phonon settings.

If there really is some issue with it, I think it can be removed from start-pulseaudio-x11 and it will either be loaded by KDE or it will be the last push to phase out this settings from KDE. I personally am not against it.

The current situation in plasma-pa (which I do maintain) is that we use GConf to permanently enable/disable modules (eg. to be remembered after pulseaudio restart). There have been voices against this too, so I would also like to ask here what should we use instead?
Comment 13 Tanu Kaskinen 2017-12-02 16:07:23 UTC
plasma-pa starts in the beginning of a login session, right? Maybe it could use libpulse to load module-switch-on-connect every time it starts?

What to do with module-device-manager is up to KDE to decide. Who's maintaining the Phonon audio and video settings app?
Comment 14 Tanu Kaskinen 2017-12-02 16:13:02 UTC
Adding to my previous comment: it would be nice to have an API for managing the persistent module configuration, but no such API exists at the moment (apart from GConf). I hope we'll have such API some day (it's probably required for getting rid of GConf anyway).
Comment 15 David Rosca 2017-12-02 16:34:45 UTC
(In reply to Tanu Kaskinen from comment #13)
> plasma-pa starts in the beginning of a login session, right? Maybe it could
> use libpulse to load module-switch-on-connect every time it starts?
This should work, I was hoping for more elegant solution though :)

> What to do with module-device-manager is up to KDE to decide. Who's
> maintaining the Phonon audio and video settings app?
Harald Sitter, though I'm not sure if he still is.
Comment 16 Nate Graham 2018-03-21 03:28:14 UTC
(In reply to David Rosca from comment #15)
> (In reply to Tanu Kaskinen from comment #13)
> > plasma-pa starts in the beginning of a login session, right? Maybe it could
> > use libpulse to load module-switch-on-connect every time it starts?
> This should work, I was hoping for more elegant solution though :)

David, so we have a downstream KDE Bugzilla ticket tracking this?
Comment 17 GitLab Migration User 2018-07-30 10:34: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/509.


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.