Skip to content

Conversation

@mmstick
Copy link
Member

@mmstick mmstick commented Oct 20, 2025

Closes #1325
Closes #1577
Closes pop-os/cosmic-epoch#655
Closes pop-os/cosmic-epoch#787
Closes pop-os/cosmic-epoch#946
Closes pop-os/cosmic-epoch#1001
Closes pop-os/cosmic-epoch#568
Closes pop-os/cosmic-epoch#1368

  • Device profiles have been moved into a new Device Profiles sub-page for selecting profiles per device
    • Set with wpctl set-profile {{device-id}} {profile-index}} instead of pactl
  • Setting the default sink (output) and source (input) now operates independently
    • Set with wpctl set-default {{node-id}}
  • All of our devices now have stable node object and device IDs from pipewire-rs
    - Enables using wpctl for setting card profiles, default sinks/sources, volume, and mute
    - Significant performance and stability improvements
    - Wireplumber state no longer gets corrupted
  • Fixed early return on debounced volume events dropping pipewire and pulse events
  • Update pipewire-rs to version 0.9
  • Most of our dependency on libpulse has been eliminated
    • It is only used for getting and setting volume, volume balance, and watching default sink/source changes

@mmstick mmstick requested review from a team October 20, 2025 14:18
Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, there's an overflow/sizing issue with the drop-down box on the Device Profiles page. By default, I had no profile selected (not even "Off"), which seems impossible. In that state, most of the drop-down items flowed out of the end of the window:

Image

It seems like longer labels being selected allowed the drop-down to display more of its contents:

Image Image

Separate issue, but after I selected "Off" as my profile, the device disappeared from the list, making it impossible to turn on again. The point of the "Off" option is to still show the device in the list while it's disabled, so that shouldn't happen.

Image

@mmstick
Copy link
Member Author

mmstick commented Oct 20, 2025

What's the output of pw-dump on this system? This is what I see on a system with a Realtek card, Radeon HDMI audio, and a USB-C sound card.

Screenshot_2025-10-20_19-25-58 Screenshot_2025-10-20_19-27-00

@mmstick
Copy link
Member Author

mmstick commented Oct 21, 2025

Fixed the devices on the device profiles page disappearing when setting their profile to off. Which also fixes the device briefly disappearing when the device's nodes are replaced.

wash2
wash2 previously approved these changes Oct 21, 2025
@jackpot51 jackpot51 requested a review from jacobgkau October 21, 2025 16:31
Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the same machine as yesterday, I still had one of the devices not have any profile visibly selected at first, which shouldn't be possible:

Screenshot_2025-10-21_11-21-24

Here is pw-dump from that system: pw-dump-oryp8.txt

If I set the device to "Off", it initially shows itself as "Off", but if I reboot, I end up in the same state as shown above (it boots up set to nothing instead of showing as set to "Off".)

@jacobgkau
Copy link
Member

jacobgkau commented Oct 21, 2025

I'm still also seeing menu items getting cut off at the edge of the window. Is that a libcosmic bug? Dropdown menus in other COSMIC apps seem to be able to run out the side of the window.

@mmstick
Copy link
Member Author

mmstick commented Oct 21, 2025

It's a different dropdown widget. I will switch to it

wash2
wash2 previously approved these changes Oct 21, 2025
@mmstick
Copy link
Member Author

mmstick commented Oct 21, 2025

The index of the selected profile on that Built-in Audio device should be fixed now

@mmstick mmstick requested a review from jacobgkau October 21, 2025 18:08
@jacobgkau
Copy link
Member

jacobgkau commented Oct 21, 2025

On 8688b54 and oryp8, the profile of Built-in Audio keeps defaulting to Digital Surround 5.1 (IEC958/AC3) Output. I think this corresponds to the S/PDIF output, but attempting to change the volume does nothing. Going directly to Digital Stereo (IEC958) Output doesn't work, but if I choose Off, then I can go to Digital Stereo (IEC958) Output to get sound out of the S/PDIF port (the Digital Surround option then gives distorted audio if I select that again).

If I just boot (defaulting to Digital Surround 5.1 (IEC958/AC3) Output) and change directly to one of the Analog Stereo options, that also doesn't work (changing the volume doesn't work & there's no sound). Again, I have to select Off first, then go back to Analog Stereo for it to work.

