I cobbled together this solution based on several different posts, but I could not find anything directly when I had searched for combinations of terms in the title, so I thought I would leave this here for the next person trying to do the same.
I am guessing this might be too specific to add to Docs? If you disagree, I would be willing to contribute something.
OSMC uses ALSA. You don’t need to install pulseaudio (as I read in some posts). But you do need to install the following packages, which were not pulled in as dependencies for some reason(?) (I installed via apt.mopidy.com):
gstreamer1.0-alsa
The following packages helped me in diagnosing what was going on, but are not strictly needed just to get it working (these are for Debian which OSMC is based on, I’m currently still on Stretch on this particular RPi):
gstreamer1.0-tools
provides gst-inspect-1.0
(and maybe gst-launch-1.0
and/or aplay
?)
Then I was able to get the following command working:
gst-launch-1.0 audiotestsrc ! audioresample ! alsasink device=hw:1,0
Once you get to this point (hearing output tone from speakers attached to HiFiBerry) you are just about there. Simply take the above and add it into your config, like so:
[audio]
output = alsasink device=hw:1,0
Oh I forgot. How did I find that information? By doing aplay -l
which gave me the following output:
osmc@rpi:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ HiFi pcm512x-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
So, in this case the HiFiBerry is card 1, subdevice 0, aka hw:1,0
which is what you test with command above and then put in your config file.
I hope that helps someone. It took me a couple hours to figure it out, but I am still learning about sound on GNU/Linux.
Finally, I am not sure if it is appropriate to adjust packaging for Debian to include gstreamer-1.0-alsa
or not? I think it would be required for everything, no? Or just needed for HiFiBerry?