Bug 365723 - Disconnected pulseaudio outputs not hidden in drop-down list
Summary: Disconnected pulseaudio outputs not hidden in drop-down list
Status: RESOLVED FIXED
Alias: None
Product: plasma-pa
Classification: Plasma
Component: kcm (show other bugs)
Version: 5.12.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Rosca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-15 20:17 UTC by Bernie Innocenti
Modified: 2018-07-14 13:33 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
KDE shows inactive outputs alongside the active ones (83.85 KB, image/png)
2016-07-15 20:19 UTC, Bernie Innocenti
Details
Cinnamon only shows connected sound outputs (38.12 KB, image/png)
2016-07-15 20:21 UTC, Bernie Innocenti
Details
Gnome control center similarly filters the unconnected outputs (27.21 KB, image/png)
2016-07-15 20:30 UTC, Bernie Innocenti
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernie Innocenti 2016-07-15 20:17:56 UTC
My system has 3 HDMI outputs, each with 3 speaker options. Thus, the drop-down menu becomes very long and it is hard to select the correct option (HDMI1 and HDMI3 are disconnected).

See attached screenshots comparing kcm_pulseaudio against the cinnamon-settings UI.

Reproducible: Always
Comment 1 Bernie Innocenti 2016-07-15 20:19:34 UTC
Created attachment 100115 [details]
KDE shows inactive outputs alongside the active ones
Comment 2 Bernie Innocenti 2016-07-15 20:21:26 UTC
Created attachment 100116 [details]
Cinnamon only shows connected sound outputs
Comment 3 Bernie Innocenti 2016-07-15 20:30:13 UTC
Created attachment 100117 [details]
Gnome control center similarly filters the unconnected outputs
Comment 4 David Rosca 2016-07-19 09:51:23 UTC
The ui of kcm actually tries to offer same options as pavucontrol, not the ones that you mentioned.
Comment 5 Bernie Innocenti 2016-07-21 19:30:45 UTC
kcm_pulseaudio uses a loop like this to fill-in the profiles drop-down:

    for (auto **it = info->profiles2; it && *it != nullptr; ++it) {
        Profile *profile = new Profile(this);
        profile->setInfo(*it);
        m_profiles.append(profile);
        if (info->active_profile2 == *it) {
            m_activeProfileIndex = m_profiles.length() - 1;
        }
    }

I added some logging and found that checking (*it)->available is not enough to tell if a profile should be enabled. It seems that all profiles have available == 1.

Next, I looked at the corresponding code in pavucontrol: for each profile, it looks at all the ports. If the profile appears in port.profiles, it checks if the port is in state PA_PORT_AVAILABLE_NO:

    for (std::set<pa_card_profile_info2>::iterator profileIt = profile_priorities.begin(); profileIt != profile_priorities.end(); ++profileIt) {
        bool hasNo = false, hasOther = false;
        std::map<Glib::ustring, PortInfo>::iterator portIt;
        Glib::ustring desc = profileIt->description;

        for (portIt = w->ports.begin(); portIt != w->ports.end(); portIt++) {
            PortInfo port = portIt->second;

            if (std::find(port.profiles.begin(), port.profiles.end(), profileIt->name) == port.profiles.end())
                continue;

            if (port.available == PA_PORT_AVAILABLE_NO)
                hasNo = true;
            else {
                hasOther = true;
                break;
            }
        }
        if (hasNo && !hasOther)
            desc += _(" (unplugged)");

        if (!profileIt->available)
            desc += _(" (unavailable)");

        w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(profileIt->name, desc));
    }

The "hasNo && !hasOther" thing is pretty confusing. I guess what they really meant is: "mark the profile as unplugged if all its ports are in state PA_PORT_AVAILABLE_NO".

So we could do something similar in plasma-pa... I would prefer not to see the unplugged profiles at all in the list (like Gnome and Cinnamon do it). Grayed-out would also work, but it seems more clutter.
Comment 6 Bernie Innocenti 2017-06-06 04:42:05 UTC
Still present in Plasma 5.10.0.
Comment 7 Nate Graham 2018-02-04 16:10:16 UTC
There's a patch for this: https://phabricator.kde.org/D10148
Comment 8 David Rosca 2018-02-10 12:50:09 UTC
Git commit 1e644e5723df6d7e6ed2f4a6bf71dd694bb5aa97 by David Rosca.
Committed on 10/02/2018 at 12:49.
Pushed by drosca into branch 'master'.

KCM: Show only available device profiles

Differential Revision: https://phabricator.kde.org/D10148

M  +6    -4    src/kcm/package/contents/ui/CardListItem.qml

https://commits.kde.org/plasma-pa/1e644e5723df6d7e6ed2f4a6bf71dd694bb5aa97
Comment 9 Christoph Feck 2018-02-28 23:13:31 UTC
Did the previous commit resolve this issue?
Comment 10 Bernie Innocenti 2018-03-06 11:23:08 UTC
I'm still seeing see disconnected outputs in the drop-down list with plasma-pa 5.12.2.

Looks like your commit isn't present on the 5.12 branch, could you please cherry-pick? Building from git is a bit hard for me at the moment.
Comment 11 Nate Graham 2018-03-06 11:27:04 UTC
It was committed to master, which means it'll wind up in 5.13. You can try it out with KDE Neon dev unstable, which has commits from master.