Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alsa, pulseaudio (and jack, pipewire, steam) on x86_64 #157631

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

ivanbrennan
Copy link
Member

@ivanbrennan ivanbrennan commented Feb 1, 2022

Motivation for this change

A recent alsa-lib upgrade (#154276) removed a patch without understanding its purpose, leaving alsa-lib unable to parse the /etc/asound.conf generated by pulseaudio, jack, or pipewire.

As a result, ALSA utils (e.g. alsactl, alsamixer, speaker-test) are failing on x86_64 architecture for some configurations (e.g. if pulseaudio is enabled).

$ alsactl monitor default
alsa-lib control.c:1464:(snd_ctl_open_conf) Unknown field libs
Cannot open ctl default

The patch was originally added in 2014 to support running apps with 32bit sound on 64bit architecture. The patch itself adds a "libs" field to the syntax recognized in /etc/asound.conf: ab8ef63. The "libs" field is used by pulseaudio (link), jack (link), and pipewire (link) to declare locations for both native and 32bit plugins.

Re-adding the patch fixes what's currently broken.

Note: It's debatable whether the 32bit use-case warrants patching alsa-lib. I don't have an opinion on the matter, but if it's to be removed, the removal should start by deprecating the relevant options and informing users of an alternative solution, if one exists. I'll leave that to someone more knowledgeable on the subject. (I can see how to remove the option, but I don't know what alternative to suggest in a deprecation warning.) My first priority is to fix what's currently broken.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

This patch was originally added in 2014 to support running apps with
32bit sound on 64bit architecture.

The patch itself add a "libs" field to syntax recognized in /etc/asound.conf:
ab8ef63

The pulseaudio module then used the "libs" to declare locations for both native
and 32bit plugins:
0c8ad65

In a recent alsa-lib upgrade (1.2.5.1 -> 1.2.6.1), the patch was removed
without understanding its purpose, leaving alsa-lib unable to parse the
etc/asound.conf that the pulseaudio module generated:
aeea1bb

As a result, ALSA utils are failing on x86_64 architecture if pulseaudio
is enabled. E.g.

  $ alsactl monitor default
  alsa-lib control.c:1464:(snd_ctl_open_conf) Unknown field libs
  Cannot open ctl default

  $ alsamixer
  ALSA lib control.c:1464:(snd_ctl_open_conf) Unknown field libs
  cannot open mixer: Invalid argument

  $ speaker-test -t wav -c 2

  speaker-test 1.2.6

  Playback device is default
  Stream parameters are 48000Hz, S16_LE, 2 channels
  WAV file(s)
  ALSA lib pcm.c:2576:(snd_pcm_open_conf) Unknown field libs
  Playback open error: -22,Invalid argument

Put the patch back in place to fix what was broken.
@L-as
Copy link
Member

L-as commented Feb 1, 2022 via email

@Synthetica9
Copy link
Member

@ofborg test pulseaudio

Copy link
Member

@L-as L-as left a comment

Choose a reason for hiding this comment

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

This is quite unfortunate! I do wonder how other distros manage to do it without this patch.

@ivanbrennan
Copy link
Member Author

This is quite unfortunate! I do wonder how other distros manage to do it without this patch.

@L-as I agree, and maybe there's a way to achieve this without a patch, but I was unable to determine what that is. Someone more knowledgeable than myself in this area might have more luck.

However, as described in #157352 (comment), I think the first priority should be fixing what's broken. Then, if someone can find an alternative solution, that would be a great followup.

@ofborg ofborg bot requested a review from L-as February 1, 2022 16:23
@ivanbrennan
Copy link
Member Author

@lovesegfault Anything I can do to help get this PR approved/merged?

@Synthetica9
Copy link
Member

I think this is definitely better than the current state of master, so I'm gonna merge this.

@Synthetica9 Synthetica9 merged commit 37809af into NixOS:staging Feb 2, 2022
@ivanbrennan ivanbrennan deleted the re-add-alsa-lib-patch branch February 2, 2022 18:32
Electrostasy added a commit to Electrostasy/dots that referenced this pull request Feb 4, 2022
remove alsa 32bit support (the relevant PR
NixOS/nixpkgs#157631) got merged, but I
don't currently need 32bit alsa.

removed pipewire media-session in favour of wireplumber
svrana added a commit to svrana/nix-home that referenced this pull request Feb 9, 2022
This reverts commit 7cd5154.

Sound not working in qutebrowser. Will wait for changes in
NixOS/nixpkgs#157631 to be in nixos-unstable.
Synthetica9 added a commit to Synthetica9/nixpkgs that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants