Nixpkgs: Pipewire status tracking issue

Created on 3 Nov 2020  路  5Comments  路  Source: NixOS/nixpkgs

Pipewire is quite a beast, still very much in flux and has some changes to integration with various environments so let's track the current state of it on NixOS here.

Currently on master:

  • [x] nixos service exists and works
  • [x] libpulse.so, alsa and JACK compatibility shims can be enabled with options
  • [ ] pulse-bridge, a module to let pipewire act as a pulseaudio server, this fixes steam + games without the need for additional tweaks
  • [ ] bluetooth (bluez5 module is currently disabled by default)

configuration.nix:

# Not strictly required but pipewire will use rtkit if it is present
security.rtkit.enable = true;
services.pipewire = {
  enable = true;
  # Compatibility shims, adjust according to your needs
  alsa.enable = true;
  alsa.support32Bit = true;
  pulse.enable = true;
  jack.enable = true;
};

Known problems:

  • steam does not see the compat shim

    • for individual games adding pw-pulse %command% in launch options works around this

    • pulse-bridge fixes audio for both the steam client and games launched from it

  • Cantata (mpd) stutters intermittently

    • reason unknown, maybe mpd tries to do some fancy sync stuff that is not yet supported by the libpulse shim or pulse-bridge?

  • Discord does not see any audio devices

    • Can be worked around by removing libpulseaudio from the hardcoded LD_LIBRARY_PATH in the wrapper script or by replacing it with the path to the libpulse shim (obtained e.g. from ldd pw-pulse)

    • when pulse-bridge is enabled this Just Works

  • Bluetooth falls out of sync and experiences some audio loss

    • Sync issues can be avoided with ??? workaround

  • Problems when system is under high load
  • Alsa media controls and e.g. plasma system tray volume controls might not work
nixos

Most helpful comment

Upstream has deprecated the libpulseaudio.so shim and provides a systemd service to load pulse-bridge now. This makes packaging a lot easier since we don't have to patch files and there should no longer be socket conflicts with pulseaudio either.

All 5 comments

From my experience

  • With default configuration

    • Bluetooth

    • Works fine for a small amount of time, before crapping out and going out of sync

    • On high load

    • Well let's just say it isn't pretty but not unusable

  • With tweaked configuration (don't ask how to tweak, I don't know, or at least it needs tweaking outside of the pipewire configuration as well)

    • Bluetooth

    • I haven't had any out of sync yet, though I do have some intermittent audio loss but at least it still stays in sync

    • On high load

    • Better but still pretty distinctive

There are other things that are pretty annoying, audio control is completely bonkers for me, alsactl/alsamixer is half broken, I have to rely on using pactl and the pulseaudio library shims to even change my audio with keybinds. Anyway just a couple of things off the top of my head.

Note that you may not experience some of my issues, because it's configuration dependent on more than just the pipewire configuration.

As of November 14, 2020, all of the issues I've listed have been resolved (on my system). HFP/HSP doesn't work the last time checked that out, as only the backend support is implemented, in case that is a deal breaker for anyone (as far as I can remember).

Did some digging and the Discord issue is fairly simple: the wrapper prepends the dependencies' paths to LD_LIBRARY_PATH, and those dependencies include libpulseaudio. So I tried making a copy of the wrapper script that prepends the pipewire pulseaudio shim's path instead of the native pulseaudio one and voil脿, it works perfectly! Simply removing the libpulseaudio part from LD_LIBRARY_PATH works as well, as long as the result does not put the native libpulseaudio before the pipewire shim.

I'm guessing the Right solution to this is to wait for the pulse-bridge aka "fake" pulseaudio server in pipewire so Discord (and presumably steam) can just use the native library and everything looks like business as usual to them.

Pulse-bridge does seem to work surprisingly well: I tried stopping the pipewire service and launching it manually with pulse-bridge enabled (I have pulseaudio disabled in my nixos config so there won't be conflicts): pipewire-media-session -e pulse-bridge
If steam, discord etc is launched after starting the media session, audio is working without further tweaking as expected. If they were running before this, they will likely crash or lock up when pipewire is stopped.

So for transparent support we'll need a nixos option to enable the pulse-bridge module as described upstream. Some discussion about that happened in #102514 .

The same approach could be used for the bluez5 module which is also disabled by default for now.

Upstream has deprecated the libpulseaudio.so shim and provides a systemd service to load pulse-bridge now. This makes packaging a lot easier since we don't have to patch files and there should no longer be socket conflicts with pulseaudio either.

ALSA compatibility option doesn't provide ctl.!default for some reason: https://github.com/NixOS/nixpkgs/blob/c18b90b5b90bd20c421ffe795420ad501e6613c7/nixos/modules/services/desktops/pipewire.nix#L85-L98

This leads to the impossibility to control pipewire via alsamixer :(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rzetterberg picture rzetterberg  路  3Comments

copumpkin picture copumpkin  路  3Comments

yawnt picture yawnt  路  3Comments

teto picture teto  路  3Comments

spacekitteh picture spacekitteh  路  3Comments