Skip to content

Commit 3c785eb

Browse files
committed
fix(quickemu): detect audio backends via sockets, not pidof
- Replace process checks (pidof pipewire / pidof pulseaudio) with socket existence checks to determine functional audio services. - PipeWire detection checks $PIPEWIRE_REMOTE or $XDG_RUNTIME_DIR/pipewire-0. - PulseAudio detection checks $PULSE_SERVER or $XDG_RUNTIME_DIR/pulse/native. - Change default audio driver from pa to alsa as a safer fallback on headless hosts. - Set detection priority: PipeWire (if QEMU >= 8.1) → PulseAudio → ALSA. - Reason: a listening socket indicates a working service; pidof can be misleading on headless servers and caused QEMU "Failed to initialize PW context" errors. Fixes #1838 Signed-off-by: Martin Wimpress <martin@wimpress.org>
1 parent e777817 commit 3c785eb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

quickemu

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,15 +1266,17 @@ function check_cocoa_gl_es_support() {
12661266
}
12671267

12681268
function configure_display() {
1269-
# Determine which audio driver use between Pulseaudio or ALSA
1270-
local AUDIO_DRIVER="pa"
1271-
if pidof pipewire >/dev/null 2>&1; then
1269+
# Determine which audio driver to use: PipeWire, PulseAudio, or ALSA
1270+
# Socket detection is more reliable than process detection on headless servers
1271+
local AUDIO_DRIVER="alsa"
1272+
local pw_socket="${PIPEWIRE_REMOTE:-${XDG_RUNTIME_DIR}/pipewire-0}"
1273+
local pa_socket="${PULSE_SERVER:-${XDG_RUNTIME_DIR}/pulse/native}"
1274+
1275+
if [ "${QEMU_VER_SHORT}" -ge 81 ] && [ -S "${pw_socket}" ]; then
12721276
# QEMU's pipewire audio backend was added in version 8.1
1273-
if [ "${QEMU_VER_SHORT}" -ge 81 ]; then
1274-
AUDIO_DRIVER="pipewire"
1275-
fi
1276-
elif ! pidof pulseaudio >/dev/null 2>&1; then
1277-
AUDIO_DRIVER="alsa"
1277+
AUDIO_DRIVER="pipewire"
1278+
elif [ -S "${pa_socket}" ]; then
1279+
AUDIO_DRIVER="pa"
12781280
fi
12791281

12801282
# Setup the appropriate audio device based on the display output

0 commit comments

Comments
 (0)