Closed jansol closed 1 year ago
From my experience
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 :(
0.3.16 has been merged, this adds pulse-bridge which fixes most pulseaudio applications including steam and its games. (channels haven't updated yet at the time of writing though)
0.3.16 has been merged
With 0.3.17, bluetooth works out of the box for me (both HFP and A2DP). #105362
Isn't the bluez5 module disabled by default?
Isn't the bluez5 module disabled by default?
with-pulse
fileBluetooth worked for me even without the with-pulse
file. HFP required enabling hsphfpdSupport
(compile-time option) though.
According to the source code, it should be enabled with the pulse file: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/0.3.17/src/examples/media-session/media-session.c#L2109-2111
And looks like it should be with-pulseaudio
rather than with-pulse
: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/0.3.17/src/examples/media-session/media-session.c#L2128
Thanks, fixed the with-pulseaudio
file name.
Eventually, the nixos module should also generate a pipewire.conf
file (so that we can modify it). Right now, it's e.g. impossible to pass extra arguments to pipewire-media-session
.
I have an issue while trying to use qjackctl
with pipewire:
$ qjackctl
/nix/store/xv3g9szrk83yqizmzzaxvl45qz5sv4hh-qjackctl-0.6.3/bin/qjackctl: symbol lookup error: /nix/store/xv3g9szrk83yqizmzzaxvl45qz5sv4hh-qjackctl-0.6.3/bin/qjackctl: undefined symbol: jack_session_commands_free
Thanks, fixed the
with-pulseaudio
file name.
btw, imho, it is worth to replace
sound.extraConfig = mkIf cfg.alsa.enable ''
pcm_type.pipewire {
libs.native = ${cfg.package.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;
${optionalString enable32BitAlsaPlugins
"libs.32Bit = ${pkgs.pkgsi686Linux.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;"}
}
pcm.!default {
@func getenv
vars [ PCM ]
default "plug:pipewire"
playback_mode "-1"
capture_mode "-1"
}
'';
environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable {
source = "${cfg.package}/share/alsa/alsa.conf.d/50-pipewire.conf";
};
with
sound.extraConfig = mkIf cfg.alsa.enable ''
pcm_type.pipewire {
libs.native = ${cfg.package.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;
${optionalString enable32BitAlsaPlugins
"libs.32Bit = ${pkgs.pkgsi686Linux.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;"}
}
ctl_type.pipewire {
libs.native = ${cfg.package.lib}/lib/alsa-lib/libasound_module_ctl_pipewire.so ;
${optionalString enable32BitAlsaPlugins
"libs.32Bit = ${pkgs.pkgsi686Linux.pipewire.lib}/lib/alsa-lib/libasound_module_ctl_pipewire.so ;"}
}
'';
environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable {
source = "${cfg.package}/share/alsa/alsa.conf.d/50-pipewire.conf";
};
environment.etc."alsa/conf.d/99-pipewire-default.conf" = mkIf cfg.alsa.enable {
source = "${cfg.package}/share/alsa/alsa.conf.d/99-pipewire-default.conf";
};
Is there a reason to keep the sound.extraConfig
or could we put that into alsa/conf.d
as well?
Yeah, it should work with conf.d as well. You could test with alsamixer: if everything is ok, it will give you pipewire volume control instead of hardware volume control by default.
It finds out, qjackctl can be fixed with --disable-jack-session
option to configure. It should be provided by default, since jack session api is deprecated: https://jackaudio.org/api/group__JackSessionManagerAPI.html
I don't know if the following issues are nixos specific:
With pipewire, my keyboard media keys (vol up & vol down) don't seem to work under gnome (x11).
Anyone has an idea?
Anyone has an idea?
It's a bug with restoring default device on restart https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/429
pipewire has a race condition with logind, thus adding the user to the audio
group might help with some issues that happen on restart (i always add my user to the audio group to have working rtkit-daemon, so I don't know which issues it might fix exactly)
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/423
Just updated my NixOS unstable
0.3.18 is out, fixes some more issues: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/NEWS
Hopefully my sound card won't stutter anymore with the latest bugfixes.
0.3.18 is out, fixes some more issues: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/NEWS
Hopefully my sound card won't stutter anymore with the latest bugfixes.
Just waiting for the nixos channels to update... #106990
Oh, I missed that, thanks :)
Just updated to the latest nixos unstable (before i had almost perfectly working pipewire aside from a couple of annoyances) now i have completely broken audio, alsamixer throws this. I'd really appreciate someone's help with this
[W][000000128.554552][ctl_pipewire.c:1105 on_core_error()] alsa-plugin 0x2177300: error id:5 seq:21 res:-2 (No such file or directory): enum params id:13 (Spa:Enum:ParamId:Route) failed
And audio (if it comes out) is completely distorted and from the left channel only
Updated to the latest nixos unstable as well and I don't have any problems :man_shrugging: :thinking:
Current nixos-unstable works fine for me, but I don't really use alsa nor am I familiar with how it is supposed to work (didn't have much success when I gave it a quick try in the previous version though). @ilya-fedin can you edit the alsa bits in the OP since you seem to be familiar with it? If not, please update me on fixed/new known issues you encounter.
@bbigras plasma/gnome volume widgets aren't working at all here it seems, I think the keyboard volume buttons go through those... IIRC they are supposed to work with the fake pulse server though, not sure what the problem there is
@ilya-fedin can you edit the alsa bits in the OP since you seem to be familiar with it?
Looks like I have not enough rights :(
I know at least two problems with alsamixer (seems to be bugs in the pipewire's shim):
amixer controls
(it is numid=3,iface=MIXER,name='Master Playback Volume'
for me)amixer cset numid=3 100%
(where numid=3
is your numid)With regards to GNOME, you can convince it to work.
To get the notification icon working, you can just do a gnome reset (enter r
in the alt+f2 menu)
To get the media keys working systemctl --user restart org.gnome.SettingsDaemon.MediaKeys.target
Seems like there is some sort of race condition at session-startup perhaps?
Using this config seems to make pipewire with Gnome/x11 work just fine. Forcing the services to start instead of using socket activation.
hardware.pulseaudio.enable = pkgs.lib.mkForce false;
systemd.user.services.pipewire.wantedBy = [ "default.target" ];
systemd.user.services.pipewire-pulse.wantedBy = [ "default.target" ];
services.pipewire = {
enable = true;
socketActivation = false;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
(EDIT: also make sure your user account is in the audio
group. See below.)
Using this config seems to make pipewire with Gnome/x11 work just fine.
It's weird. With that config I get the notification icon and the volume overlay working but only in gdm.
Once logged in I have none and my sound doesn't work. I had no output with pavucontrol.
Maybe it's a coincidence. In my config I also had jack.enable = true
.
pipewire
-- Journal begins at Mon 2020-11-23 21:17:39 EST, ends at Thu 2020-12-31 14:36:47 EST. --
déc 31 04:41:30 desktop systemd[2044]: Started Multimedia Service.
déc 31 04:41:30 desktop pipewire[2053]: Failed to receive portal pid: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.freedesktop.portal.Desktop': no such name
déc 31 04:41:30 desktop pipewire[2053]: could not make thread realtime: No such file or directory
déc 31 04:41:30 desktop pipewire-media-session[2067]: could not make thread realtime: No such file or directory
déc 31 04:41:30 desktop pipewire-media-session[2067]: can't open control for card hw:1: No such file or directory
déc 31 04:41:30 desktop pipewire-media-session[2067]: can't open control for card hw:0: No such file or directory
déc 31 04:41:30 desktop pipewire-media-session[2067]: can't open control for card hw:2: No such file or directory
déc 31 04:41:30 desktop pipewire-media-session[2067]: v4l2: Cannot open '/dev/video0': 13, Permission denied
déc 31 04:41:30 desktop pipewire-media-session[2067]: v4l2: Cannot open '/dev/video1': 13, Permission denied
déc 31 04:41:30 desktop pipewire-media-session[2067]: oFono: Register() failed: org.freedesktop.DBus.Error.ServiceUnknown
déc 31 04:41:30 desktop pipewire-media-session[2067]: RegisterApplication() failed: org.freedesktop.DBus.Error.ServiceUnknown
déc 31 04:41:30 desktop pipewire[2053]: ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: Permission denied
déc 31 04:41:30 desktop pipewire[2053]: open failed: Permission denied
déc 31 04:41:30 desktop pipewire[2053]: can't create node: Permission denied
déc 31 04:41:30 desktop pipewire-media-session[2067]: error id:3 seq:3 res:-13 (Permission denied): can't create node: Permission denied
déc 31 04:41:55 desktop pipewire-media-session[2067]: GetManagedObjects() failed: org.freedesktop.DBus.Error.NoReply
déc 31 04:45:00 desktop pipewire-media-session[2067]: no node found for 37
pipewire-pulse
-- Journal begins at Mon 2020-11-23 21:17:39 EST, ends at Thu 2020-12-31 14:36:47 EST. --
déc 31 04:41:30 desktop systemd[2044]: Started PipeWire PulseAudio.
déc 31 04:41:30 desktop pipewire-pulse[2052]: could not make thread realtime: No such file or directory
déc 31 04:45:00 desktop pipewire-pulse[2052]: stream 0x10cef90: error no node available
déc 31 04:45:00 desktop pipewire-pulse[2052]: pulse-server 0x10aaeb0: [Firefox] ERROR command:-1 (invalid) tag:5 error:25 (Input/output error)
déc 31 04:45:44 desktop pipewire-pulse[2052]: pulse-server 0x10d0fe0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:12 error:19 (Operation not supported)
déc 31 04:45:44 desktop pipewire-pulse[2052]: pulse-server 0x10d0fe0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:13 error:19 (Operation not supported)
déc 31 04:45:44 desktop pipewire-pulse[2052]: pulse-server 0x10d0fe0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:14 error:19 (Operation not supported)
déc 31 04:45:44 desktop pipewire-pulse[2052]: pulse-server 0x10d0fe0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:15 error:19 (Operation not supported)
Here's the logs when it works:
pipewire
-- Journal begins at Tue 2020-11-24 05:22:01 EST, ends at Thu 2020-12-31 14:36:47 EST. --
déc 30 23:54:38 desktop systemd[2037]: Started Multimedia Service.
déc 30 23:54:38 desktop pipewire[2403]: could not make thread realtime: No such file or directory
déc 30 23:54:38 desktop pipewire[2403]: Failed to receive portal pid: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.freedesktop.portal.Desktop': no such name
déc 30 23:54:38 desktop pipewire-media-session[2428]: could not make thread realtime: No such file or directory
déc 30 23:54:38 desktop pipewire-media-session[2428]: oFono: Register() failed: org.freedesktop.DBus.Error.ServiceUnknown
déc 30 23:54:38 desktop pipewire-media-session[2428]: RegisterApplication() failed: org.freedesktop.DBus.Error.ServiceUnknown
déc 30 23:54:49 desktop pipewire-media-session[2428]: GetManagedObjects() failed: org.freedesktop.DBus.Error.TimedOut
pipewire-pulse
-- Journal begins at Tue 2020-11-24 05:22:01 EST, ends at Thu 2020-12-31 14:36:47 EST. --
déc 30 23:54:35 desktop systemd[2037]: Started PipeWire PulseAudio.
déc 30 23:54:36 desktop pipewire-pulse[2209]: could not make thread realtime: No such file or directory
déc 30 23:55:02 desktop pipewire-pulse[2209]: pulse-server 0x1100df0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:12 error:19 (Operation not supported)
déc 30 23:55:02 desktop pipewire-pulse[2209]: pulse-server 0x1100df0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:13 error:19 (Operation not supported)
déc 30 23:55:02 desktop pipewire-pulse[2209]: pulse-server 0x1100df0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:14 error:19 (Operation not supported)
déc 30 23:55:02 desktop pipewire-pulse[2209]: pulse-server 0x1100df0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:15 error:19 (Operation not supported)
déc 30 23:55:02 desktop pipewire-pulse[2209]: pulse-server 0x1100df0: [Contrôle du volume PulseAudio] ERROR command:87 (EXTENSION) tag:17 error:19 (Operation not supported)
déc 30 23:55:02 desktop pipewire-pulse[2209]: Failed to mlock memory 0x7fbff6520000 32832: This is not a problem but for best performance, consider increasing RLIMIT_MEMLOCK
@bbigras try to add both your user and gdm's user to the audio group
@bbigras try to add both your user and gdm's user to the audio group
It works. Thanks @ilya-fedin !
I am having a problem where no app detects pulse-bridge, even if I start it manually. Everything just prints "connection refused".
I am having a problem where no app detects pulse-bridge, even if I start it manually. Everything just prints "connection refused".
There's no pulse-bridge anymore, there's only pipewire-pulse
@pushqrdx I'm hitting this as well, sound is audible but KDE audio configuration doesn't work. qjackctl
works fine.
pacmd
also aborts with No PulseAudio daemon running, or not running as session daemon.
. For some reason I have neither pipewire-pulse
nor pulse-bridge
in my path with pipewire installed (I only find pipewire
, pipewire-media-session
and some pw-*
tools).
pacmd is hardcoded to work only with pulseaudio process https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/357
For some reason I have neither
pipewire-pulse
norpulse-bridge
in my path with pipewire installed
ps aux | grep pipewire-pulse
ilya 1125 0.0 0.3 96388 18744 ? Ssl 12:30 0:00 /nix/store/pl34m73jxmy2h495a8xfbc1pc82crmy5-pipewire-0.3.18-pulse/bin/pipewire-pulse
ilya 5624 0.0 0.0 6452 2240 pts/0 S+ 13:29 0:00 /nix/store/134fdr0yrl4wgrrasxn9d3s8vzcm5lxq-gnugrep-3.6/bin/grep --color=auto pipewire-pulse
Pipewire 0.3.19 was recently released. The bad news is that the configuration format changed, which will require some packaging changes. The good news is that mSBC (improved microphone quality) is working wonderfully if you're on kernel 5.10.X for X >= 18 or 5.11.Y for Y >= 1. If you need support on the 5.8/5.9 series, there's a patch you can apply (see previous version of this message). If you're on 5.4, you might be out of luck.
There are sample config files in the repo so changing the current module to generate a config in the new format shouldn't be too difficult. What is unclear to me is how the new config file relates to the /etc/pipewire-media-session.d/with-*
files that were used to enable the compat modules. I'd like to update this ASAP for stability reasons as well (there are a bunch of very regularly occuring crashes in 0.3.18 that have been fixed in 0.3.19 AFAIK) but unfortunately I'm tied up with other things for the next few days.
I asked it at https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/548. It's a peculiar configuration format: you declare "bundles" in /etc/pipewire/media-session.d/media-session.conf, but a given bundle is only enabled if a file with the same name as the bundle exists in /etc/pipewire/media-session.d/
Looks like they fixed the logind ACL race condition and the audio group workaround shouldn't be needed with 0.3.19
Here's a subpar generation function that generally works for everything except objects
(though you can see the subpar attempt). Not even sure how the language is even structured, so the quoting is left for the user to add.
mkSPAValueString = v:
if builtins.isList v then "[${lib.concatMapStringsSep " " mkSPAValueString v}]"
else if lib.types.attrs.check v then
"{${lib.concatStringsSep " " (mkSPAKeyValue { _SPA_DUP = v._type or "" == "_SPA_DUP"; } v)}}"
else lib.generators.mkValueStringDefault {} v;
mkSPAKeyValue = { _SPA_DUP ? false }: attrs: map (def: def.content) (lib.sortProperties
(lib.mapAttrsToList
(k: v:
let
keyValue = v': "${lib.escape ["="] k} = ${mkSPAValueString (v'._content or v')}";
in lib.mkOrder (v._priority or 1000)
(if _SPA_DUP
then lib.concatMapStringsSep " " keyValue (v._content or [])
else keyValue v))
attrs));
toSPAJSON = attrs: lib.concatStringsSep "\n" (mkSPAKeyValue {} attrs);
I am having issues with an electron app (teams) not detecting any audio output, inputs are detected just fine. Other applications (firefox, mpv) can output audio just fine too.
Any way I can debug this? I guess something goes wrong during discovery?
Teams is working fine here. What does it look like in pavucontrol or one of the numerous JACK patchbays? (carla, patchage)
It appears briefly (as "chromium"), but disappears after a few seconds. The weird thing is I can make a test call which start playing the ringtone (which works) and when the other end accepts the call, it gives me a notification there is no speaker detected... (without any sound).
This is how it looks in patchage (after enabling jack and rebooting). The connection from chromium
is the ringtone playing.
Connecting the Skype
output channels to playback results in my microphone input going to my headphone output.
I'll try to find out how teams performs its audio discovery...
For me it obediently follows the defaults I have set in pavucontrol. Try nuking ~/.config/pipewire-media-session/*
and then setting the default devices in pavucontrol before launching anything that plays audio. That fixed some applications reverting to the wrong soundcard for me.
TL;DR: Things are generally in pretty good shape but wireplumber can't be configured via the nixos module yet. On the other hand most people won't need to change anything from the defaults.
If you are reporting something, please mention the pipewire version you are using, as it is updated very frequently. Bonus points for checking if upstream already has a fix mentioned in the commit log or release notes.
Currently on master:
~/.config/wireplumber
)Configuration
Most basic additions to configuration.nix, this should be enough for most people:
Some useful knobs if you want to finetune or debug your setup. Note that pipewire config keys may contain a period '.' so they need to be quoted in Nix. (combine these with the basic config above):
Virtual Sinks/Sources
If you want to do some fancy routing with null sinks, you can define them directly in the pipewire config like this. Especially convenient if you have a multi-channel (8+, or something "weird" like 2x2, 3x2) soundcard that keeps confusing applications with too many channels or a bad channel layout. (Note: you can set those cards to the "Pro Audio" profile with pavucontrol so pipewire doesn't try to guess a wrong channel layout for them.) Note that arrays are replaced rather than merged with defaults, so you need to list any default items that you want to keep here (the dummy and freewheeling driver for JACK applications, if you have JACK support enabled):
You can't currently link nodes to each other in the config, but you can adapt this script to do it for you. Replace the soundcard names and ports with whatever matches your setup:
Standalone mode (no session manager)
If you want to run a minimal pipewire instance with no session manager for automatic switching etc, you can do that as of 0.3.46 (technically pipewire supported it a bit longer than that but that's when the nixos module was adapted to account for it). This is mainly intended for systems that used to run purely JACK:
If this doesn't work it is likely because it defaults to using an alsa device called
hw:0
which might not be the sound card you want to be using. You can easily fix this by overriding the device name in the"context.objects"
array of the main pipewire configuration. The names and descriptions of available devices can be seen withaplay -l
from thealsa-utils
package. Note that you'll have to write out the full contents of the array because the default items will be replaced completely with this:Miscellaneous
For the time being you can switch between two session managers, although there is usually no reason to. Note #159546 which intends to change the default from media-session to wireplumber since media-session is considered deprecated by upstream.
For other available options, consult the upstream config templates. All config files listed there should be accessible via the nixos module as
services.pipewire.config.$basename
andservices.pipewire.media-session.config.$basename
for the daemon and the default session manager respectively.Please help test new PRs!
Please do try out update pull requests before they are merged (if you can), it is fairly easy:
sudo nixos-rebuild test -I nixpkgs=path/to/nixpkgs/clone
Known Problems
The issues people have previously described here should all be fixed now.
Please add a comment if something is broken (and ideally open an issue upstream if it is not a packaging problem).