From 829dce524dbbf34439422cd2906b94ce0e7920ed Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 May 2020 19:35:21 +0200 Subject: [PATCH] Fix T72920: Snap package fails to play audio and blocks audio in other apps ALSA and OSS are not available for the snap packages, and trying to initialize them seems to cause some problems for other applications. Instead configure OpenAL and SDL to use PulseAudio, and set PULSE_SERVER environment variable to make it work. --- release/freedesktop/snap/blender-wrapper | 19 +++++++++++++++++++ release/freedesktop/snap/snapcraft.yaml.in | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 release/freedesktop/snap/blender-wrapper diff --git a/release/freedesktop/snap/blender-wrapper b/release/freedesktop/snap/blender-wrapper new file mode 100755 index 00000000000..c116a4c2712 --- /dev/null +++ b/release/freedesktop/snap/blender-wrapper @@ -0,0 +1,19 @@ +# Disable ALSA and OSS as they are not available, and trying to initialize them +# breaks sound in other apps. Use PulseAudio instead. +export ALSOFT_DRIVERS=-oss,-alsa, +export SDL_AUDIODRIVER=pulseaudio + +# Make PulseAudio socket available inside the snap-specific $XDG_RUNTIME_DIR +# This is adapted from https://github.com/ubuntu/snapcraft-desktop-helpers, +# in common/desktop-exports. +mkdir -p $XDG_RUNTIME_DIR -m 700 +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 + +# Run Blender +$SNAP/blender diff --git a/release/freedesktop/snap/snapcraft.yaml.in b/release/freedesktop/snap/snapcraft.yaml.in index a79d9ccc0a2..eb3ef97eba8 100644 --- a/release/freedesktop/snap/snapcraft.yaml.in +++ b/release/freedesktop/snap/snapcraft.yaml.in @@ -24,7 +24,7 @@ confinement: classic apps: blender: - command: ./blender + command: ./blender-wrapper desktop: ./blender.desktop version: '@VERSION@' @@ -46,3 +46,8 @@ parts: - libxfixes3 - libxrender1 - libxxf86vm1 + wrapper: + plugin: copy + source: . + files: + blender-wrapper: blender-wrapper