From 66fdb74b5b360901b8c4b707de508d5f58e72002 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Mon, 13 Jan 2020 10:05:26 +0100 Subject: [PATCH] qemu: Make QEMU audio backend configurable (!1859) At the moment we assume that everyone running QEMU is either using ALSA, or has the ALSA PulseAudio plugin configured on the host system. (Since we run QEMU outside of the chroot at the moment, configuration files are read from the host system instead of the chroot...) Other distributions have much wider support for PulseAudio, so not everyone will actually have the ALSA PulseAudio plugin configured. In that case, it is better to use QEMU's PulseAudio backend since that does not require any configuration. It also lets us drop the alsa-lib fork, since that was only needed for loading the ALSA PulseAudio plugin. In general, it seems difficult to detect which audio backend the user wants to run (if any). Selecting the wrong one results in ugly warnings when running QEMU. So let's not assume any by default, and add a --audio option instead which accepts one of QEMU's audio backends (alsa, pa or sdl). --- pmb/parse/arguments.py | 4 ++++ pmb/qemu/run.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index 275f4584..87b690cb 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -147,6 +147,10 @@ def arguments_qemu(subparser): help="QEMU's display parameter (default: sdl,gl=on)", default="sdl,gl=on", nargs="?") + ret.add_argument("--audio", dest="qemu_audio", choices=["alsa", "pa", "sdl"], + help="QEMU's audio backend (default: none)", + default=None, nargs="?") + ret.add_argument("--host-qemu", dest="host_qemu", action='store_true', help="Use the host system's qemu") diff --git a/pmb/qemu/run.py b/pmb/qemu/run.py index cb0379f2..0c48faed 100644 --- a/pmb/qemu/run.py +++ b/pmb/qemu/run.py @@ -129,8 +129,7 @@ def command_qemu(args, arch, device, img_path, spice_enabled): rootfs_native = args.work + "/chroot_native" env = {"QEMU_MODULE_DIR": rootfs_native + "/usr/lib/qemu", "GBM_DRIVERS_PATH": rootfs_native + "/usr/lib/xorg/modules/dri", - "LIBGL_DRIVERS_PATH": rootfs_native + "/usr/lib/xorg/modules/dri", - "ALSA_PLUGIN_DIRS": rootfs_native + "/usr/lib/alsa-lib"} + "LIBGL_DRIVERS_PATH": rootfs_native + "/usr/lib/xorg/modules/dri"} if "gtk" in args.qemu_display: gdk_cache = create_gdk_loader_cache(args) @@ -218,8 +217,9 @@ def command_qemu(args, arch, device, img_path, spice_enabled): command += ["-display", args.qemu_display] # Audio support - command += ["-audiodev", "id=alsa,driver=alsa"] - command += ["-soundhw", "hda"] + if args.qemu_audio: + command += ["-audiodev", args.qemu_audio + ",id=audio"] + command += ["-soundhw", "hda"] return (command, env) @@ -274,7 +274,7 @@ def install_depends(args, arch): "mesa-gl", "mesa-egl", "mesa-dri-ati", "mesa-dri-freedreno", "mesa-dri-intel", "mesa-dri-nouveau", "mesa-dri-swrast", "mesa-dri-virtio", "mesa-dri-vmwgfx", "qemu-audio-alsa", - "qemu-audio-sdl", "alsa-plugins-pulse"] + "qemu-audio-pa", "qemu-audio-sdl"] if args.spice_port: depends += ["virt-viewer", "font-noto"] pmb.chroot.apk.install(args, depends)