librespot icon indicating copy to clipboard operation
librespot copied to clipboard

ALSA lib pcm.c:8382:(snd_pcm_set_params) Sample format not available for PLAYBACK: Invalid argument

Open ghost opened this issue 7 years ago • 11 comments

Hi,

I built librespot with alsa backend on Archlinuxarm:

https://aur.archlinux.org/packages/librespot-alsa-git/

When I try to start librespot with the following command:

librespot --cache /var/cache/librespot --name Test --bitrate 320 --username xxxxxx --password xxxxxx

I get the following error:

ALSA lib pcm.c:8382:(snd_pcm_set_params) Sample format not available for PLAYBACK: Invalid argument thread '' panicked at 'called Option::unwrap() on a None value', src/libcore/option.rs:323 note: Run with RUST_BACKTRACE=1 for a backtrace.

Any help is highly appreciated.

Many thanks,

Michael

ghost avatar Mar 11 '17 09:03 ghost

Looks like your ALSA device does not support the sample format S16_LE.

joerg-krause avatar Mar 11 '17 10:03 joerg-krause

My device is:

ard 1, ID DAC', name S16 USB DAC' Device 0, ID USB Audio', name USB Audio', 1 subdevices (1 available) 2 channels, sampling rate 44100..384000 Hz Sample formats: S32_LE Subdevice 0, name `subdevice #0'

and indeed does not support S16_LE.

So I assume there's no solution to this?

Many thanks for your immediate reply.

ghost avatar Mar 11 '17 10:03 ghost

You can set the ALSA device with the --device option. Try --device=plughw:1.

joerg-krause avatar Mar 11 '17 10:03 joerg-krause

Thank you very much, it works!

I am trying to find a more generic approach so that librespot uses the default alsa device. Is there any possibility to do this?

ghost avatar Mar 11 '17 10:03 ghost

librespot does use the default device. Your default device does not support S16_LE. If you do not want to set the device with --device you have to make plughw:1 your default ALSA device. You can set this in ALSA config file. Google will help you :smile:

joerg-krause avatar Mar 11 '17 10:03 joerg-krause

Many thanks for everything.

I have already created an asound.conf file with the following configuration:

pcm.!default { type hw card 1 }

As it seems I have to search more for this.

ghost avatar Mar 11 '17 10:03 ghost

Try this:

pcm.!default {
type plughw
card 1
}

joerg-krause avatar Mar 11 '17 10:03 joerg-krause

Thank you very much for everything Joerg.

Everything is up and running buy adding the device option on the systemd.service file.

ghost avatar Mar 11 '17 11:03 ghost

You are welcome!

joerg-krause avatar Mar 11 '17 11:03 joerg-krause

am getting this too, but with a FiiO USB DAC adding --device=plughw:1 doesn't fix it. See my report on pimusicbox through which I am using librespot https://github.com/pimusicbox/pimusicbox/issues/453

arthurlutz avatar Nov 16 '17 20:11 arthurlutz

Try doing the following: List all available devices: aplay -l Locate your USB device. For my dragonfly it was: plughw:CARD=v10 Append it to your --device option.

Worked like a charm for me.

IngvarRagnarsson avatar Jan 04 '19 03:01 IngvarRagnarsson