Spotifyd / spotifyd

A spotify daemon
https://spotifyd.rs
GNU General Public License v3.0
9.83k stars 450 forks source link

systemd unit crashes immediately when trying to play anything #1274

Closed burdoto closed 5 months ago

burdoto commented 6 months ago

Description When started using the provided systemd unit file, regardless of whether being started as a user or root process, spotifyd always crashes trying to find an audio device, regardless of the executing user and group.

To Reproduce

  1. Start with the provided systemd service
  2. Try to change playback to spotifyd
  3. Crash

Expected behavior no crash

Logs

Click to show logs ``` Apr 04 18:34:39 netzteil systemd[1]: spotifyd.service: Scheduled restart job, restart counter is at 1. Apr 04 18:34:39 netzteil systemd[1]: Stopped A spotify playing daemon. Apr 04 18:34:39 netzteil systemd[1]: Started A spotify playing daemon. Apr 04 18:34:39 netzteil spotifyd[2444]: Loading config from "/root/.config/spotifyd/spotifyd.conf" Apr 04 18:34:39 netzteil spotifyd[2444]: No proxy specified Apr 04 18:34:39 netzteil spotifyd[2444]: Using software volume controller. Apr 04 18:34:39 netzteil spotifyd[2444]: Ignoring blacklisted access point ap-gew4.spotify.com:4070 Apr 04 18:34:39 netzteil spotifyd[2444]: Ignoring blacklisted access point ap-gew4.spotify.com:443 Apr 04 18:34:39 netzteil spotifyd[2444]: Ignoring blacklisted access point ap-gew4.spotify.com:80 Apr 04 18:34:39 netzteil spotifyd[2444]: Ignoring blacklisted access point ap-gue1.spotify.com:443 Apr 04 18:34:39 netzteil spotifyd[2444]: Failed to resolve Access Point: Unable to resolve any viable access points. Apr 04 18:34:39 netzteil spotifyd[2444]: Using fallback "ap.spotify.com:443" Apr 04 18:34:39 netzteil spotifyd[2444]: Connecting to AP "ap.spotify.com:443" Apr 04 18:34:40 netzteil spotifyd[2444]: Authenticated as "11131851148" ! Apr 04 18:34:40 netzteil spotifyd[2444]: Country: "DE" Apr 04 18:34:40 netzteil spotifyd[2444]: Mixing with softvol and volume control: Log(60.0) Apr 04 18:34:40 netzteil spotifyd[2444]: Converting with ditherer: tpdf Apr 04 18:34:40 netzteil spotifyd[2444]: Using AlsaSink with format: S16 Apr 04 18:35:54 netzteil spotifyd[2444]: Loading with Spotify URI Apr 04 18:35:55 netzteil spotifyd[2444]: (213573 ms) loaded Apr 04 18:35:55 netzteil spotifyd[2444]: Audio Sink Error Connection Refused: Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'UnknownErrno: Unknown errno' Apr 04 18:35:55 netzteil systemd[1]: spotifyd.service: Main process exited, code=exited, status=1/FAILURE Apr 04 18:35:55 netzteil systemd[1]: spotifyd.service: Failed with result 'exit-code'. ```

This log was gathered from a systemd unit that explicitly starts the service as root in the root group. No difference when starting as a user or with the audio group.

Please note that when started manually from a terminal, spotifyd works just fine as expected. Its specifically the systemd situation that does not work at all.

Versions (please complete the following information):

eladyn commented 6 months ago

Hmm, that is strange. Have you made sure that the configuration file that is used is the same? To debug the problem, maybe you can try something like replacing the ExecStart with aplay -L or aplay -D default /dev/urandom (warning: potentially loud noise coming out of your speaker) and see if this works.

burdoto commented 6 months ago

thanks for the advice; i will try once i get the chance because i recently killed the pi that this issue was occurring on, and i dont have a viable replacement option at this point in time šŸ˜…šŸ˜‚

burdoto commented 5 months ago

i have finally had the chance to replace my PIs, and been trying to get this working first try, with both bluetooth speakers (and been trying to set up GPIO speakers but i couldnt get it finished yet) either way, while commands such as speaker-test -c2 -t sine -f 440 and aplay -D default /dev/urandom work without issues with bluetooth speakers when launched from a commandline shell, i still get the very same crash and error message with spotifyd as a systemd unit.

when replacing the ExecStart parameter with aplay -D default /dev/urandom as you suggested, this is the only output i can get:

Apr 19 17:20:06 netzteil systemd[1]: spotifyd.service: Scheduled restart job, restart counter is at 2.
Apr 19 17:20:06 netzteil systemd[1]: Stopped spotifyd.service - A spotify playing daemon.
Apr 19 17:20:06 netzteil systemd[1]: Started spotifyd.service - A spotify playing daemon.
Apr 19 17:20:07 netzteil aplay[950]: aplay: main:831: audio open error: Unknown error 524
Apr 19 17:20:07 netzteil systemd[1]: spotifyd.service: Main process exited, code=exited, status=1/FAILURE
Apr 19 17:20:07 netzteil systemd[1]: spotifyd.service: Failed with result 'exit-code'.

everything is up-to-date. i've been having no trouble playing audio from commandline, but no such luck trying to play from a systemd unit

eladyn commented 5 months ago

Thank you for reporting back. That means, that it is not spotifyd at fault here, since aplay cannot play audio either. So it's indeed some systemd / audio issue.

burdoto commented 5 months ago

Yes, so far thats what I could figure out so far too, but I found no solution so far. Although, yes this means this issue report is invalid.

eladyn commented 5 months ago

If you want, you can join the matrix server, and we can try troubleshooting over there. That is usually easier than through GitHub issues.

burdoto commented 5 months ago

thank you for the offer, i'm in šŸ‘