Spotify does not play audio

snap --version
snap    2.30.r282.ge1eddad26-1
snapd   2.30.r282.ge1eddad26-1
series  16
arch
kernel  4.9.70-1-lts

Spotify doesn’t play any audio and I get the following errors when I try to play a song.

Gtk-Message: Failed to load module "canberra-gtk-module"
ALSA lib conf.c:3750:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib conf.c:3750:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib conf.c:3750:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default

Also closing spotify doesn’t end the program. Last time I had to Ctrl+C the snap run command I got https://ptpb.pw/xQQF

We spoke on IRC. I can confirm that spotify plays in strict mode on Ubuntu 17.10 with pulseaudio (verified with pavucontrol). @j605 is running Arch with pulseaudio and it appears that the snap is having trouble using pulseaudio and falling back to alsa.

For now, I’m going to modify the topic to append ‘on Arch’.

Note that @j605 is having trouble with audio in the VLC snap too: Call for testing: VLC 3.0.0-rc1 so this is probably not a spotify-specific issue.

I can also confirm this.

@mborzecki Does it work for you?

Maciej is on Arch.

Works here on Manjaro (built on Arch).

I installed the repo package and I still get the same error.

Ah, ok, so not an issue in the snap.

Oh sorry for my wording. I meant to say I installed snapd from Arch repos(version 2.27) and still experience the same error. Audio in my system has no issues.

Works fine right here. I’m running this version:

maciek@corsair:~ snap version
snap    2.30.r282.ge1eddad26-1
snapd   2.30.r282.ge1eddad26-1
series  16
arch    
kernel  4.14.6-1-ARCH
maciek@corsair:~ 

Also tried the LTS kernel 4.9.70-1-lts, got the same results.

I’ve seen the problem with spotify not closing before when using spotify from AUR and with a repacked spotify RPM on Fedora. Albeit, this was with some older version and I don’t recall seeing it recently.

Please double check that these are connected:

maciek@corsair:~ snap interfaces spotify
Slot                   Plug
:browser-support       spotify
:gsettings             spotify
:home                  spotify
:network               spotify
:opengl                spotify
:pulseaudio            spotify
:unity7                spotify
:x11                   spotify
spotify:spotify-mpris  -
-                      spotify:mount-observe

Another thing you can try is run spotify from the console and enable debugging logs and paste the output: PULSE_LOG=4 SNAPD_DEBUG=1 SNAP_CONFINE_DEBUG=1 /snap/bin/spotify

FWIW, libpulse logs I get here are:

Parsing configuration file '/etc/pulse/client.conf'
/etc/pulse/client.conf.d does not exist, ignoring.
Using shared memory pool with 1024 slots of size 64,0 KiB each, total size is 64,0 MiB, maximum usable slot size is 65472
Trying to connect to {55f76458585f45adb352cdec85634ded}unix:/run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 32, local 30
Negotiated SHM: yes
Parsing configuration file '/etc/pulse/client.conf'
/etc/pulse/client.conf.d does not exist, ignoring.
Using shared memory pool with 1024 slots of size 64,0 KiB each, total size is 64,0 MiB, maximum usable slot size is 65472
Trying to connect to {55f76458585f45adb352cdec85634ded}unix:/run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 32, local 30
Negotiated SHM: yes
2 Likes

The [community] package is outdated, but we cannot update it at this time. Please stick to snapd-git from AUR.

not sure about arch, its just it doesnot even open on Xubuntu 17.10

@attache If you run it in the terminal (e.g. via snap run spotify), what messages (if any) do you get? Could you please paste them here so that we can analyse this further?

it works now, it just didn’t work yesterday.

now I cannot even remember my p/word.

so christmas is gonna be grimm.

After some discussions in the IRC, snapd is looking at /run/user/1000/snap.spotify/pulse/native for the socket which is not available. Instead of looking at /run/user/1000/pulse/native, it tries /var/run/pulse/native and fails. @mvo suggested creating a symlink to check if it indeed fixes the issue. This workaround fixes the issue so the problem is snapd not looking in the correct directory for the socket. Thanks for the help @mvo and @mborzecki!

To give more detail on the matter at hand:

  • $XDG_RUNTIME_DIR is set to /run/user/1000/snap.spotify inside the snap
  • libpulse tries pulse socket locations in the following order: $XDG_RUNTIME_DIR/pulse/native, /var/run/pulse/native
  • pulse socket is not available in either location

Surprisingly it works on my system, the logs show that instead of trying $XDG_RUNTIME_DIR/pulse/native libpulse goes to {55f76458585f45adb352cdec85634ded}unix:/run/user/1000/pulse/native, as if $XDG_RUNTIME_DIR was completely ignored.

This should do the trick:

--- spotify.orig/bin/desktop-launch	2017-11-28 23:24:55.000000000 +0100
+++ spotify/bin/desktop-launch	2017-12-21 12:43:42.987532058 +0100
@@ -145,6 +145,18 @@ if [ -n "$XDG_RUNTIME_DIR" ]; then
     fi
 fi
 
+if [ -n "$XDG_RUNTIME_DIR" ]; then
+    pulsenative="pulse/native"
+    pulseaudio_sockpath="$XDG_RUNTIME_DIR/../$pulsenative"
+    pulseaudio_snappath="$XDG_RUNTIME_DIR/$pulsenative"
+    if [ -S "$pulseaudio_sockpath" ]; then
+        if [ ! -e "$pulseaudio_snappath" ]; then
+            mkdir -p -m 700 $(dirname "$pulseaudio_snappath")
+            ln -s "$pulseaudio_sockpath" "$pulseaudio_snappath"
+        fi
+    fi
+fi
+
 # GI repository
 export GI_TYPELIB_PATH=$RUNTIME/usr/lib/girepository-1.0:$RUNTIME/usr/lib/$ARCH/girepository-1.0
 [ "$WITH_RUNTIME" = yes ] && GI_TYPELIB_PATH=$SNAP/usr/lib/gjs/girepository-1.0:$SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$ARCH/girepository-1.0 # add local SNAP assets if a runtime is used

@mborzecki Please can you submit that as a pull request to the desktop helpers. Then @kenvandine and @jamesh can review it :slight_smile:

PR right here:

3 Likes

Curious… why does it work for everybody else?