raspotify: Raspotify crashes with Alsa equalizer

I have setup alsa with an equalizer according to this comment: https://github.com/dtcooper/raspotify/issues/23#issuecomment-476951906

This has been working for quite some time. The other day I upgraded to 0.31.3 and after that audio playback crashes with the following error:

Dec 13 08:50:10 raspberrypi librespot[12520]: [2021-12-13T08:50:10Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <AlsaSink> Device equal May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'EPERM: Operation not permitted'
Dec 13 08:50:10 raspberrypi systemd[1]: raspotify.service: Main process exited, code=exited, status=1/FAILURE
Dec 13 08:50:10 raspberrypi systemd[1]: raspotify.service: Failed with result 'exit-code'.

However running the librespot command standalone does not produce the same error. Playback works in that case.

/usr/bin/librespot --name raspotify --device-type speaker --backend alsa --bitrate 320 --disable-audio-cache --enable-volume-normalisation --volume-ctrl log --initial-volume=30 --device equal

Even without the “–device equal” setting, the crash occurs.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 15

Most upvoted comments

After looking in the pi user’s home it seems that the plugin probably wants to put a .alsaequal.bin in the home of the user that’s using the plugin. The docs say as much. That ofc isn’t going to work with a user without a home.

I can get it to work by putting .alsaequal.bin in a place that is visible to the raspotify service and telling the plugin where it’s at in my /etc/asound.conf. Something like this works with the latest git version of raspotify:

pcm.!default {
    type plug
    slave.pcm plugequal
}
ctl.!default {
    type hw card 0
}
ctl.equal {
    type equal
    controls /var/lib/raspotify/.alsaequal.bin
}
pcm.plugequal {
    type equal
    controls /var/lib/raspotify/.alsaequal.bin
    slave.pcm "plughw:0,0"
}
pcm.equal {
    type plug
    slave.pcm plugequal
}

The problem ofc with this is that you have to use sudo to change the eq values and nothing else can read /var/lib/raspotify/.alsaequal.bin. The previous way that the plugin worked by using $HOME may have worked when the plugin was 1st written (and may continue to work for real human users) but it will break for more and more system services as they adopt systemd features like dynamic users.