fix: enable PipeWire/Pulse AOs so audio works on PipeWire desktops (#1)

* fix: link libmpv against the system libasound instead of a static build

A statically linked libasound fails at runtime with 'Unknown PCM
cards.pcm.default': the default PCM is resolved dynamically per sound card
(load_for_all_cards hook enumerating cards and loading cards/<driver>.conf),
and that machinery did not work in the vendored archive, so audio produced no
output even though the config file itself was found (the earlier
--with-configdir prefix bug is fixed).

Link libasound.so.2 dynamically from the system (libasound2-dev), exactly like
CoreAudio on macOS and WASAPI on Windows: the OS audio stack stays external,
all video dependencies remain static and self-contained.

The build script no longer builds alsa-lib (the _alsa step, ALSA_VER pin and
the autoreconf dependency it needed are gone); meson resolves the system
'alsa' dependency via pkg-config. The workflow installs libasound2-dev, drops
autoconf/automake/libtool, and verifies ldd shows libasound.so.2 instead of
asserting a baked-in config dir.

* fix: enable PipeWire/Pulse AOs so audio works on PipeWire desktops

On a desktop where PipeWire owns the sound cards, the direct ALSA/dmix
'default' path is broken: snd_pcm_open('default') resolves to a dmix slave
that cannot be opened (verified: aplay -D default fails identically, while
aplay -D pulse works). libmpv with only the ALSA AO therefore got no sound.

mpv auto-probes audio drivers in the order pipewire -> pulse -> alsa, so
enable all three (each linked against its system shared lib, consistent with
CoreAudio/WASAPI). On a PipeWire/Pulse box it now uses the working server
before ever falling back to the direct ALSA path.

The workflow installs libpipewire-0.3-dev and libpulse-dev alongside
libasound2-dev, and the artifact verification now accepts any of the three
system audio libs instead of only libasound.

---------

Co-authored-by: david <david@phoenix.ipv64.de>
This commit is contained in:
kirbylink
2026-10-02 18:25:12 +02:00
committed by GitHub
co-authored by david
parent 61b5018811
commit 8ad01bbab1
2 changed files with 34 additions and 49 deletions
+18 -24
View File
@@ -1,10 +1,11 @@
name: build-linux
# Builds a single self-contained libmpv.so for Linux (x86_64) from mpv source
# pinned to a release tag. Every dependency is built static and linked into
# the one .so; only glibc/pthread/dl/m and the system zlib stay external, so
# the artifact has no runtime dependency closure to ship (unlike mpv's own
# shared-lib CI build).
# pinned to a release tag. Every video dependency is built static and linked
# into the one .so; glibc/pthread/dl/m, the system zlib and the system audio
# stack (PipeWire / PulseAudio / ALSA) stay external, mirroring CoreAudio
# (macOS) and WASAPI (Windows), so the OS audio is left dynamic and
# everything else is self contained.
#
# Linux is the easiest of the three platforms: a single native build on an
# ubuntu runner, no cross-compile, no lipo. The only Linux-specific work is the
@@ -61,7 +62,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
ccache nasm ninja-build pkgconf cmake autoconf automake libtool
ccache nasm ninja-build pkgconf cmake \
libasound2-dev libpulse-dev libpipewire-0.3-dev
python3 -m pip install meson
# Run the vendored build script from inside the mpv source tree, so the
@@ -83,16 +85,13 @@ jobs:
ls -l artifact-libmpv
# Verify the artifact is self-contained and portable:
# (1) ldd shows only system libs (no vendored .so to ship),
# (2) no .debug sections remain (strip worked, artifact stays small),
# (3) the ALSA config dir is the system path, not the build prefix.
# (The prefix-baked ALSA_CONFIG_DIR is what broke audio before:
# snd_pcm_open("default") looked for <prefix>/share/alsa/alsa.conf
# on the target box. fontconfig also bakes its prefix into the
# binary, but that is benign - with no config at that path it falls
# back to a built-in config that scans /usr/share/fonts, so we do
# NOT fail on fontconfig prefix strings.)
- name: Verify artifact (ldd, size, alsa config dir)
# (1) ldd shows only system libs - and among them libasound.so.2,
# because audio is left to the OS stack (CoreAudio/WASAPI model),
# (2) no .debug sections remain (strip worked, artifact stays small).
# fontconfig bakes its build prefix into the binary, but that is benign:
# with no config file at that path it falls back to a built-in config
# that scans /usr/share/fonts, so we do NOT fail on those strings.
- name: Verify artifact (ldd, size, alsa is a system lib)
run: |
cd artifact-libmpv
echo "=== dynamic deps (system libs only) ==="
@@ -101,18 +100,13 @@ jobs:
readelf -S libmpv.so | grep -c '\.debug' || true
echo "=== size ==="
du -h libmpv.so
echo "=== ALSA config dir baked into the lib (must be /usr/share/alsa) ==="
if strings -a libmpv.so | grep -q "linux_prefix/share/alsa\|/share/alsa"; then
strings -a libmpv.so | grep -o "[^ ]*share/alsa" | sort -u
echo "=== system audio libs present (pipewire/pulse/alsa, not vendored) ==="
if ldd libmpv.so | grep -Eq 'libpipewire-0\.3|libpulse\.so|libasound\.so'; then
echo "OK: at least one system audio lib present, as intended"
else
echo "ERROR: no ALSA config dir found in libmpv.so (libasound not linked?)"
echo "ERROR: libmpv.so links no audio backend (no sound?)"
exit 1
fi
if strings -a libmpv.so | grep -q "linux_prefix/share/alsa"; then
echo "ERROR: ALSA config dir points at the build prefix (audio will be broken)"
exit 1
fi
echo "OK"
- name: Checksums
run: |