mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 00:05:55 +03:00
[GH-ISSUE #373] sluggish reaction to user input on Libreelec Kodi #249
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#249
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dfrieling on GitHub (Sep 22, 2019).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/373
I am using librespot (version 2019-07-23) with libreelec (9.1.501) on Kodi with Raspberry pi 4. It works OK but has quite a sluggish reaction to user input on the remote control (smartphone): when pressing pause or changing the volume it takes at least 2 seconds to reflect.
I've been using librespot for years and it didn't have this delay. I believe it was introduced when switching to use Kodi as audio playback device. When using ALSA it was fine. But I could be mistaking and actually the delay is caused by another change.
Checking in kodi's log I see it takes approx. 1 sec to see this message in the log
NOTICE: Librespot: pausing librespot playbackand another 1 sec to actually pause the playback
Any ideas how to debug the problem?
@willstott101 commented on GitHub (Sep 22, 2019):
That first delay is unavoidable, the second is probably due to audio buffer size.
Do you know which audio backend you're using?
@willstott101 commented on GitHub (Sep 22, 2019):
Sorry, I misread that, is kodi receiving the audio via the pipe output?
@devgianlu commented on GitHub (Sep 22, 2019):
Probably something similar to https://github.com/librespot-org/librespot-java/pull/120#issuecomment-519194594, the pipe size may be the issue as I discovered: https://github.com/librespot-org/librespot-java/issues/121#issuecomment-522345917
@dfrieling commented on GitHub (Sep 22, 2019):
The Kodi addon runs librespot with the following params:
librespot --backend pulseaudio --bitrate 320 --cache /storage/.kodi/userdata/addon_data/service.librespot/cache --device-type TV --disable-audio-cache --name Kodi (LibreELEC) --notify-kodi@dfrieling commented on GitHub (Sep 22, 2019):
pipe size is 1048576, executed on the RPi4:
cat /proc/sys/fs/pipe-max-size 1048576@devgianlu commented on GitHub (Sep 22, 2019):
You're not using "pipe" so this has nothing to do with it. Must be some other issue.
@dfrieling commented on GitHub (Sep 25, 2019):
just compiled the current HEAD for Rpi with alsa support using
master/contrib/Dockerfile.Rpi, with that it works with a delay of <0.5 sec. Very much looks like using pulseaudio + kodi is the problem.@awiouy would be happy to have your thoughts on this - is a delay of ~2sec expected when using librespot with libreelec kodi+pulseaudio or did you manage to get it to react instantaneously?
@willstott101 commented on GitHub (Sep 26, 2019):
Here we explicitly use PA's default buffer setup.
https://github.com/librespot-org/librespot/blob/master/playback/src/audio_backend/pulseaudio.rs#L90
According to this page that can usually be up to 2s
https://freedesktop.org/software/pulseaudio/doxygen/structpa__buffer__attr.html#abef20d3a6cab53f716846125353e56a4
Changing the volume will always be that slow unless the buffer size is reduced. However skipping/pausing we could conceivably drain the buffer to respond faster.
@rpardini commented on GitHub (Dec 25, 2020):
It seems like CoreELEC/LibreELEC Kodi "librespot" Kodi plugin uses librespot in an interesting way.
Kodi itself holds the ALSA output device, starts an RTP listener on port 24642, setups PulseAudio to output to Null, forwards Null via RTP back to Kodi, and starts librespot outputting to pulseaudio. The whole thing adds 3000ms or more latency to my setup.
But, it does allow unified device setup in Kodi and lyrics/visualizations of the sound stream produced by librespot in Kodi (!) in a way that "just works", albeit with some sluggishness.
Lowering buffer sizes all-around that chain uses CPU a lot and does not make things much better.
For people bothered by this: switch Kodi to use PulseAudio, make PulseAudio output to ALSA device. Kodi and Kodi/librespot still works sluggish, but you can run a second/separate instance of librespot that outputs directly to Pulse->ALSA with minimal lag, but no Kodi integration.