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: |
+16 -25
View File
@@ -21,7 +21,8 @@ set -e
# - gl is the plain GL render-API support (no X11/Wayland context backend),
# which jlibmpv's externally supplied OpenGL context (JOGL) consumes via
# the mpv render API. No vo is built at all (cplayer=false).
# - alsa is the audio output (no PulseAudio/JACK/OSS).
# - audio goes through the system audio stack (PipeWire/Pulse/ALSA, all
# linked dynamically, like CoreAudio/WASAPI); no JACK/OSS.
#
# All third-party sources are pinned to the latest stable tag that existed on
# the mpv v0.41.0 release date (2025-12-21), so a rebuild reproduces the same
@@ -57,7 +58,6 @@ FRIBIDI_VER=1.0.16
HARFBUZZ_VER=12.2.0
FONTCONFIG_VER=2.16.2
EXPAT_VER=R_2_7_3
ALSA_VER=v1.2.15
# Static everywhere: every dependency becomes a .a archive that gets linked
# into the single libmpv.so. (mpv's own script ships shared libs instead.)
@@ -129,26 +129,6 @@ _expat () {
}
_expat_mark=lib/libexpat.a
_alsa () {
gitpin https://github.com/alsa-project/alsa-lib.git alsa-lib "$ALSA_VER"
builddir alsa-lib
# alsa-lib ships autotools inputs but no generated configure; generate it
# in the source tree (we build out-of-tree from ../). -fPIC is required
# because the static archive is linked into the shared libmpv.so, and
# alsa's configure only adds -fPIC for shared builds.
( cd .. && autoreconf -fi )
# --with-configdir pins the ALSA_CONFIG_DIR compile-time default to the
# canonical system path instead of our build prefix. alsa-lib looks up its
# config at this path at runtime (env ALSA_CONFIG_DIR / ALSA_CONFIG_PATH
# override); leaving it at $prefix_dir/share/alsa makes snd_pcm_open("default")
# fail on any machine that does not carry that build path.
CFLAGS="$CFLAGS -fPIC" ../configure --prefix="$prefix_dir" \
--with-configdir=/usr/share/alsa $commonflags
makeplusinstall
popd
}
_alsa_mark=lib/libasound.a
_fontconfig () {
gitpin https://github.com/fontconfig/fontconfig.git fontconfig "$FONTCONFIG_VER"
builddir fontconfig
@@ -278,7 +258,11 @@ _libplacebo_mark=lib/libplacebo.a
# Group A: no intra-prefix deps (freetype is built with harfbuzz off, so it
# needs nothing we build here - only system zlib).
for x in expat alsa freetype fribidi dav1d lcms2; do
# (ALSA is deliberately NOT built here: it is linked dynamically against the
# system libasound.so.2, like CoreAudio on macOS / WASAPI on Windows. A static
# libasound failed to resolve the dynamic "cards.pcm.default" device at
# runtime, so audio is left to the OS audio stack.)
for x in expat freetype fribidi dav1d lcms2; do
build_if_missing $x
done
# Group B: depend on group A (fontconfig/libass need freetype2.pc, libass
@@ -296,7 +280,13 @@ rm -rf $build
# against the static dependency archives built above. No CLI player, no tests,
# no lua/javascript, no vulkan. plain-gl is the OpenGL render-API support
# (no X11/Wayland context backend - jlibmpv supplies the GL context via JOGL).
# alsa is the audio output.
# Audio: pipewire, pulse and alsa are all enabled and linked against their
# system shared libs (meson finds them via the system pkg-config), consistent
# with CoreAudio/WASAPI on the other platforms - the OS audio stack is left
# dynamic, everything else static. mpv auto-probes audio drivers in the order
# pipewire -> pulse -> alsa, so on a PipeWire/Pulse box it uses the working
# server before falling back to the direct ALSA/dmix path (which is what
# breaks on desktops where PipeWire owns the sound cards).
meson setup $build \
--buildtype release -Dstrip=true \
-Ddefault_library=shared \
@@ -310,7 +300,8 @@ meson setup $build \
-Dvulkan=disabled \
-Dgl=enabled -Dplain-gl=enabled \
-Dgl-x11=disabled -Degl=disabled -Ddrm=disabled -Dwayland=disabled \
-Dalsa=enabled -Dpulse=disabled -Djack=disabled -Doss-audio=disabled \
-Dpipewire=enabled -Dpulse=enabled -Dalsa=enabled \
-Djack=disabled -Doss-audio=disabled \
-Dx11=disabled -Dx11-clipboard=disabled
meson compile -C $build