dtcooper / raspotify

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

librespot takes 97% CPU, music replay stutters #504

Closed removogel closed 2 years ago

removogel commented 2 years ago

Compatible OS

Latest Version

Due Diligence

What happened?

Since a few days music replay is starting to stutter after a few minutes working fine. /usr/bin/libespot takes up to 97% CPU

Did a check with journalctl, there is an error writing to PCM

ALSA works fine, just testet with aplay as documented in log below

Relevant log output

Jan 23 15:25:21 raspberrypi librespot[459]: [2022-01-23T14:25:21Z WARN  librespot_playback::audio_backend::alsa] Error writing from AlsaSink buffer to PCM, trying to recover, ALSA function 'snd_pcm_writei'
Jan 23 15:25:21 raspberrypi librespot[459]: ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred

sudo aplay -Dhw:0,0 --dump-hw-params /usr/share/sounds/alsa/Front_Right.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Right.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
HW Params of device "hw:0,0":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: [16 32]
CHANNELS: [1 2]
RATE: [32000 48000]
PERIOD_TIME: [1000 8192000]
PERIOD_SIZE: [32 262144]
PERIOD_BYTES: [64 524288]
PERIODS: [2 1024]
BUFFER_TIME: (1333 16384000]
BUFFER_SIZE: [64 524288]
BUFFER_BYTES: [128 1048576]
TICK_TIME: ALL
--------------------
pejobo commented 2 years ago

How / where do you set this mode? During build time or as environment variable or parameter during runtime?

kirenida commented 2 years ago

How / where do you set this mode? During build time or as environment variable or parameter during runtime?

https://github.com/dtcooper/raspotify/wiki/Configuration

pejobo commented 2 years ago

Thanks, I found it here: https://github.com/librespot-org/librespot/wiki/Options

JasonLG1979 commented 2 years ago

Although this is not a documented setting for raspotify,

Librespot settings are clearly link to in the wiki.

nachoman42 commented 2 years ago

Sorry, @pejobo, I should have said it was a config setting. Glad you sorted it out.
@JasonLG1979, sorry, I must have missed it. It wasn't clear to me if every librespot option was mapped in the config file.