I tried adding the audio-playback interface to my snapcraft.yaml and have the pulseaudio snap installed but I’m not getting audio output via HDMI or the headphone socket on the Raspberry Pi 3. The documentation says that the audio-playback interface auto-connects, but the plug of my application doesn’t seem to have connected to anything.
Do I need to use the alsa interface perhaps? Or is there another staging snap or package I need to install?
Are you able to play audio using the commands from the pulseaudio snap i.e. pulseaudio.paplay with a sample mp3 file or something ? It could be that the pulseaudio snap is not working
The pulseaudio snap needs to be updated to provide the audio-playback and audio-record slots, it currently only provides pulseaudio so there is nothing for your snap to plugs audio-playback to.
I’m not even sure how I would do that? The /snap/bin/pulseaudio.pactl binary only seems to have limited commands and /snap/bin/pulseaudio.pactl upload-sample foo.mp3 fails to open a file I scp to the device. How can I test it?
Ah OK. I noticed that you replaced the pulseaudio interface with the audio-playback interface in the snapcraft-desktop-helpers examples and said that audio-playback now “only manually connects pulseaudio”. So what do I need to do to get audio output from Electron?
For the moment, you need to plugs pulseaudio (feel free to continue to plugs audio-playpack), then when you install, use snap connect <your snap name>:pulseaudio.
But really the snap needs to be updated. Not sure who is owning that these days, @awe, @abeato , @kenvandine or @Wimpress, can you comment?
Thank you for the suggestion, but I already tried this. With the pulseaudio plug defined in snapcraft.yaml and pulseaudio installed, my application auto-connects the :pulseaudio plug as follows:
Is your application starting as a daemon? I suspect you’ll get output if it is, as the daemon and pulseaudio snaps will both be running as (confined) root, rather than as your user.
I replaced the audio-playback plug with an alsa plug and manually connected it with:
$ snap connect krellian-kiosk:alsa :alsa
Unfortunately I still get the same errors.
Edit: I tried installing the alsa-utils snap and running the speaker test (with sudo) and I do get audio output from that. So the problem does seem to be with whatever Electron is trying to do.
The MAINTAINERS file lists @morphis, but there have been no changes since November 2017. I don’t think anyone is actively maintaining the snap at this point.
I do have a desktop-gtk3 part which is adapter from snapcraft-desktop-helpers as per the tutorial. Would you have expected that to do fix the library path?
Thanks for this suggestion, this got past the alsa.conf error, but then I just had a bunch more errors.
Bingo! Once I added libpulse0 to stage-packages audio output started working.
I have now removed the alsa plug and added both the audio-playback and pulseaudio plugs back and it seems to work. It also seems to autoconnect the pulseaudio plug which is not what the documentation suggests.
This is because that page is talking about the implicit classic slot that you see on classic distro (not Ubuntu Core devices where the interface does not exist unless a snap provides it). The pulseaudio snap is providing the pulseaudio slot, and this snap allows auto-connection of the pulseaudio interface. It doesn’t provide the audio-playback and audio-record interfaces, so its pulseaudio slot was not deprecated.
I realise it’s tricky to document these interfaces when there are differences between implementations, but I’ve added comments on the Supported Interfaces and pulseaudio pages to suggest making this more clear in the documentation.
It also wasn’t obvious to me that I needed to install the pulseaudio snap (and stage the libpulse0 package) for this interface to work on Ubuntu Core.
(I would edit the documentation myself, but I’m not sure what the policy is on documenting differences between implementations as I guess the documentation is supposed to apply to all distros, not just Ubuntu)
this is not core specific, you need to do this for all installations when wanting to talk to pulse … if you use somehing like the gnome-3-xx extensions (like many desktop apps do) it comes for free with the extension though …