[gnome-boxes/workaround-audio-regression] vm-configurator: Introduce hack to fix regression in audio




commit 1f62f093b89eab8b84ecb7134c60e9a3d3f5a7a8
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Dec 1 12:55:51 2021 +0100

    vm-configurator: Introduce hack to fix regression in audio
    
    Libvirt 7.2.0 (2021-04-01) added support for audio backend specific
    settings. See https://libvirt.org/news.html
    
    Boxes uses libvirt-glib to manipulate libvirt domain configurations,
    and libvirt-glib doesn't have yet a GVirConfig.DomainAudio device.
    
    This is a temporary fix/hack that edits the VM configuration XML
    directly to replace the audio.type and audio.serverName properties
    of the <audio> xml node. This DOES NOT test for the existence or
    support of the audio backend.
    
    See #738

 src/vm-configurator.vala | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index b9b515d1..27554b24 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -273,6 +273,21 @@ public static async void update_existing_domain (Domain          domain,
             if (device is DomainGraphics)
                 continue;
 
+            // Fix broken audio. FIXME. See https://gitlab.gnome.org/GNOME/gnome-boxes/-/issues/738
+            var device_xml = device.to_xml ();
+            if (device_xml.has_prefix ("<audio") && device_xml.contains ("none")) {
+                debug ("Fixing audio for %s\n", domain.name);
+
+                var server_name = Path.build_filename (Environment.get_user_runtime_dir (), "pulse", 
"native");
+                var fixed_audio_xml = device_xml.replace ("none\"",
+                                                          "pulseaudio\" serverName=\"%s\"".printf 
(server_name));
+
+                var audio_device = new GVirConfig.Object.from_xml (typeof (DomainDevice), "audio", "", 
fixed_audio_xml);
+                devices.prepend (audio_device as DomainDevice);
+
+                continue;
+            }
+
             if (device is DomainInterface)
                 iface = device as DomainInterface;
             else if (device is DomainChannel) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]