spotifyd icon indicating copy to clipboard operation
spotifyd copied to clipboard

Index out of bounds

Open g0ierli opened this issue 3 years ago • 7 comments

Description Spotifyd crashes when I try to turn on shuffle with spotipy (!sic), directly after initializing.

To Reproduce

  1. Set config (in this scenario, there already exists a valid cache): [global] username = "myacccount" use_mpris = true backend = "alsa" # use portaudio for macOS [homebrew] device = "default" control = "default" mixer = "PCM" # omit for macOS volume_controller = "alsa" # use softvol for macOS device_name = "myname" bitrate = 160 cache_path = "/home/user/spotifyd/cache" initial_volume = "100" volume_normalisation = true normalisation_pregain = -10 zeroconf_port = 5234 device_type = "computer"

  2. spotifyd --no-daemon --config-path ~/.config/spotifyd

  3. Call shuffle(state=True, device_id='spotify device id') Info: https://spotipy.readthedocs.io/en/2.19.0/

  4. App crashes

Output Loading config from "/home/user/.config/spotifyd" No password specified. Checking password_cmd No password_cmd specified No proxy specified Using alsa volume controller. Couldn't read volume from alsa device with name "default". Connecting to AP "ap.spotify.com:443" Authenticated as "myaccount" ! Country: "removed" Using Alsa sink with format: S16 Couldn't set volume: "Couldn't find selem with name 'PCM'." PANIC: Shutting down spotifyd. Error message: index out of bounds: the len is 0 but the index is 0

Compilation flags

  • [ ] dbus_mpris
  • [ ] dbus_keyring
  • [x] alsa_backend
  • [ ] portaudio_backend
  • [ ] pulseaudio_backend
  • [ ] rodio_backend

Versions (please complete the following information):

Used and Compiled PR #1041

enabling shuffling seems to work, but i have to run any other commands BEFORE (e.g. play a track or playlist) Trying to enable shuffle seems to crash only directly after spotifyd was initialized

g0ierli avatar Jan 31 '22 08:01 g0ierli

Thank you for the elaborate description!

This actually seems to be a librespot error (the upstream crate that spotifyd uses), which is still present in the current release, so I filed a bug report there (https://github.com/librespot-org/librespot/issues/959). Feel free to comment there, if you have some information to add to the issue.

eladyn avatar Jan 31 '22 18:01 eladyn

One of the developers of librespot has already submitted a patch, which fixes the issue in upstream librespot (https://github.com/librespot-org/librespot/pull/960). Unfortunately, since spotifyd is lagging several versions behind with upstream librespot, this fix probably won't make it into the application anytime soon.

If you really need this to work, I guess you could create your own version of librespot that has the fix from the linked PR backported for librespot 0.2.0. Then you could patch the upstream dependency in spotifyd's Cargo.toml with your own version.

Hope this helps!

eladyn avatar Feb 01 '22 19:02 eladyn

I couldn't help but notice that you're only using Spotifyd with the alsa backend. IMHO you'd be much better off just using librespot. As mentioned Spotifyd is pretty out of date and in my mind really the only reason to use it over librespot is if you want the keyring and mpris features. I have no idea what distro you're running on but I maintain Raspotify which is basically just librespot packaged for armhf, arm64 and amd64 Debian (and other Debian based distros). Aside from that it's stupid easy to compile librespot.

JasonLG1979 avatar Feb 08 '22 23:02 JasonLG1979

@JasonLG1979 thank you very much. I've finished my DIY alexa with audible and spotify project so far. I'll consider this for future improvements.

g0ierli avatar Feb 09 '22 07:02 g0ierli

@JasonLG1979 Again, thank you. I wish I saw librespot much earlier. Just started to read through it and will definitely use it.

g0ierli avatar Feb 17 '22 14:02 g0ierli

Again, thank you. I wish I saw librespot much earlier. Just started to read through it and will definitely use it.

It should more or less be a drop-in replacement I would think if what you need is a headless Spotify Connect client.

JasonLG1979 avatar Feb 18 '22 02:02 JasonLG1979