librespot: ERROR ALSA function 'snd_pcm_hw_params_set_buffer_time_near' failed with error 'EINVAL: Invalid argument' on playback on Vero4K
On my Vero4K (OSMC) I get the following error on playback:
[2021-11-28T23:21:41Z ERROR librespot_playback::player] Audio Sink Error Invalid Parameters: <AlsaSink> Hardware, ALSA function 'snd_pcm_hw_params_set_buffer_time_near' failed with error 'EINVAL: Invalid argument'
The librespot command:
osmc@osmc0:~$ /usr/bin/librespot --name DEBUG --device-type speaker --backend alsa --bitrate 320 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 --verbose
[2021-11-28T23:21:14Z INFO librespot] librespot 0.3.1 bbd575e (Built on 2021-11-26, Build ID: a6e0Ery3, Profile: release)
I have nothing in /etc/asound.conf or ~/.asoundrc. Output of aplay -l:
osmc@osmc0:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: AMLMESONAUDIO [AML-MESONAUDIO], device 0: I2S T9015-audio-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: AMLMESONAUDIO [AML-MESONAUDIO], device 1: SPDIF dit-hifi-1 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: AMLMESONAUDIO [AML-MESONAUDIO], device 2: PCM pcm2bt-pcm-2 []
Subdevices: 1/1
Subdevice #0: subdevice #0
and aplay -L:
osmc@osmc0:~$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
btaudio
Bluetooth Audio
default:CARD=AMLMESONAUDIO
AML-MESONAUDIO,
Default Audio Device
sysdefault:CARD=AMLMESONAUDIO
AML-MESONAUDIO,
Default Audio Device
hdmi:CARD=AMLMESONAUDIO,DEV=0
AML-MESONAUDIO,
HDMI Audio Output
dmix:CARD=AMLMESONAUDIO,DEV=0
AML-MESONAUDIO,
Direct sample mixing device
dmix:CARD=AMLMESONAUDIO,DEV=1
AML-MESONAUDIO,
Direct sample mixing device
dmix:CARD=AMLMESONAUDIO,DEV=2
AML-MESONAUDIO,
Direct sample mixing device
dsnoop:CARD=AMLMESONAUDIO,DEV=0
AML-MESONAUDIO,
Direct sample snooping device
dsnoop:CARD=AMLMESONAUDIO,DEV=1
AML-MESONAUDIO,
Direct sample snooping device
dsnoop:CARD=AMLMESONAUDIO,DEV=2
AML-MESONAUDIO,
Direct sample snooping device
hw:CARD=AMLMESONAUDIO,DEV=0
AML-MESONAUDIO,
Direct hardware device without any conversions
hw:CARD=AMLMESONAUDIO,DEV=1
AML-MESONAUDIO,
Direct hardware device without any conversions
hw:CARD=AMLMESONAUDIO,DEV=2
AML-MESONAUDIO,
Direct hardware device without any conversions
plughw:CARD=AMLMESONAUDIO,DEV=0
AML-MESONAUDIO,
Hardware device with all software conversions
plughw:CARD=AMLMESONAUDIO,DEV=1
AML-MESONAUDIO,
Hardware device with all software conversions
plughw:CARD=AMLMESONAUDIO,DEV=2
AML-MESONAUDIO,
Hardware device with all software conversions
I reported this originally in https://github.com/dtcooper/raspotify/issues/466 there are some more details there.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 34 (28 by maintainers)
As soon as it hits dev I will ship it in Raspotify. It should be plenty of exposure there.
Thanks for that work. I’ll take some time to test it on my rig this weekend and get it merged. Then when it lives in
devit can get some proper exposure before we release a new version.@JasonLG1979 it looks like it was exactly same issue as @oebeledrijfhout had. I try to reproduce the error and it looks like i didn’t configure external USB sound card, so it used internal one. Sorry for mystification. Nevertheless the update fix the problem when using internal card and log is same as @oebeledrijfhout posted.
On my Vero4k (OSMC) version:
raspotify_0.31.3-4-g8d41bd0-dirty~librespot.v0.2.0-150-gc737337_armhf.debfixed my issue (same as @oebeledrijfhout posted originally). I don’t have any complains about set buffer size, but i’m using external USB sound card.Weird that it reports an available buffer size range of
16 - 65536Frames and then totally fails whenlibrespottries to set the buffer to22050Frames which is obviously in that range. That’s clearly a driver/configuration bug. The expected result of callingsnd_pcm_hw_params_set_buffer_size_near(and the rust bindings) would be for it to return what the driver set the buffer size to be (hopefully something close to what you asked for). You should basically be able to pass any Frame value to that function and it should never fail. The fact that it always fails is very, very broken. I would file a bug report upstream and tell them to fix their shit drivers/configuration.looks (and sounds) good!
You can get it out of draft when you think the code is ready for review. No problem that it needs more testing after that. “Draft” to me means: I’m still at it, but know that this is on the way, and I welcome any input on-the-go.
I installed that build and playback is working, with the same warning as with the previous build:
BTW, CPU usage is not looking excessive during playback.
@oebeledrijfhout if all goes well with the PR that references this issue I will issue a new Raspotify release after it is merged.
@oebeledrijfhout Try this build:
https://drive.google.com/file/d/1IJDvD_iQOYCf0CNZFdQHVAZmrKiUjupp/view?usp=sharing
It’s based on this branch:
https://github.com/JasonLG1979/librespot/tree/best-effort-buffer
It doesn’t actually fix anything it just makes errors setting the buffer and period size non-fatal.