Navigation Menu

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

spotify: 1.0.96.181 -> 1.1.10.546 #65602

Merged
merged 2 commits into from Aug 1, 2019

Conversation

angristan
Copy link
Member

@angristan angristan commented Jul 30, 2019

See #57800 and #65081 for discussion around fixing the SIGSEV with ALSA since 1.1.5

Fix taken from
https://gitweb.gentoo.org/repo/gentoo.git/commit/media-sound/spotify?id=d8c8d8abd012c709551cc96802d2615fa69b5212:

Adding apulse libraries to LD_LIBRARY_PATH make spotify work
even if pulseaudio is not installed. If pulseaudio is installed
instead of apulse, this has no effect.

Adding APULSE_PLAYBACK_DEVICE is also necessary otherwise apulse does
not find the device (inspired by the tor-browser-bundle derivation)

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @eelco @ftrvxmtrx @sheenobu @mudri @timokau

@angristan
Copy link
Member Author

angristan commented Jul 30, 2019

Btw I made a single commit for the update + ALSA fix. Please tell me if I should split them.

@angristan
Copy link
Member Author

It seems I messed up something with the maintainers list.

@veprbl
Copy link
Member

veprbl commented Jul 30, 2019

It seems I messed up something with the maintainers list.

You need to add yourself to https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix to fix this.

@angristan
Copy link
Member Author

Thanks!

See NixOS#57800 and NixOS#65081 for discussion around fixing the SIGSEV since 1.1.5

Fix taken from
https://gitweb.gentoo.org/repo/gentoo.git/commit/media-sound/spotify?id=d8c8d8abd012c709551cc96802d2615fa69b5212:

Adding apulse libraries to LD_LIBRARY_PATH make spotify work
even if pulseaudio is not installed. If pulseaudio is installed
instead of apulse, this has no effect.

Adding APULSE_PLAYBACK_DEVICE is also necessary otherwise apulse does
not find the device (inspired by the tor-browser-bundle derivation)
@FRidh
Copy link
Member

FRidh commented Aug 1, 2019

Tested locally (and actually played music this time @timokau !). Thank you @angristan

@FRidh FRidh merged commit a8d45e7 into NixOS:master Aug 1, 2019
@timokau
Copy link
Member

timokau commented Aug 2, 2019

I just tested this and unfortunately it doesn't work for me :/ Does apulse need any setup?

I built spotify from current master and ran it from the result symlink. It doesn't crash at playback, but I don't get any sound either. Pulse audio doesn't report any playback.

@angristan
Copy link
Member Author

@timokau thanks for the feedback. I guess this has something to do with APULSE_PLAYBACK_DEVICE.

@timokau
Copy link
Member

timokau commented Aug 2, 2019

Are you going to debug this? Otherwise I propose we revert this update for now, before it hits the unstable channel. I'll probably not be the only one with the issue.

Its annoying, I know. But an old version is better than a version that only works for some users.

@angristan
Copy link
Member Author

Let's revert it again 🎉

Though if we don't get feedback from users where it doesn't work properly, it will be hard to fix.

@timokau
Copy link
Member

timokau commented Aug 2, 2019

Well you have at least one test subject where it doesn't work. If you have anything you want me to try, I'd be happy to.

@angristan
Copy link
Member Author

angristan commented Aug 2, 2019

Yes I agree this is enough to say Spotify on master is broken.

Do you have any specific audio config?

Mine is:

  hardware.pulseaudio = {
    enable = true;
    package = pkgs.pulseaudioFull;
  };

Maybe try other audio devices like APULSE_PLAYBACK_DEVICE = hw:0,0?

For dmix works because apparently this is the output used when multiple programs emit sound. hw:0,0 works too because it corresponds to my sound card (aplay -l)

@ajs124
Copy link
Member

ajs124 commented Aug 2, 2019

I doubt this would work for people with alsa, but for me, this patch works on a networked pulseaudio setup:

diff --git a/pkgs/applications/audio/spotify/default.nix b/pkgs/applications/audio/spotify/default.nix
index 4c08a8d285d..9327a8e124c 100644
--- a/pkgs/applications/audio/spotify/default.nix
+++ b/pkgs/applications/audio/spotify/default.nix
@@ -1,7 +1,7 @@
 { fetchurl, stdenv, squashfsTools, xorg, alsaLib, makeWrapper, openssl, freetype
 , glib, pango, cairo, atk, gdk_pixbuf, gtk2, cups, nspr, nss, libpng, libnotify
 , libgcrypt, systemd, fontconfig, dbus, expat, ffmpeg_3, curl, zlib, gnome3
-, at-spi2-atk, at-spi2-core, apulse
+, at-spi2-atk, at-spi2-core, libpulseaudio
 }:
 
 let
