ALSA lib return error cannot open shared library .../libasound_module_pcm_pulse.so

Bug #1864381 reported by guy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Invalid
Undecided
Unassigned

Bug Description

I am trying to use ALSA according to this site https://snapcraft-alsa.readthedocs.io/en/latest/snapcraft_usage.html that I found in the snapcraft forum https://forum.snapcraft.io/t/reusable-alsa-lib-part/3556/28

After snapping I get the following 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
ALSA lib control.c:1373:(snd_ctl_open_noupdate) Invalid CTL hw:2
ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_pulse.so
ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_pulse.so
Fail to open PortAudio stream, error message is Device unavailable.

If you need some code to try I can create public project in github

snapcraft.yaml :

name: app-name
base: core18
version: '0.2' # Just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

  #grade: stable # must be 'stable' to release into candidate/stable channels
  #confinement: strict # use 'strict' once you have the right plugs and slots

grade: devel # Must be 'stable' to release into candidate/stable channels
confinement: devmode
#architectures: [all]

parts:
  alsa-mixin:
    plugin: nil
    source: https://github.com/diddlesnaps/snapcraft-alsa.git
    override-pull: |
      cat > asound.conf <<EOF
      pcm.!default {
          type pulse
          fallback "sysdefault"
          hint {
              show on
              description "Default ALSA Output (currently PulseAudio Sound Server)"
          }
      }
      ctl.!default {
          type pulse
          fallback "sysdefault"
      }
      EOF
      cat > alsa-launch <<EOF
      #!/bin/bash
      export ALSA_CONFIG_PATH="\$SNAP/etc/asound.conf"

      if [ -d "\$SNAP/usr/lib/alsa-lib" ]; then
          export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/usr/lib/alsa-lib"
      elif [ -d "\$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib" ]; then
          export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib"
      fi
      export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio"

      # Make PulseAudio socket available inside the snap-specific \$XDG_RUNTIME_DIR
      if [ -n "\$XDG_RUNTIME_DIR" ]; then
          pulsenative="pulse/native"
          pulseaudio_sockpath="\$XDG_RUNTIME_DIR/../\$pulsenative"
          if [ -S "\$pulseaudio_sockpath" ]; then
              export PULSE_SERVER="unix:\${pulseaudio_sockpath}"
          fi
      fi

      exec "\$@"
      EOF
      chmod +x alsa-launch
    override-build: |
      snapcraftctl build
      install -m644 -D -t $SNAPCRAFT_PART_INSTALL/etc asound.conf
      install -m755 -D -t $SNAPCRAFT_PART_INSTALL/snap/command-chain alsa-launch
    build-packages:
      - libasound2-dev
    stage-packages:
      - libasound2
      - libasound2-plugins

  app-name:
    after: [alsa-mixin]
    plugin: dump
    source: .
    override-build: |

      # some code here that I have deleted for the post

      snapcraftctl build

    build-packages:
      - wget
      - unzip
      - git
      - gcc
      - make
      # - python3-pyaudio
      - python3-pip
      - libevent-dev
      # - python-dev
      # - libpcre3
      # - libpcre3-dev
      - libperl-dev
      # - libasound2
      # - libasound2-dev
      - libatlas-base-dev
      - libasound2-plugins
      # - alsa-utils
      # - pulseaudio
      - libasound-dev
    stage-packages:
      # - python3-pyaudio
      # - sox
      # - python-setuptools
      - libatlas-base-dev
      - libevent-dev
      # - python3-pip
      # - python-dev
      # - libpcre3
      # - libpcre3-dev
      # - libperl-dev
      # - libasound2
      # - libasound2-dev
      # - alsa-utils
      # - pulseaudio

apps:
  demo:
    command-chain: ["snap/command-chain/alsa-launch"]
    command: scripts/cScripts/demo $SNAP
    plugs: [network, network-bind, gpio, hardware-observe, audio-playback, audio-record, pulseaudio, alsa]

Tags: alsa
Revision history for this message
guy (guyluz11) wrote :

I have created a project that have only the ALSA parts that I use, hope it will help debugging

https://github.com/guyluz11/Alsa-snap-not-working

Revision history for this message
Lucy Llewellyn (lucyllewy) wrote :

I've updated the instructions with a simpler integration. The old instructions were missing the `layout` definition, which is a requirement:

```
layout:
  /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
    bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
```

You can either copy just the layout into what you already have, which is the easiest option because it should only be missing the layout; or, you can redo the alsa configuration with the updated code on https://snapcraft-alsa.readthedocs.io/en/latest/snapcraft_usage.html

Revision history for this message
guy (guyluz11) wrote :

Add the layout now I have different 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
ALSA lib control.c:1373:(snd_ctl_open_noupdate) Invalid CTL hw:2
ALSA lib pcm_pulse.c:752:(pulse_prepare) PulseAudio: Unable to create stream: Access denied

Expression 'r' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2092
Expression 'PaAlsaStreamComponent_FinishConfigure( &self->capture, hwParamsCapture, inParams, self->primeBuffers, realSr, inputLatency )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2726
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2838
Fail to open PortAudio stream, error message is Unanticipated host error.

I can create new bug for the new error if it preferable.

Revision history for this message
guy (guyluz11) wrote :

Adding the layout part solved it for me the previous error that I posted is on PulseAudio on the computer, thanks for all the help.

The bug can be closed now.

Changed in snapd:
status: New → Invalid
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.