I'm running into strange behavior running librespot-org/librespot#660 on the Rodio backend and Alsa host. On the current cpal master, output is opened four times. Last time is with incorrect parameters causing incorrect playback.
Regardless of the --format setting librespot is launched with (F32 or S16):
First time opening is with FloatLE, 44100 Hz and 2 channels (as expected).
Second time is FloatLE, 4294967295 Hz and 2 channels.
Third time is FloatLE, 44100 Hz and 2 channels.
Fourth time is FloatLE, 4000 Hz and 2 channels.
This behavior is triggered by lines 194-201 in stream.rs of Rodio:
self.new_output_stream_with_format(default_format)
.unwrap_or_else(|err| {
// look through all supported formats to see if another works
supported_output_formats(self)
.filter_map(|format| self.new_output_stream_with_format(format).ok())
.next()
.ok_or(err)
.expect("build_output_stream failed with all supported formats")
The first three iterations trigger the unwrap_or_else closure because cpal fails to prepare the Alsa stream. This line fails:
I am stumped why this fails. This is Alsa on a Raspberry Pi 3 Model B+, running 32-bit Raspian 10 (Linux 5.10.17-v7+) over I2S to an external DAC. aplay --dump-hw-params gives:
Indeed this is reflected as SupportedStreamConfig. Using the native Alsa backend in librespot works just fine for all formats F32, S32, S24, S24_3 and S16 so the Alsa soundcard itself is working fine.
Applying #520 by @alexmoon fixes one issue, being that the output is now opened once and correctly, but introduces another issue: after opening, no sound is played and the librespot player thread hangs when writing.
Again I've been banging my head trying to get this down for several nights of debugging now. Any suggestions?
I'm running into strange behavior running librespot-org/librespot#660 on the Rodio backend and Alsa host. On the current cpal
master
, output is opened four times. Last time is with incorrect parameters causing incorrect playback.Regardless of the
--format
settinglibrespot
is launched with (F32 or S16): First time opening is withFloatLE
, 44100 Hz and 2 channels (as expected). Second time isFloatLE
, 4294967295 Hz and 2 channels. Third time isFloatLE
, 44100 Hz and 2 channels. Fourth time isFloatLE
, 4000 Hz and 2 channels.This behavior is triggered by lines 194-201 in
stream.rs
of Rodio:The first three iterations trigger the
unwrap_or_else
closure because cpal fails to prepare the Alsa stream. This line fails:https://github.com/RustAudio/cpal/blob/fbc0f71e21bb7491797138fe107d27034b3c8e08/src/host/alsa/mod.rs#L260
I am stumped why this fails. This is Alsa on a Raspberry Pi 3 Model B+, running 32-bit Raspian 10 (Linux 5.10.17-v7+) over I2S to an external DAC.
aplay --dump-hw-params
gives:Indeed this is reflected as
SupportedStreamConfig
. Using the native Alsa backend inlibrespot
works just fine for all formats F32, S32, S24, S24_3 and S16 so the Alsa soundcard itself is working fine.Applying #520 by @alexmoon fixes one issue, being that the output is now opened once and correctly, but introduces another issue: after opening, no sound is played and the
librespot
player thread hangs when writing.Again I've been banging my head trying to get this down for several nights of debugging now. Any suggestions?