Spotifyd / spotifyd

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

Index out of bounds #1049

Open g0ierli opened 2 years ago

g0ierli commented 2 years ago

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

To Reproduce

0. 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" 1. spotifyd --no-daemon --config-path ~/.config/spotifyd 2. Call shuffle(state=True, device_id='spotify device id') Info: https://spotipy.readthedocs.io/en/2.19.0/ 3. 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

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

eladyn commented 2 years ago

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 commented 2 years ago

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!

JasonLG1979 commented 2 years ago

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.

g0ierli commented 2 years ago

@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 commented 2 years ago

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

JasonLG1979 commented 2 years ago

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.

Tsury commented 2 months ago

@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.

Hey @g0ierli, out of context question - are you able to include your DIY Alexa in a proper Alexa Speaker Group? I want to create my own DIY Alexa but want to make sure I'm able to include it in my existing Alexa Speaker Groups for multi room music.