Using HifiBerry DACPlus with OSMC and squeezelite

Hey there,
I’ve been searching for this one pretty intensely over the last weeks and I couldn’t find an answer.
My setup:
raspi 4 B
HifiBerry DAC (+)

I have OSMC installed along with squeezelite to use my beloved squeezebox server.

My major problem is as follows:
I can pass the sound of my squeezelite client to the hifiberry. When I do so the capability of kodi to read the sound output options is broken and I have to use bluetooth to play the sound from kodi. Like I can not choose any audio output from the settings.

When I deactivate squeezelite I can use the hifiberry audio jack without any problem and use the settings menu to look for output options. So obviously those two audio sources can not cope with one audio sink…

I couldn’t find any instruction to use ALSA for mixing both of those sources and what I found on pulseaudio was rather intimidating.
I tried my luck with pulseaudio but was not able to get it moving.

Do you have any idea where I could start?

One or both of squeezelite and kodi are accessing your hifiberry directly. You need to use the dmix plug-in for the hifiberry and point both applications to that. If you can post the output of aplay -l and aplay -L (you may have to install alsa-tools) we can suggest something.

Do you already have a .soundrc file in your home directory? If so, post that as well.

thanks for the fast reply:
the output of aplay -l:

**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: sndrpihifiberry [snd_rpi_hifiberry_dacplus], Gerät 0: HiFiBerry DAC+ HiFi pcm512x-hifi-0 [HiFiBerry DAC+ HiFi pcm512x-hifi-0]
  Sub-Geräte: 0/1
  Sub-Gerät #0: subdevice #0
Karte 1: vc4hdmi1 [vc4-hdmi-1], Gerät 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0

and of aplay -L

null
    Discard all samples (playback) or generate zero samples (capture)
btaudio
    Bluetooth Audio
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
default:CARD=sndrpihifiberry
    snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0
    Default Audio Device
sysdefault:CARD=sndrpihifiberry
    snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0
    Default Audio Device
dmix:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0
    Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0
    Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0
    Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0
    Hardware device with all software conversions
usbstream:CARD=sndrpihifiberry
    snd_rpi_hifiberry_dacplus
    USB Stream Output
default:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    HDMI Audio Output
dmix:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Direct sample mixing device
dsnoop:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Direct sample snooping device
hw:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Hardware device with all software conversions
usbstream:CARD=vc4hdmi1
    vc4-hdmi-1
    USB Stream Output

And I don’t have a .soundrc file.

Thanks for introducing me to all that sound stuff. Beginning to learn and great to be welcomed!

Cheers and enjoy the weekend!

You need something like this:

pcm.hifimix {
    type dmix
    ipc_key 12345
    slave.pcm "hw:CARD=sndrpihifiberry,DEV=0"
    hint { show on description "HiFiBerry dmix" }
}

Make a file called .asoundrc in your home directory ( nano ~/.asoundrc) with those lines in it. Then restart Kodi with Power->Exit and you should see a new entry in the audio devices list. Choose that and also point squeezelite at the same device.

And uninstall pulseaudio.

1 Like

Amazing! Works like a charme!

I used a systemd service for squeezelite in /etc/systemd/system/sounddaemon.service like this:

[Unit]
Description=SqueezeLite Player Service
After=network.target

[Service]
Type=simple
User=osmc

ExecStart=/usr/bin/squeezelite  -o hifimix
ExecStop=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

Now everything is connected I don’t have to use pulseaudio!

Thanks!

2 Likes

Hi hukipola,
maybe you can help me with my setup?
It’s almost the same, only the card is a hifiberry digi+ pro.
I did the same like you, but now i only have vc4-hdmi as the output for kodi :frowning: Output of squeezile -l : Output devices:
null - Discard all samples (playback) or generate zero samples (capture)
btaudio - Bluetooth Audio
default:CARD=sndrpihifiberry - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Default Audio Device
sysdefault:CARD=sndrpihifiberry - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Default Audio Device
iec958:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Hardware device with all software conversions
default:CARD=vc4hdmi - vc4-hdmi, MAI PCM i2s-hifi-0 - Default Audio Device
sysdefault:CARD=vc4hdmi - vc4-hdmi, MAI PCM i2s-hifi-0 - Default Audio Device
hdmi:CARD=vc4hdmi,DEV=0 - vc4-hdmi, MAI PCM i2s-hifi-0 - HDMI Audio Output
dmix:CARD=vc4hdmi,DEV=0 - vc4-hdmi, MAI PCM i2s-hifi-0 - Direct sample mixing device
dsnoop:CARD=vc4hdmi,DEV=0 - vc4-hdmi, MAI PCM i2s-hifi-0 - Direct sample snooping device
hw:CARD=vc4hdmi,DEV=0 - vc4-hdmi, MAI PCM i2s-hifi-0 - Direct hardware device without any conversions
plughw:CARD=vc4hdmi,DEV=0 - vc4-hdmi, MAI PCM i2s-hifi-0 - Hardware device with all software conversions

I cannot run aplay -l: “command not found”.

Thank you!

hey tgazmann,

first of all you need to install the package for aplay:

sudo apt-get update
sudo apt-get install alsa-utils

Then you use the setup in the myosmc menu for setting up your system for the hifiberry card.

Then you point the system to the hifimix like described by grahamh in the post above.

And then you use a systemd service for the squeezelite as described by my post.
On how to setup a systemd service read this man page:

and try to use a system wide service.

Don’t hesitate to come back when you don’t know any further.

cheers

hukipola

hi hukipola,
thanks! following your guide:

install alsa-utils > done

aplay -l:
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_digi], device 0: HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 [HiFiBerry Digi+ Pro HiFi wm8804-spdif-0]
Subdevices: 0/1
Subdevice #0: subdevice #0

squeezelite -l:
Output devices:
null - Discard all samples (playback) or generate zero samples (capture)
btaudio - Bluetooth Audio
hifimix2 - HiFiBerry dmix
default:CARD=sndrpihifiberry - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Default Audio Device
sysdefault:CARD=sndrpihifiberry - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Default Audio Device
iec958:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_digi, HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 - Hardware device with all software conversions

there is the “hifimix2” plugin

setting up MYOSMC >> done

But it seems that squeezelite and kodi doesnot recognize the “hifimix2” interface.

kodi.log:

2022-01-23 22:54:01.611 T:438 INFO : CAESinkALSA - Unable to open device “hifimix2” for playback

squeezelite does not even start, becouse of the missing interface.

After kodi starts, i can choose the card hifiberry from the SETTINGS/SYSTEM/AUDIO menu, but that i could set even without the whole listed before.

Thank you!

squeezelite -o hifimix2

[23:08:33.045630] test_open:294 playback open error: Device or resource busy
[23:08:33.045913] output_init_common:381 unable to open output device

started from scratch and now it works! THANKS FOR THE HELP!
i did not set soundc overlay ind MYOSMC, is this nessecary?

dmix mode is only working with “hw:CARD=sndrpihifiberry,DEV=0” ?
if i set “iec958:CARD=sndrpihifiberry,DEV=0” in .asoundrc then neither kodi nor squeezelite can’t open the interface…

i think for the playback iec958 is more closer to “bit-perfect”.

regards

1 Like