[GH-ISSUE #787] Alsa 'snd_pcm_hw_params' error with USB DAC #410

Closed
opened 2026-02-27 19:30:28 +03:00 by kerem · 6 comments
Owner

Originally created by @wpresident on GitHub (Jun 4, 2021).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/787

Originally assigned to: @roderickvd on GitHub.

Hi. I'am trying to use librespot with raspberry pi zero w (Raspberry Pi OS Lite + raspotify) and usb dac.
As i understand my DAC can do 32bit, not 16bit. So i use --format S32. But have errors after song start.
Using latest build.
What i'am doing wrong?

pi@raspberrypi:~ $ aplay -Dhw:CARD=S10th,DEV=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:CARD=S10th,DEV=0":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S32_LE SPECIAL DSD_U32_BE
SUBFORMAT:  STD
SAMPLE_BITS: 32
FRAME_BITS: 64
CHANNELS: 2
RATE: [44100 384000]
PERIOD_TIME: [125 1486078)
PERIOD_SIZE: [8 65536]
PERIOD_BYTES: [64 524288]
PERIODS: [2 1024]
BUFFER_TIME: (41 2972155)
BUFFER_SIZE: [16 131072]
BUFFER_BYTES: [128 1048576]
TICK_TIME: ALL
--------------------
aplay: set_params:1339: Sample format non available
Available formats:
- S32_LE
- SPECIAL
- DSD_U32_BE
pi@raspberrypi:~ $ ./librespot --name rasp --device-type speaker --backend alsa --bitrate 320 --format S32 --device plughw:1,0 --disable-audio-cache --volume-ctrl linear --initial-volume 50 
[2021-06-04T15:22:39Z INFO  librespot] librespot **0.2.0 33c07f0 (Built on 2021-06-02**, Build ID: CNFDrudt)
[2021-06-04T15:22:50Z INFO  librespot_core::session] Connecting to AP "gew1-accesspoint-d-cfc4.ap.spotify.com:4070"
[2021-06-04T15:22:50Z INFO  librespot_core::session] Authenticated as "z3efh6a1zvkdn7g3dvh5ngtno" !
[2021-06-04T15:22:50Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Linear
[2021-06-04T15:22:50Z INFO  librespot_core::session] Country: "RU"
[2021-06-04T15:22:50Z INFO  librespot_playback::audio_backend::alsa] Using Alsa sink with format: S32
[2021-06-04T15:22:51Z INFO  librespot_playback::player] Loading <Dreams> with Spotify URI <spotify:track:2jbtkmkMgu0QzuaWi1boGI>
[2021-06-04T15:22:52Z INFO  librespot_playback::player] <Dreams> (328451 ms) loaded
[2021-06-04T15:22:54Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error'
[2021-06-04T15:22:54Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed
[2021-06-04T15:22:54Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error'
[2021-06-04T15:22:54Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed
[2021-06-04T15:22:54Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error'
[2021-06-04T15:22:54Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', playback/src/audio_backend/alsa.rs:170:37
stack backtrace:
   0:   0x96fb38 - <unknown>
   1:   0x99a720 - <unknown>
   2:   0x967b1c - <unknown>
   3:   0x9724d0 - <unknown>
   4:   0x971f08 - <unknown>
   5:   0x972ce4 - <unknown>
   6:   0x97280c - <unknown>
   7:   0x9700b4 - <unknown>
   8:   0x97278c - <unknown>
   9:   0x9975d4 - <unknown>
  10:   0x997530 - <unknown>
  11:   0x66b120 - <unknown>
  12:   0x66b2ec - <unknown>
  13:   0x64e580 - <unknown>
  14:   0x5bd450 - <unknown>
  15:   0x579a60 - <unknown>
  16:   0x541788 - <unknown>
  17:   0x57adf4 - <unknown>
  18:   0x979b5c - <unknown>
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: SendError(Pause)', playback/src/player.rs:348:51
stack backtrace:
   0:   0x96fb38 - <unknown>
   1:   0x99a720 - <unknown>
   2:   0x967b1c - <unknown>
   3:   0x9724d0 - <unknown>
   4:   0x971f08 - <unknown>
   5:   0x972ce4 - <unknown>
   6:   0x972844 - <unknown>
   7:   0x9700b4 - <unknown>
   8:   0x97278c - <unknown>
   9:   0x9975d4 - <unknown>
  10:   0x99742c - <unknown>
  11:   0x64cdc8 - <unknown>
  12:   0x5d6b88 - <unknown>
  13:   0x5d65b0 - <unknown>
  14:   0x567998 - <unknown>
  15:   0x5693e4 - <unknown>
  16:   0x53cfb0 - <unknown>
  17:   0x56a748 - <unknown>
  18:   0x51d484 - <unknown>
  19:   0x58b170 - <unknown>
  20:   0x51e06c - <unknown>
  21:   0x52b714 - <unknown>
  22:   0x54191c - <unknown>
  23:   0x59dc04 - <unknown>
  24:   0x973224 - <unknown>
  25:   0x52b7dc - <unknown>
  26: 0xb6c45718 - __libc_start_main
[2021-06-04T15:22:56Z ERROR librespot_playback::player] Player thread panicked!
Originally created by @wpresident on GitHub (Jun 4, 2021). Original GitHub issue: https://github.com/librespot-org/librespot/issues/787 Originally assigned to: @roderickvd on GitHub. Hi. I'am trying to use librespot with raspberry pi zero w (Raspberry Pi OS Lite + raspotify) and usb dac. As i understand my DAC can do 32bit, not 16bit. So i use --format S32. But have errors after song start. Using latest build. What i'am doing wrong? ``` pi@raspberrypi:~ $ aplay -Dhw:CARD=S10th,DEV=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:CARD=S10th,DEV=0": -------------------- ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED FORMAT: S32_LE SPECIAL DSD_U32_BE SUBFORMAT: STD SAMPLE_BITS: 32 FRAME_BITS: 64 CHANNELS: 2 RATE: [44100 384000] PERIOD_TIME: [125 1486078) PERIOD_SIZE: [8 65536] PERIOD_BYTES: [64 524288] PERIODS: [2 1024] BUFFER_TIME: (41 2972155) BUFFER_SIZE: [16 131072] BUFFER_BYTES: [128 1048576] TICK_TIME: ALL -------------------- aplay: set_params:1339: Sample format non available Available formats: - S32_LE - SPECIAL - DSD_U32_BE ``` ``` pi@raspberrypi:~ $ ./librespot --name rasp --device-type speaker --backend alsa --bitrate 320 --format S32 --device plughw:1,0 --disable-audio-cache --volume-ctrl linear --initial-volume 50 [2021-06-04T15:22:39Z INFO librespot] librespot **0.2.0 33c07f0 (Built on 2021-06-02**, Build ID: CNFDrudt) [2021-06-04T15:22:50Z INFO librespot_core::session] Connecting to AP "gew1-accesspoint-d-cfc4.ap.spotify.com:4070" [2021-06-04T15:22:50Z INFO librespot_core::session] Authenticated as "z3efh6a1zvkdn7g3dvh5ngtno" ! [2021-06-04T15:22:50Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Linear [2021-06-04T15:22:50Z INFO librespot_core::session] Country: "RU" [2021-06-04T15:22:50Z INFO librespot_playback::audio_backend::alsa] Using Alsa sink with format: S32 [2021-06-04T15:22:51Z INFO librespot_playback::player] Loading <Dreams> with Spotify URI <spotify:track:2jbtkmkMgu0QzuaWi1boGI> [2021-06-04T15:22:52Z INFO librespot_playback::player] <Dreams> (328451 ms) loaded [2021-06-04T15:22:54Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error' [2021-06-04T15:22:54Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed [2021-06-04T15:22:54Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error' [2021-06-04T15:22:54Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed [2021-06-04T15:22:54Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_hw_params' failed with error 'EIO: I/O error' [2021-06-04T15:22:54Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', playback/src/audio_backend/alsa.rs:170:37 stack backtrace: 0: 0x96fb38 - <unknown> 1: 0x99a720 - <unknown> 2: 0x967b1c - <unknown> 3: 0x9724d0 - <unknown> 4: 0x971f08 - <unknown> 5: 0x972ce4 - <unknown> 6: 0x97280c - <unknown> 7: 0x9700b4 - <unknown> 8: 0x97278c - <unknown> 9: 0x9975d4 - <unknown> 10: 0x997530 - <unknown> 11: 0x66b120 - <unknown> 12: 0x66b2ec - <unknown> 13: 0x64e580 - <unknown> 14: 0x5bd450 - <unknown> 15: 0x579a60 - <unknown> 16: 0x541788 - <unknown> 17: 0x57adf4 - <unknown> 18: 0x979b5c - <unknown> thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: SendError(Pause)', playback/src/player.rs:348:51 stack backtrace: 0: 0x96fb38 - <unknown> 1: 0x99a720 - <unknown> 2: 0x967b1c - <unknown> 3: 0x9724d0 - <unknown> 4: 0x971f08 - <unknown> 5: 0x972ce4 - <unknown> 6: 0x972844 - <unknown> 7: 0x9700b4 - <unknown> 8: 0x97278c - <unknown> 9: 0x9975d4 - <unknown> 10: 0x99742c - <unknown> 11: 0x64cdc8 - <unknown> 12: 0x5d6b88 - <unknown> 13: 0x5d65b0 - <unknown> 14: 0x567998 - <unknown> 15: 0x5693e4 - <unknown> 16: 0x53cfb0 - <unknown> 17: 0x56a748 - <unknown> 18: 0x51d484 - <unknown> 19: 0x58b170 - <unknown> 20: 0x51e06c - <unknown> 21: 0x52b714 - <unknown> 22: 0x54191c - <unknown> 23: 0x59dc04 - <unknown> 24: 0x973224 - <unknown> 25: 0x52b7dc - <unknown> 26: 0xb6c45718 - __libc_start_main [2021-06-04T15:22:56Z ERROR librespot_playback::player] Player thread panicked! ```
kerem 2026-02-27 19:30:28 +03:00
Author
Owner

@roderickvd commented on GitHub (Jun 4, 2021):

You are running aplay and librespot with two different devices. Please use the same ones and report back.

plughw should really take any format and reformat to whatever your hardware device supports so I suspect an issue with your Alsa configuration.

<!-- gh-comment-id:854824894 --> @roderickvd commented on GitHub (Jun 4, 2021): You are running `aplay` and `librespot` with two different devices. Please use the same ones and report back. `plughw` should really take any format and reformat to whatever your hardware device supports so I suspect an issue with your Alsa configuration.
Author
Owner

@wpresident commented on GitHub (Jun 4, 2021):

I have only one sound card (DAC) connected to USB.
I'am weak with launch line. Shouldn't I use --device plughw:1,0 ?

 aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: S10th [SMSL Sanskrit 10th], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
pi@raspberrypi:~ $ ./librespot --device ?
[2021-06-04T15:51:24Z INFO  librespot] librespot 0.2.0 33c07f0 (Built on 2021-06-02, Build ID: CNFDrudt)
[2021-06-04T15:51:24Z INFO  librespot_playback::audio_backend::alsa] Using Alsa sink with format: S16
Listing available Alsa outputs:
pcm devices:
default:CARD=S10th
        SMSL Sanskrit 10th, USB Audio
        Default Audio Device

sysdefault:CARD=S10th
        SMSL Sanskrit 10th, USB Audio
        Default Audio Device

front:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        Front speakers

surround21:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        2.1 Surround output to Front and Subwoofer speakers

surround40:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        4.0 Surround output to Front and Rear speakers

surround41:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        4.1 Surround output to Front, Rear and Subwoofer speakers

surround50:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        5.0 Surround output to Front, Center and Rear speakers

surround51:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        5.1 Surround output to Front, Center, Rear and Subwoofer speakers

surround71:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        7.1 Surround output to Front, Center, Side, Rear and Woofer speakers

iec958:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        IEC958 (S/PDIF) Digital Audio Output

dmix:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        Direct sample mixing device

dsnoop:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        Direct sample snooping device

hw:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        Direct hardware device without any conversions

plughw:CARD=S10th,DEV=0
        SMSL Sanskrit 10th, USB Audio
        Hardware device with all software conversions

ctl devices:
hwdep devices:
<!-- gh-comment-id:854829862 --> @wpresident commented on GitHub (Jun 4, 2021): I have only one sound card (DAC) connected to USB. I'am weak with launch line. Shouldn't I use `--device plughw:1,0` ? ``` aplay -l **** List of PLAYBACK Hardware Devices **** card 1: S10th [SMSL Sanskrit 10th], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 ``` ``` pi@raspberrypi:~ $ ./librespot --device ? [2021-06-04T15:51:24Z INFO librespot] librespot 0.2.0 33c07f0 (Built on 2021-06-02, Build ID: CNFDrudt) [2021-06-04T15:51:24Z INFO librespot_playback::audio_backend::alsa] Using Alsa sink with format: S16 Listing available Alsa outputs: pcm devices: default:CARD=S10th SMSL Sanskrit 10th, USB Audio Default Audio Device sysdefault:CARD=S10th SMSL Sanskrit 10th, USB Audio Default Audio Device front:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio Front speakers surround21:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio 2.1 Surround output to Front and Subwoofer speakers surround40:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio 4.0 Surround output to Front and Rear speakers surround41:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers iec958:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio IEC958 (S/PDIF) Digital Audio Output dmix:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio Direct sample mixing device dsnoop:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio Direct sample snooping device hw:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio Direct hardware device without any conversions plughw:CARD=S10th,DEV=0 SMSL Sanskrit 10th, USB Audio Hardware device with all software conversions ctl devices: hwdep devices: ```
Author
Owner

@roderickvd commented on GitHub (Jun 4, 2021):

The device you want is probably hw:0, this is the most "bare metal". You may also try plughw:0 (with all software conversions) or just hw:CARD=S10th,DEV=0 for the full name of your device.

In any case I am closing this as I am 99% sure that this is not an issue with librespot.

<!-- gh-comment-id:854890158 --> @roderickvd commented on GitHub (Jun 4, 2021): The device you want is probably `hw:0`, this is the most "bare metal". You may also try `plughw:0` (with all software conversions) or just `hw:CARD=S10th,DEV=0` for the full name of your device. In any case I am closing this as I am 99% sure that this is not an issue with `librespot`.
Author
Owner

@JasonLG1979 commented on GitHub (Jun 4, 2021):

You are running aplay and librespot with two different devices. Please use the same ones and report back.

There's really no way to know that. hw:CARD=S10th,DEV=0 could very well be the same device as plughw:1,0 (just going though plug ofc) You can address cards by name or index.

The device you want is probably hw:0, this is the most "bare metal". You may also try plughw:0 (with all software conversions) or just hw:CARD=S10th,DEV=0 for the full name of your device.

hw:0 is just the 1st card that alsa runs into. Generally hw:0 is the built-in sound card if the device has it and it's not otherwise disabled. Indexes are assigned on a 1st come 1st served basis. If your system has a built-in sound and a USB DAC the DAC will be hw:1 most of the time. (his aplay -l lists his DAC as hw:1) That's why referring to them by name is always best when in doubt.

But I agree otherwise. Either use --device hw:1,0 or --device hw:CARD=S10th,DEV=0

<!-- gh-comment-id:854897968 --> @JasonLG1979 commented on GitHub (Jun 4, 2021): > You are running `aplay` and `librespot` with two different devices. Please use the same ones and report back. There's really no way to know that. `hw:CARD=S10th,DEV=0` could very well be the same device as `plughw:1,0` (just going though `plug` ofc) You can address cards by name or index. > The device you want is probably hw:0, this is the most "bare metal". You may also try plughw:0 (with all software conversions) or just hw:CARD=S10th,DEV=0 for the full name of your device. `hw:0` is just the 1st card that `alsa` runs into. Generally `hw:0` is the built-in sound card if the device has it and it's not otherwise disabled. Indexes are assigned on a 1st come 1st served basis. If your system has a built-in sound and a USB DAC the DAC will be `hw:1` most of the time. (his `aplay -l` lists his DAC as `hw:1`) That's why referring to them by name is always best when in doubt. But I agree otherwise. Either use `--device hw:1,0` or `--device hw:CARD=S10th,DEV=0`
Author
Owner

@JasonLG1979 commented on GitHub (Jun 4, 2021):

I can confirm though that plughw:x,x works just fine as a --device value. Come to think of it, it looks like you may be trying to open a device that's already open judging by the 'EIO: I/O error' part of the error. Only one program can open a sound device at a time.

<!-- gh-comment-id:854913405 --> @JasonLG1979 commented on GitHub (Jun 4, 2021): I can confirm though that `plughw:x,x` works just fine as a `--device` value. Come to think of it, it looks like you may be trying to open a device that's already open judging by the `'EIO: I/O error'` part of the error. Only one program can open a sound device at a time.
Author
Owner

@wpresident commented on GitHub (Jun 9, 2021):

Problem solved. All of this because of usb power-board that was attached to second-hand rpi i bought (https://www.elecrow.com/usb-hub-powermanager-for-rpi-zero-v1-0.html)
Disconnected it and used simple pc usb hub via micro usb port on rpi zero w. Works like a charm.

<!-- gh-comment-id:857828434 --> @wpresident commented on GitHub (Jun 9, 2021): Problem solved. All of this because of usb power-board that was attached to second-hand rpi i bought (https://www.elecrow.com/usb-hub-powermanager-for-rpi-zero-v1-0.html) Disconnected it and used simple pc usb hub via micro usb port on rpi zero w. Works like a charm.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#410
No description provided.