@@ -21,8 +21,8 @@ let
 
 
   deps = [
+    libpulseaudio
     alsaLib
-    apulse
     atk
     at-spi2-atk
     at-spi2-core
@@ -136,8 +136,6 @@ stdenv.mkDerivation {
       librarypath="${stdenv.lib.makeLibraryPath deps}:$libdir"
       wrapProgram $out/share/spotify/spotify \
         --prefix LD_LIBRARY_PATH : "$librarypath" \
-        --prefix LD_LIBRARY_PATH : "${apulse}/lib/apulse" \
-        --set APULSE_PLAYBACK_DEVICE plug:dmix \
         --prefix PATH : "${gnome3.zenity}/bin"
 
       # fix Icon line in the desktop file (#48062)

@timokau
Copy link
Member

timokau commented Aug 2, 2019

No specific config, just enabling pulseaudio. hw:0,0 doesn't work.

I can play a file with aplay -D default file.wav (but setting default as APULSE_PLAYBACK_DEVICE doesn't work, which is why you changed it to plug:dmix). When I use aplay -D plug:dmix file.wav I get

ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
aplay: main:828: audio open error: Device or resource busy

Curiously enough @asj124's fix works for me. So maybe we don't need apulse at all but just libpulseaudio?

@angristan
Copy link
Member Author

@ajs124's patch works for me too.

@timokau
Copy link
Member

timokau commented Aug 2, 2019

@ajs124, can you submit that as a PR? Pulseaudio is required for a bunch of programs nowadays anyway. I'm not sure if spotify worked with plain alsa before.

@ajs124
Copy link
Member

ajs124 commented Aug 3, 2019

Right now, spotify 1.0.x (on 19.03) connects to my pulseaudio through the alsa emulation. So I assume it would work with plain ALSA. Meaning, my patch might break backwards compatibility?

@timokau
Copy link
Member

timokau commented Aug 3, 2019

You're right, just dropping alsa support entirely would be a bit of a cop out in that case. On the other hand, I don't feel like supporting it when upstream apparently doesn't care for it.

Let's do the revert first to take the urgency out of it: #65833

I did some debugging. Apparently plug:dmix plays on hw:0,0 by default. I use my HDMI output though, which is hw:1,3.

If I set the output device to plug:'dmix:CARD=1,DEV=3' I can get it to work. But that differs per user of course. You can probably change the default alsa device somehow, but that would mean that pulseaudio users (which are probably the majority of users) would have to configure alsa to get spotify to work.

Any ideas how we can have the cake and eat it too? Maybe detect an available pulseaudio daemon at runtime and only use apluse if it can't be found (would be nice if apluse had a mode to do that automatically). But then I'm still not sure if plug:dmix would work for every alsa user, I just don't know enough about alsa/pulseaudio.

@ajs124
Copy link
Member

ajs124 commented Aug 3, 2019

Maybe detect an available pulseaudio daemon at runtime

Please don't. There is no pulseaudio daemon running on my system, since I only use it over the network.

Has anyone without pulseaudio tested what happens with my patch? Did they actually drop support for plain ALSA?

@timokau
Copy link
Member

timokau commented Aug 3, 2019

Maybe detect an available pulseaudio daemon at runtime

Please don't. There is no pulseaudio daemon running on my system, since I only use it over the network.

Good point. But what I generally meant was "do whatever the application would do to detect pulseaudio", it wouldn't necessarily need to be a check for the daemon.

Has anyone without pulseaudio tested what happens with my patch? Did they actually drop support for plain ALSA?

I haven't tested it since I couldn't get audio working on my system with pulseaudio disabled.

The issue is that spotify doesn't officially support anything on linux. While there is code for alsa support in spotify, it has led to segfaults for months now. And according to the comments in that thread that is not the first issue with alsa.

So alsa is definitely not in their test matrix (if they even test anything...) and they apparently don't care about it either. Effectively unsupported.

@aakropotkin
Copy link
Contributor

I have been battling this for months now lol.
I've gone through such absurd Alsa/Pulse setups trying to get Brave to work (Pulse) and Spotify to work (Alsa).
I sincerely hope y'all crack the case <3

@timokau timokau mentioned this pull request Nov 3, 2019
10 tasks
@kolaente
Copy link
Member

kolaente commented Nov 5, 2019

Continued in #72596, feel free to review.

rafaeldff added a commit to rafaeldff/nixpkgs that referenced this pull request Jan 24, 2020
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.

None yet

7 participants