Closed foreveremain closed 5 years ago
Looks like the device snapcast
isn't a valid ALSA device, and thus it's complaining.
I am not to well versed with snapcast
, but it believe you probably need to pass the --backend pipe
option to VLS.
thanks. snapcast is a PCM patch device to resample 44.1->48k, as a fix the spotify-resample problem:
https://github.com/badaix/snapcast/issues/45
--backend pipe works, but still requires a resample before passing to snapserver. Earlier versions of librespot could write to the PCM device directly, but something seems to have changed after daeeeaa. I'm not enough of an alsa expert to work out what's going on here ! Either way I guess its an upstream issue.
What does your asound.conf
look like?
I will try and recreate something this side to debug.
From the error - ALSA can't read the PCM handle that was given to it (EINVAL
).
Btw - can't you achieve the resampling from directly by setting sampleformat
to something like &sampleformat=44100:16:2
?
Thanks for keeping with this one !
#SNAPCAST
pcm.!snapcast {
type plug
slave {
pcm rate48000Hz # Direct default output to the below converter
}
}
pcm.rate48000Hz {
type rate
slave {
pcm writeFile # Direct to the plugin which will write to a file
format S16_LE
rate 48000
}
}
pcm.writeFile {
type file
slave.pcm null
file "/tmp/snapfifo"
format "raw"
}
#ENDOFSNAPCAST
This is the vanilla solution for upsampling the 44.1k spotify stream to 48k which is the only one natively supported by the android snapcast client. I noticed someone over at https://github.com/librespot-org/librespot/issues/340 suggested a fix of changing the snapcast samplerate -- that's fine if your sink handles it but most don't.
So I had some time tonight, so tired to understand what is going on with this.
It looks like this plug
device is quite sensitive to the snd_pcm_hw_params
that alsa needs to set up the device before opening it up.
I made a new test build based on some trial and error - but since I don't have snapcast setup, I'd request you to test it out. This build should open up the device without crashing, but don't know if the parameters would actually lead to some sensible output. Either way, it needs to be passed a special flag, like so:
LIBRESPOT_RATE_RESAMPLE=1 /data/plugins/music_service/volspotconnect2/vollibrespot -n test --device snapcast
Let me know!
Looks good !
volumio@volumio-bedroom:~$ LIBRESPOT_RATE_RESAMPLE=1 ./vollibrespot -n test --device snapcast
vollibrespot v0.1.6-beta f23083b 2019-06-12 (librespot 6e369f0 2019-06-12) -- Built On 2019-07-08
[Vollibrespot] : Failed to register IPv6 receiver: Os { code: 19, kind: Other, message: "No such device" }
[Vollibrespot] : Connecting to AP "gew1-accesspoint-a-l8ps.ap.spotify.com:4070"
[Vollibrespot] : Authenticated as "foreveremain" !
[Vollibrespot] : Using alsa sink
[Vollibrespot] : Metadata pipe established
[Vollibrespot] : Country: "GB"
[Vollibrespot] : SessionActive!
[Vollibrespot] : Loading track "Sexbombe Über Alles" with Spotify URI "spotify:track:74Xcy98SAzj63fZEEK6sxE"
[Vollibrespot] : Track "Sexbombe Über Alles" loaded
[Vollibrespot] : Allowing resampling, and setting period size
[Vollibrespot] : SessionActive!
[Vollibrespot] : Loading track "Sexbombe Über Alles" with Spotify URI "spotify:track:74Xcy98SAzj63fZEEK6sxE"
[Vollibrespot] : Track "Sexbombe Über Alles" loaded
[Vollibrespot] : Allowing resampling, and setting period size
Android snapclient receives the stream at the right speed - so issue is resolved :)
Nice, I shall test a little more and then push it to the next version.
Rudimentary support has been implemented with https://github.com/ashthespy/librespot/commit/4c81c88c10d3a6993cd6c1c7e19f598d3c57be3f
And is baked into v0.1.7
of the daemon. It still needs the LIBRESPOT_RATE_RESAMPLE
flag to be set though.
After upgrading volumio in May 2019, volspotconnect2 no longer played tracks through a custom alsa sink (even though the spotify app thought it was playing). Executing vollibrespot directly revealed the alsa error messages below. I've seen the same with all versions of vollibrespot including latest v0.1.6. Also seen with Raspotify 0.13.x, with the last good version of raspotify was 0.12, built with librespot daeeeaa (2019-02-22).
Linux volumio-bedroom 4.14.92-v7+ #1187 SMP Wed Jan 9 20:01:54 GMT 2019 armv7l GNU/Linux volumio version: 2.587 (rasbian 8 on Pi 3B) Plugins: snapcast + vollibrespot Alsaconfig: snapcast device resample 48->44.1
Apologies to be the bearer of bad tidings ! Let me know if you'd like me to try anything..