Snap with ALSA lib does not work if run as daemon

Bug #1868530 reported by guy
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
snapd
Invalid
Undecided
Unassigned

Bug Description

I got my snap working and now I need it to run as daemon (daemon: simple) in the background.
Unfortunately my snap use ALSA lib which cannot run with super user permissions https://forum.snapcraft.io/t/reusable-alsa-lib-part/3556/33

"With at least Ubuntu, the pulseaudio system is started per user session at login. This requires that the session be a desktop (gui) session. The pulseaudio system is restricted from being accessed by other users, including root, while it runs in a user session. What this means is that you cannot use the pulseaudio system from a daemon or system service or anything run through sudo."

Error:

  ALSA lib control.c:1373:(snd_ctl_open_noupdate) Invalid CTL hw:0
  ALSA lib control.c:1373:(snd_ctl_open_noupdate) Invalid CTL hw:1
  No protocol specified
  xcb_connection_has_error() returned true
  ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
  No protocol specified
  xcb_connection_has_error() returned true
  ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
  Fail to open PortAudio stream, error message is Device unavailable.

I am opening this bug because this is holding me back from continuing my startup and I need to stay notify if anything changes.

Revision history for this message
Samuele Pedroni (pedronis) wrote :

* we are implementing user daemon services

* there is a way for snap services to switch to a different user than root/drop privileges:

    https://forum.snapcraft.io/t/system-usernames/13386

Changed in snapd:
status: New → Invalid
Revision history for this message
guy (guyluz11) wrote :

I have created side project to test it.
While using the daemon services with
system-usernames:
  snap_daemon: shared
I still can't use alsa inside the sanp.

This is a link to the project on github if it more convenient for you https://github.com/guyluz11/Alsa-snap-not-working .
The .c file that I run is located in Alsa-snap-not-working/Again/scripts/cScripts/snowboy/examples/C/demo.c

I have also created question in the forum, there you can also see my .yaml file: https://forum.snapcraft.io/t/running-alsa-inside-daemon-snap/18850

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.