I know some of this might be audio card weirdness that's outside the scope of COSMIC Settings, but does any of this sound like a COSMIC Settings thing? The two distinct problems are the default/last selected profile not being saved between sessions, and not being able to switch from the default to one of the others successfully without first selecting Off (or possibly just sound not working at all until it's turned Off).

@jacobgkau
Copy link
Member

jacobgkau commented Oct 21, 2025

From @WatchMkr in Mattermost (posting here so it doesn't get lost)-- the design also calls for the device description to be prepended to the profile name when selecting an input/output device (e.g. Speakers - Built-in Audio). The string to be prepended appears to be labeled "description" in pw-dump.

@mmstick
Copy link
Member Author

mmstick commented Oct 22, 2025

Seems I'll need to add the different routes (ports) to the output/input dropdown lists. Pavucontrol puts those on a separate port dropdown.

@jacobgkau
Copy link
Member

Not sure if you were ready for me to look at this again yet, but just to corroborate, on f787c83, I'm seeing the Output device as Analog Stereo - Built-in Audio, when it should say Speakers - Built-in Audio. As you noted, it should be the description of the route, not the profile.

The other problems I mentioned before are still occurring.

@mmstick mmstick force-pushed the sound branch 2 times, most recently from cdbd2a9 to 089d65e Compare October 27, 2025 14:11
Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

35e3127 still has reliability issues on oryp8.

If I set Built-in Audio's profile to Analog Stereo Duplex and then reboot, it defaults to Digital Surround 5.1 (IEC958/AC3) Output again.

If I change the profile to Analog Stereo Duplex, then both Output device and Input device show their only option as Built-in Audio, with no route name/description prepended. Changing the speaker volume with hotkeys doesn't work in this state.

If I change the profile to Analog Stereo Output, then Output device changes to Speakers - Built-in Audio, and the speaker hotkeys work. Alternatively, if I open up an app and start playing audio, then the Output device does not change, but the speaker hotkeys do start working.

@mmstick
Copy link
Member Author

mmstick commented Oct 28, 2025

What's the output of pw-dump when set to Analog Stereo Duplex? Particularly the Pipewire:Interface:Node associated with it. Changing the profile changes the active route, and a PipeWire:Interface:Node is created from that.

Based on the logic that I have, the most likely problem is that the node failed to parse. The node ID is required to set a default sink/source, and the route won't be added to the device name if a node isn't associated with it.

.info({
let state = Rc::downgrade(&state);
move |info| {
if let Some(node) = Node::from_node(info) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the node is parsed. This could be wrapped with dbg!(Node::from_node(info)) to check if all nodes are getting parsed.

Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is pw-dump after booting on 4a14492, defaulting to S/PDIF: oryp8-4a14492-default-spdif.txt
Here is pw-dump after changing the profile to Analog Stereo Duplex: oryp8-4a14492-duplex.txt

On 4a14492, the speaker hotkeys work immediately after changing the profile to Analog Stereo Duplex, but the Output device is only labeled Built-in Audio, while the Input device is labeled Speakers - Built-in Audio.

@mmstick
Copy link
Member Author

mmstick commented Oct 28, 2025

I think I see the issue

@mmstick
Copy link
Member Author

mmstick commented Oct 29, 2025

Hoping this fixes the issue you're seeing.

@jacobgkau
Copy link
Member

On c8880c8, I see wireplumber.service being restarted the first time I open Sound Settings in the broken state, so that part's working. However, the volume hotkeys don't start working after that. If I attempt to change the profile from the Digital Surround 5.1 (IEC958/AC3) Output profile it defaults to in the broken state to Analog Stereo Duplex, the volume hotkeys still don't start working. They still start working right away if I open up pavucontrol.

This is what stream-properties looks like when booting up in the broken state:

[stream-properties]
Audio/Sink:node.name:alsa_output.pci-0000_00_1f.3.iec958-ac3-surround-51={"channelMap":["FL", "FR", "RL", "RR", "FC", "LFE"], "channelVolumes":[1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]}
Audio/Sink:node.name:auto_null={"volume":1.000000, "mute":false, "channelMap":["FL", "FR"], "channelVolumes":[1.000000, 1.000000]}
Output/Audio:media.role:Music={"channelVolumes":[1.000000, 1.000000], "volume":1.000000, "mute":false, "channelMap":["FL", "FR"]}

This is what it looks like after opening Sound Settings for the first time, with the hotkeys still not working:

[stream-properties]
Audio/Sink:node.name:alsa_output.pci-0000_00_1f.3.iec958-ac3-surround-51={"channelVolumes":[1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000], "channelMap":["FL", "FR", "RL", "RR", "FC", "LFE"]}
Audio/Sink:node.name:auto_null={"mute":false, "volume":1.000000, "channelMap":["FL", "FR"], "channelVolumes":[1.000000, 1.000000]}
Input/Audio:application.id:org.PulseAudio.pavucontrol={"channelMap":["MONO"], "mute":false, "volume":1.000000, "channelVolumes":[1.000000]}
Output/Audio:media.role:Music={"channelVolumes":[1.000000, 1.000000], "volume":1.000000, "mute":false, "channelMap":["FL", "FR"]}

This is what it looks like after opening pavucontrol, when the hotkeys start working:

[stream-properties]
Audio/Sink:node.name:alsa_output.pci-0000_00_1f.3.iec958-ac3-surround-51={"channelVolumes":[0.857375, 0.857375, 0.857375, 0.857375, 0.857375, 0.857375], "channelMap":["FL", "FR", "RL", "RR", "FC", "LFE"]}
Audio/Sink:node.name:auto_null={"mute":false, "volume":1.000000, "channelMap":["FL", "FR"], "channelVolumes":[1.000000, 1.000000]}
Input/Audio:application.id:org.PulseAudio.pavucontrol={"mute":false, "channelMap":["MONO"], "volume":1.000000, "channelVolumes":[1.000000]}
Output/Audio:media.role:Music={"channelVolumes":[1.000000, 1.000000], "volume":1.000000, "mute":false, "channelMap":["FL", "FR"]}

They look pretty similar, so I'm not sure the problem's in there.

After replicating the issue again, I also tried opening up this branch and then manually restarting pipewire.service and pipewire.socket, which didn't help.

@mmstick
Copy link
Member Author

mmstick commented Nov 5, 2025

I looked around the Internet for random bug reports about this. There are some mixed results. Some mention that muting and unmuting may fix the device. Others report than changing the profile fixes it. One person mentioned needing to restart pipewire-pulse.

Pavucontrol's source code was quite cryptic to read through, but it doesn't seem to be doing anything special besides re-setting the current settings? So I added some wpctl calls to run wpctl set-profile {{device_id}} {{profile_index}} and wpctl set-default {{node_id}} when we get notice of a new profile and device default. Maybe there's a better way, but it feels like a bug in wireplumber or pipewire.

@mmstick
Copy link
Member Author

mmstick commented Nov 5, 2025

If you run pw-cli ls Node you can get a list of nodes and their IDs. pw-cli ls Device for devices. pw-cli e {{device-id}} Profile to get the active profile and its index for a device (albeit the output is not very human-friendly). It may also be worth trying out pw-cli s {{device-id}} Profile '{ index: {{profile-index}}, save: true }' from https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Migrate-PulseAudio#set-card-profile

@jacobgkau
Copy link
Member

On 1b93fdf, when I opened the new settings page for the first time after messing up the profile with the old one, the repair defaulted it to having the device's profile set to Off. Changing it to Analog Stereo Duplex got me working hotkeys immediately. I think this is acceptable behavior.

However, when I rebooted the system, it defaulted to Digital Surround 5.1 (IEC958/AC3) Output. Then, changing it to Analog Stereo Duplex has broken hotkeys again. What's responsible for saving/loading the config between sessions?

I'm attempting to compare the config using the pw-cli commands you suggested.

@jacobgkau
Copy link
Member

Using pw-cli, I discovered that the Analog Stereo Duplex profile has an index of 1. (off is index 0, and the bad 5.1 digital profile is index 30.)

Coming from the bad state, if I run pw-cli s 49 Profile '{ index: 1, save: true }', then reboot, the profile's still set to 1 as I'd expect. But if I instead open COSMIC Settings, first of all, the device ID changes from 49 to 51, and then, if I change to Analog Stereo Duplex in COSMIC Settings, the profile's set to 1 for the time being, but goes back to 30 after rebooting.

The Prop: key Spa:Pod:Object:Param:Profile:save value is set to false when COSMIC Setting sets it, but obviously true when pw-cli sets it with save: true included. That's probably part of the issue with saving across reboots.

@mmstick
Copy link
Member Author

mmstick commented Nov 6, 2025

The profile is now being set with pw-cli.

@jacobgkau
Copy link
Member

Still testing, but seems to be working better now. After recreating the broken state, the new version now switches profiles correctly (with hotkeys working immediately after the switch), and then loads the profile I switched to again on the next boot.

Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I plug in headphones, the output device name doesn't update from Speakers - Built-in Audio to Headphones - Built-in Audio until I close and re-open Settings. Is it possible to make that refresh when the routes change? GNOME Settings had it update immediately.

@mmstick
Copy link
Member Author

mmstick commented Nov 6, 2025

Yeah I'll add that

Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

83eecd5 didn't seem to work for that-- the text is still not updating until I close & re-open after plugging or unplugging headphones.

Another thing I noticed is that when I use the Pro Audio profile, all of the items in the output drop-down are the same (e.g. I have five drop-down items all labeled Built-in Audio). pavucontrol at least has numbers for each of them so they can be differentiated. It looks like pavucontrol displays the node.description, which shows up as e.g. Built-In Audio Pro, Built-in Audio Pro 3, Built-in Audio Pro 7, etc, instead of the ALSA card name.

@mmstick
Copy link
Member Author

mmstick commented Nov 7, 2025

Switched to using libpulse for monitoring active port changes, and I'm seeing it switch between Speakers and Headphones on my system. Checking the Pro Audio issue now.

@jacobgkau
Copy link
Member

On ff15c0d, the active port change is working. Pro Audio isn't necessarily showing the expected labels-- this is what I see in COSMIC Settings vs. pavucontrol:

Screenshot_2025-11-10_10-48-49

The speaker output actually being labeled Speakers is actually better than pavucontrol, but it still seems like it makes less sense for the rest to not have any identifiers. Again, it looks like we could get e.g. Built-in Audio Pro 1 from node.description, or Pro 1 from device.profile.description. If we don't want to just always use the node.description instead of device.description, then maybe we could use the device.profile.description in place of the route description when the latter's empty? That would make it show up as e.g. Pro 1 - Built-in Audio.


The Confirm device type pop-up is sometimes slow to trigger, and that causes issues in the Sound settings panel if I unplug before it's processed. E.g.:

  • Plug in a headset; sound settings immediately changes Output device to reflect the output change.
  • Unplug the headset.
  • A few seconds later, the Confirm Device Type pop-up finally shows up.
  • I choose Headset (even though I've already unplugged the headset) and click Confirm.
  • Sound settings changes Input device to Speakers - Built-in Audio, which doesn't make sense.

Would this be a cosmic-osd issue?

@mmstick
Copy link
Member Author

mmstick commented Nov 10, 2025

Do you have a pw-dump with those devices on the pro audio profile?

@mmstick
Copy link
Member Author

mmstick commented Nov 10, 2025

Yeah the confirm device pop-up may be a cosmic-osd issue.

@jacobgkau
Copy link
Member

Here's a pw-dump while set to Pro Audio on oryp8: oryp8-pro-audio.txt

Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pro Audio labels are showing up as expected now.

Last thing I'm noticing is an issue with the Balance setting. It works if I'm playing audio and I change it. However, it resets to the middle every time I adjust the volume (via hotkey or slider). It should probably be unaffected by volume changes (although some way to reset it might be nice, since its slider doesn't snap to the middle).

@mmstick
Copy link
Member Author

mmstick commented Nov 13, 2025

Finally resolved. I'll need ~15-30 minutes to get this ready to commit though. We will be able to get and set channel volumes and other parameters directly in cosmic-settings without needing libpulse, wpctl, or pw-cli now. Now that we're subscribing to pipewire for parameter updates, I can drop libpulse as a dependency.

Updating the audio applet to share the same cosmic-settings library will ensure that our balance stays intact when using that as well. Changing the volume by shortcut uses wpctl though, which will overwrite the balance. I think we'll need to use cosmic-settings-daemon after this is merged to add an API for the shortcuts to use that preserves our balance.

@jacobgkau jacobgkau linked an issue Nov 14, 2025 that may be closed by this pull request
Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest update (to 9c51fff) broke the test case upgrading from the current stable version. I'm back to having no volume hotkeys after changing the profile to Analog Stereo Duplex on the new version.

Also, dragging the slider to adjust the volume doesn't seem to work anymore. It's reflected in the COSMIC Settings interface, but not pavucontrol or the OSD, and adjusting the volume with the hotkeys resumes from wherever it was before, not from where I set it to in COSMIC Settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants