Comment 5 for bug 1598309

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

@Bruno - I looked into this a little bit and ALSA doesn't allow you to override the ALSA_CONFIG_DIR in the default configuration. However, your snap can ship a configuration that you point ALSA_CONFIG_PATH at and that configuration file can be setup to work. I'm not an ALSA developer and have only sketched out the following snap so that I might develop security policy for an alsa interface: https://git.launchpad.net/~jdstrand/+git/alsa-utils?h=master

What it does is:
- ship a wrapper in files/bin/wrapper that sets ALSA_CONFIG_PATH="$SNAP/etc/alsa.conf"
- ship files/etc/alsa.conf that is a modified version of /usr/share/alsa/alsa.conf that substitutes references to datadir with values in /snap/alsa-utils/current. ALSA supports 'getenv' in the configuration files so it shouldn't be too much work for someone to getenv the $SNAP dir instead of hard-coding /snap/alsa-utils/current
- ships files/etc/alsa/cards/* that are modified versions of /usr/share/alsa/cards/* that replace 'confdir:pcm' with '/snap/alsa-utils/current/usr/share/alsa/pcm'

With the above, in devmode can:

$ alsa-utils.speaker-test
$ alsa-utils.aplay /snap/alsa-utils/current/usr/share/sounds/alsa/Noise.wav
$ alsa-utils.arecord ~/snap/alsa-utils/common/out.wav
$ alsa-utils.aplay ~/snap/alsa-utils/common/out.wav

I suspect a snapcraft part would be worthwhile for setting up the wrapper, alsa.conf and sed'ing the /usr/share/alsa/cards/*.conf files?