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).
This commit is contained in:
Minecrell 2020-01-13 10:05:26 +01:00 committed by Alexey Min
parent e04712a636
commit 66fdb74b5b
No known key found for this signature in database
GPG Key ID: EBF5ECFFFEE34DED
2 changed files with 9 additions and 5 deletions

View File

@ -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")

View File

@ -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)