dtcooper / raspotify

A Spotify Connect client that mostly Just Works™
https://dtcooper.github.io/raspotify
MIT License
4.67k stars 217 forks source link

Not able to play tracks (audio sink connection refused) #682

Open Wollert opened 1 month ago

Wollert commented 1 month ago

Compatible Device

Are you sure?

Compatible OS

Compatible Configuration

Latest Version

Are you sure?

Due Diligence

What happened?

Clean install on a RPi 3B.

Raspotify shows up as speaker in Spotify app on phone (and in Spotify player on Windows computer), and I am able to connect to it. But I am unable to play any tracks. When I press play nothing happens. When I change tracks and press play multiple times raspotify crashes.

Relevant log output and/or the contents of /etc/raspotify/crash_report if any ( sudo journalctl -u raspotify -b and sudo cat /etc/raspotify/crash_report )

-- System Info --

Linux kurer 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

-- Logs --

Oct 22 12:47:01 kurer librespot[22247]: [2024-10-22T10:47:01Z WARN  librespot_core::cdn_url] Cannot parse CDN URL expiry timestamp 'verify=1729680421-hHw6CuunbdsfCCyJW%2FHUxO7zViEK0byjM3JTlCelFhE%3D' from 'https://audio-cf-del-574.spotifycdn.com/audio/5c8ed42de32a27f84170e3fd494becc01ad1d3bd?verify=1729680421-hHw6CuunbdsfCCyJW%2FHUxO7zViEK0byjM3JTlCelFhE%3D'
Oct 22 12:47:03 kurer librespot[22247]: [2024-10-22T10:47:03Z WARN  librespot_core::cdn_url] Cannot parse CDN URL expiry timestamp 'verify=1729680423-tkp%2FU5XOMZoVjtEW6Nj58zKrmhH1n3jRdnPfwqh4Kr4%3D' from 'https://audio-cf-del-574.spotifycdn.com/audio/295e84c54f406bfcb8654e4cb3159d8993115d3c?verify=1729680423-tkp%2FU5XOMZoVjtEW6Nj58zKrmhH1n3jRdnPfwqh4Kr4%3D'
Oct 22 12:47:04 kurer librespot[22247]: [2024-10-22T10:47:04Z WARN  librespot_core::cdn_url] Cannot parse CDN URL expiry timestamp 'verify=1729680424-69x0zCOUiswU5rKHpI5JPnW9W%2BqNnIFVGGSpgwdPr9M%3D' from 'https://audio-cf-del-574.spotifycdn.com/audio/984470bd039456fbebcb0e48b9eedeb55c76cce7?verify=1729680424-69x0zCOUiswU5rKHpI5JPnW9W%2BqNnIFVGGSpgwdPr9M%3D'
Oct 22 12:47:06 kurer librespot[22247]: [2024-10-22T10:47:06Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:07 kurer librespot[22247]: [2024-10-22T10:47:07Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:08 kurer librespot[22247]: [2024-10-22T10:47:08Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:10 kurer librespot[22247]: [2024-10-22T10:47:10Z WARN  librespot_core::cdn_url] Cannot parse CDN URL expiry timestamp 'verify=1729680430-%2BUHEMe8a7TvClrLQ6g9Fn1Qo2sDvdXkGgL0fub3jVw8%3D' from 'https://audio-cf-del-574.spotifycdn.com/audio/eb4235e2ecbd751a3def02b609a6b115a8b0be21?verify=1729680430-%2BUHEMe8a7TvClrLQ6g9Fn1Qo2sDvdXkGgL0fub3jVw8%3D'
Oct 22 12:47:11 kurer librespot[22247]: [2024-10-22T10:47:11Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:12 kurer librespot[22247]: [2024-10-22T10:47:12Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:14 kurer librespot[22247]: [2024-10-22T10:47:14Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:15 kurer librespot[22247]: [2024-10-22T10:47:15Z WARN  librespot_core::cdn_url] Cannot parse CDN URL expiry timestamp 'verify=1729680435-13%2FWYGKveHcOTwVXVWa1%2BJjC87cutROH4l4jQ%2B6AxYA%3D' from 'https://audio-cf-del-574.spotifycdn.com/audio/4d030967fe7191c5992da68afc18383a74080ca9?verify=1729680435-13%2FWYGKveHcOTwVXVWa1%2BJjC87cutROH4l4jQ%2B6AxYA%3D'
Oct 22 12:47:17 kurer librespot[22247]: [2024-10-22T10:47:17Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:18 kurer librespot[22247]: [2024-10-22T10:47:18Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:20 kurer librespot[22247]: [2024-10-22T10:47:20Z WARN  librespot_core::cdn_url] Cannot parse CDN URL expiry timestamp 'verify=1729680440-M357DsUMtqdHu89i0eDYCUbVLoafItMj9poOuYD4P1I%3D' from 'https://audio-cf-del-574.spotifycdn.com/audio/a6c726982b70d5b6794ad3b3e23fe46c23ab00b2?verify=1729680440-M357DsUMtqdHu89i0eDYCUbVLoafItMj9poOuYD4P1I%3D'
Oct 22 12:47:23 kurer librespot[22247]: [2024-10-22T10:47:23Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:23 kurer librespot[22247]: [2024-10-22T10:47:23Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'
Oct 22 12:47:23 kurer librespot[22247]: [2024-10-22T10:47:23Z ERROR librespot_playback::player] PlayerInternal poll: Invalid PlayerState
Oct 22 12:47:23 kurer systemd[1]: raspotify.service: Main process exited, code=exited, status=1/FAILURE
Oct 22 12:47:23 kurer systemd[1]: raspotify.service: Failed with result 'exit-code'.
Oct 22 12:47:23 kurer systemd[1]: raspotify.service: Triggering OnFailure= dependencies.
Oct 22 12:47:23 kurer systemd[1]: raspotify.service: Consumed 1.616s CPU time.

-- Config --

LIBRESPOT_QUIET=on
LIBRESPOT_DISABLE_AUDIO_CACHE=on
LIBRESPOT_DISABLE_CREDENTIAL_CACHE=on
LIBRESPOT_ENABLE_VOLUME_NORMALISATION=on

-- Ouput of aplay -l --

**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi [vc4-hdmi], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

-- Ouput of aplay -L --

null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default Audio Device
sysdefault
    Default Audio Device
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM i2s-hifi-0
    Direct hardware device without any conversions
plughw:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM i2s-hifi-0
    Hardware device with all software conversions
default:CARD=vc4hdmi
    vc4-hdmi, MAI PCM i2s-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi
    vc4-hdmi, MAI PCM i2s-hifi-0
    Default Audio Device
hdmi:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM i2s-hifi-0
    HDMI Audio Output
dmix:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM i2s-hifi-0
    Direct sample mixing device
usbstream:CARD=vc4hdmi
    vc4-hdmi
    USB Stream Output
hw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Hardware device with all software conversions
default:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
sysdefault:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
dmix:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample mixing device
usbstream:CARD=Headphones
    bcm2835 Headphones
    USB Stream Output

-- Ouput of librespot -d ? --

    Compatible alsa device(s):

    ------------------------------------------------------

    Device:

        hw:CARD=Headphones,DEV=0

    Description:

        bcm2835 Headphones, bcm2835 Headphones
        Direct hardware device without any conversions

    Supported Format(s):

        S16

    ------------------------------------------------------

    Device:

        plughw:CARD=Headphones,DEV=0

    Description:

        bcm2835 Headphones, bcm2835 Headphones
        Hardware device with all software conversions

    Supported Format(s):

        S16 S24 S24_3 S32 F32 F64

    ------------------------------------------------------

    Device:

        default:CARD=Headphones

    Description:

        bcm2835 Headphones, bcm2835 Headphones
        Default Audio Device

    Supported Format(s):

        S16 S24 S24_3 S32 F32 F64

    ------------------------------------------------------

    Device:

        sysdefault:CARD=Headphones

    Description:

        bcm2835 Headphones, bcm2835 Headphones
        Default Audio Device

    Supported Format(s):

        S16 S24 S24_3 S32 F32 F64

    ------------------------------------------------------
kimtore commented 1 month ago

Audio Sink Error Connection Refused: \<AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'

It looks like your sound card is already in use by another application?

Wollert commented 1 month ago

Audio Sink Error Connection Refused: Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Unknown errno (524)'

It looks like your sound card is already in use by another application?

I tried sudo lsof /dev/snd/* and got only pipewire and wireplumb. I killed these processes and restarted the raspotify service, but I still get the same error. Is there any other way to find the application(-s) that might be causing the problem?

Please note that I have not installed any additional applications on this version of Raspbian, I downloaded the image and flashed it just before installing raspotify.

kimtore commented 1 month ago

How about installing the pipewire-alsa package and restarting Raspotify?

You could also try the same approach with the pipewire-pulse package and pulseaudio backend.

Wollert commented 1 month ago

Installing the pipewire-alsa package and restarting Raspotify resulted in a new error message. I understand that something might not be running that should be, but I don't know how to fix the issue.

Oct 22 14:38:02 kurer librespot[678]: [2024-10-22T12:38:02Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device default May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Host is down (112)'

kimtore commented 1 month ago

Not sure about this. I suspect Pipewire might be running as a different user than librespot, and that it has something to do with the connection refused message.

As a last resort, you could try uninstalling Pipewire altogether and see if that works for you.

Wollert commented 1 month ago

That didn't help I'm afraid, but that you for your help!

kimtore commented 1 month ago

Do other audio-based applications work? e.g. try the speaker-test application, which IIRC is in the package alsa-utils, and see if you get any sound.

Wollert commented 1 month ago

Yes, speaker-test works fine.

kimtore commented 1 month ago

Good sign then. My guess is that librespot is simply misconfigured, perhaps missing some permissions. You could try to verify this by running librespot as root on the command line, tweaking parameters as needed. Right now I don't have a fresh Raspbian system (nor a RPI 3B) to test on so I can't really make any progress yet.

Wollert commented 1 month ago

I'm getting the same error when running librespot as root. However, when I run librespot (not as root) everything works fine...

kimtore commented 1 month ago

From this info I can only guess that:

Is this correct?

twbonnot commented 3 weeks ago

So I have the same problem and I just did the speaker test and it works I just don't know why it won't connect. It does the same thing it connects on Spotify but when I press play it immediately pauses and doesn't move on the timeline at all