Alsa : cannot access devices

I’m giving snaping ALSA another go.

I want to retrieve a list of available sound devices. When run as a normal program, everything is fine :

AlsaSnapTest 0.5 started
card_num = 0
card_name = HDA Intel HDMI
card_id = HDMI
....
card_num = -1
AlsaSnapTest 0.5 ended

However, the snap has trouble opening the devices.

AlsaSnapTest 0.5 started
card_num = 0
ALSA lib control.c:1373:(snd_ctl_open_noupdate) Invalid CTL hw:0
Can't open card 0 : No such file or directory
...
card_num = -1
AlsaSnapTest 0.5 ended

Any idea how to achieve this ? I’ve used @lucyllewy 's work on audacity to add alsa to my snapcraft.yaml

Here are the steps to follow to reproduce :

git clone https://github.com/frenchguych/alsa-snap-test.git
cd alsa-snap-test
git checkout packaging
snapcraft
sudo snap install ./alsa-snap-test_dev_amd64.snap --devmode
alsa-snap-test

Thanks !

3 Likes

You app: doesn’t list the alsa interface, so that maybe a factor. Also the alsa interface is not auto-connected so after installing your snap you’ll need to snap connect alsa-snap-test:alsa

Thanks @Wimpress . I added the alsa plug, and connected it after install, but that didn’t change the result.

apps:
  alsa-snap-test:
    command: desktop-launch alsa-launch $SNAP/bin/alsa-snap-test
    plugs:
      - alsa
      - pulseaudio
      - home
      - network
      - x11
      - desktop
snapcraft
sudo snap install ./alsa-snap-test_dev_amd64.snap --devmode
sudo snap connect alsa-snap-test:alsa
alsa-snap-test
AlsaSnapTest 0.5 started
card_num = 0
ALSA lib control.c:1373:(snd_ctl_open_noupdate) Invalid CTL hw:0
Can't open card 0 : No such file or directory
...

Could it be that inside the snap, the hardware devices are not named hw:0, hw:1, etc… ?

Hi @yannick-mauray, I have the very same problem. Did you figure out how to solve the issue?

hi,

I have got an idea, might be you are using confinement strict. Like me, I try for now confinement classic and tell you the result.

Hi @jkraehemann, no I didn’t get anywhere with this.

Let me know if you get any kind of result !

Hi

Just try this:

but you have to stage (remove) any self provided libraries like:

    stage:
      - -usr/share/alsa
      - -usr/lib/x86_64-linux-gnu/libasound.so
      - -usr/lib/x86_64-linux-gnu/libasound.so.2
      - -usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
      - -usr/lib/i386-linux-gnu/libasound.so
      - -usr/lib/i386-linux-gnu/libasound.so.2
      - -usr/lib/i386-linux-gnu/libasound.so.2.0.0

Since the remote part installs the libraries in usr/lib instead of usr/lib/x86_64-linux-gnu the conflict is not detected.

I am not sure if it works but I want to try.

Hi,

I have got it working but it is just pulseaudio ALSA emulation and the only device you get is “default”

cheers,
Joël

Hi,

Could be a configuration flag issue, I just try this:

and keep you updated.

Thanks. FYI I’ve tried that already, but didn’t get anywhere. However, I may have made a mistake, so it’s worth giving that another go !