dtcooper / raspotify

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

Compatible alsa device(s): empty #676

Closed y-lobau closed 1 hour ago

y-lobau commented 1 month ago

Due Diligence

What can we help you with?

Setup:

Problem: Raspotify is running but list of supported ALSA devices is empty. What may cause this?

sudo systemctl status raspotify
● raspotify.service - Raspotify (Spotify Connect Client)
     Loaded: loaded (/lib/systemd/system/raspotify.service; enabled; preset: enabled)
     Active: active (running) since Thu 2024-09-19 21:44:09 BST; 8s ago
rpi@rpi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: seeed2micvoicec [seeed-2mic-voicecard], device 0: 1f000a0000.i2s-wm8960-hifi wm8960-hifi-0 [1f000a0000.i2s-wm8960-hifi wm8960-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
rpi@rpi:~ $ librespot -B ?
[2024-09-19T21:06:42Z INFO  librespot] librespot 0.5.0-dev fb5c0ef (Built on 2024-09-17, Build ID: jyRJ1a0M, Profile: release)
Available backends: 
- alsa (default)
- pulseaudio
- pipe
- subprocess
librespot -d ?
[2024-09-19T20:45:37Z INFO  librespot] librespot 0.5.0-dev fb5c0ef (Built on 2024-09-17, Build ID: jyRJ1a0M, Profile: release)

        Compatible alsa device(s):

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

Then the Raspotify is not recognized by Spotify connect, and I assume this may be because there's no available device for librespot.

kimtore commented 1 month ago

Not exactly sure what this could be, your ALSA setup looks fine. Perhaps the ALSA device is claimed by some other software running simultaneously?

kletze commented 1 month ago

@y-lobau o you use the PI 5 without anything connected? I mean the bare board as you get it from the supplier.

YokaiRick commented 1 month ago

Just as a heads-up, i had the same problem, but executing it with sudo the device lists outputs my devices. so it could be a permission problem

edit: after fiddling around with tcpdump i got it to work... I started spotify on my mobilephone and on my pc.. did use spotify_connect to connect my laptop and mobile phone.. somehow magically raspotify appeard within at the device list the same time

kimtore commented 3 weeks ago

@y-lobau please try again with 0.45.0.

y-lobau commented 3 weeks ago

Unfortunately, the same issue with the latest raspotify/librespot, checked on the rpi zero 2 w:

    $ sudo librespot -d ?
    [2024-10-20T15:15:15Z INFO  librespot] librespot 0.5.0 84d28e8 (Built on 2024-10-17, Build ID: CmvEuO4M, Profile: release)

    Compatible alsa device(s):

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

    ALSA lib pcm_dmix.c:999:(snd_pcm_dmix_open) unable to open slave      #I think I missed this line in my initial post
kimtore commented 3 weeks ago

@y-lobau, My gut tells me it is not a librespot/raspotify problem.

Please post your /etc/asound.conf and /etc/raspotify/conf.

Is sound working for other applications? Are you running any other applications that uses the sound card?

y-lobau commented 3 weeks ago

I agree, it looks like my infra issue. Indeed, the rpi also runs the acoustic echo cancellation built into the pipewire. Also, my app is actively listening for the microphone. Maybe there's a clash somewhere in this combination. My hope is that anyone might face with similar issue. Will post configs a bit later.

kimtore commented 3 weeks ago

Ah, you're running Pipewire on top? Then Pipewire is most certainly holding your audio device.

Might I suggest installing pipewire-pulse and try to run your audio stuff over Pipewire's Pulseaudio compatible API instead? This way you get all the software mixing built-in from Pipewire.

y-lobau commented 1 hour ago

This issue is similar to other open issues connected with the AlsaSink. When I run the librespot manually, It is discoverable and works fine. However, the Raspotify service runs into some permissions issues when attempting to play smth with it:

Nov 11 15:31:52 myadam systemd[1]: Started raspotify.service - Raspotify (Spotify Connect Client). Nov 11 15:33:02 myadam librespot[4862]: Failed to create secure directory (/root/.config/pulse): Permission denied Nov 11 15:33:02 myadam librespot[4862]: [2024-11-11T13:33:02Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: Device hw:1,0 May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'Device or resource busy (16)'