Alsa sound not working with core24

I made the necessary changes as mentioned in Migrate to core24 to my snap https://github.com/trixon/yaya/blob/develop/packaging/snap/snap/snapcraft.yaml to make it build with core24.

The first thing I noted was that the generated snap is 127MB, with core22 it’s only 66MB. Why is that?

The second thing is that the sound is no longer working, I’m getting a java exception when trying to play sound. Any ideas what could be wrong?

layout:
  /usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/alsa-lib:
    bind: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/alsa-lib

   ...
   stage-packages:
      - libasound2
      - libasound2-plugins
   ...
  alsa-pulseaudio:
    plugin: dump
    source: .
    override-pull: |
      mkdir etc -p
      cat > etc/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

I made a few snaps using Alsa (not yet with Core24). This is the best doc I found: https://snapcraft-alsa.readthedocs.io/en/latest/ (link from GitHub - diddlesnaps/snapcraft-alsa: ALSA for your snap package routing sound through Pulseaudio! )

with this example code: https://snapcraft-alsa.readthedocs.io/en/latest/snapcraft_usage.html

I’d try removing

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

On the adaptation of Lucy’s original work you’re using, I’ve never seen that layout be necessary, so it might be worth testing both Core22 and Core24 without it.

Otherwise, let us know the Java error :slight_smile:

If you go back to Lucy’s original above, then I’d add it back in. But the spin off you’re using has never needed it because it only exists in the domain of fixing ALSA → Pulse(+Pipe implicitly), not fixing direct userland ALSA access like Lucy’s.

Sorry about the missing java error @James-Carroll, here it is.

SEVERE [global]
java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian is supported.
        at java.desktop/javax.sound.sampled.AudioSystem.getLine(Unknown Source)
        at java.desktop/javax.sound.sampled.AudioSystem.getClip(Unknown Source)
        at se.trixon.yaya.dice.data.sound.Sound.lambda$load$3(Sound.java:88)
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
        at se.trixon.yaya.dice.data.sound.Sound.load(Sound.java:82)
        at se.trixon.yaya.dice.data.sound.Sound.<init>(Sound.java:43)
        at se.trixon.yaya.dice.Die$RollThread.rollOut(Die.java:362)
[catch] at se.trixon.yaya.dice.Die$RollThread.run(Die.java:317)

Removing the layout section on core22 did not seem to brake anything. Removing it on core24 did not fix the problem.

Regarding the generated snap size, is it supposed to be so much larger ?

Im shipping a custom java runtime image but the error is there when I use a classic JRE too.

I noticed that libasound2-plugins in core24 results in the extra 60MB compared with core22 and that by removing libasound2-plugins from the core22 snap I got the same error as with the core24.

To me it looks like libasound2-plugins is not configured correctly in my core24 snap, but I have no idea how to fix that.