summary refs log tree commit diff stats
path: root/audio/audio.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2023-10-05 18:42:54 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2023-10-08 21:08:27 +0200
commit63a13c08055072e92129a1d0ffeeecdcac6ad3d4 (patch)
tree720dd36f44f0b236fa9198ee8cbcbfb7e6418ed3 /audio/audio.c
parent22f84d4f7882d881a5f8574430da62c7ce5a0731 (diff)
downloadfocaccia-qemu-63a13c08055072e92129a1d0ffeeecdcac6ad3d4.tar.gz
focaccia-qemu-63a13c08055072e92129a1d0ffeeecdcac6ad3d4.zip
audio: reintroduce default audio backend for VNC
Make VNC use the default backend again if one is defined.
The recently introduced support for disabling the VNC audio
extension is still used, in case no default backend exists.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'audio/audio.c')
-rw-r--r--audio/audio.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/audio/audio.c b/audio/audio.c
index bd4bcabcca..73b65dc3b9 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1801,20 +1801,28 @@ out:
     return NULL;
 }
 
-bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp)
+AudioState *audio_get_default_audio_state(Error **errp)
 {
-    if (!card->state) {
+    if (!default_audio_state) {
+        default_audio_state = audio_init(NULL, errp);
         if (!default_audio_state) {
-            default_audio_state = audio_init(NULL, errp);
-            if (!default_audio_state) {
-                if (!QSIMPLEQ_EMPTY(&audiodevs)) {
-                    error_append_hint(errp, "Perhaps you wanted to use -audio or set audiodev=%s?\n",
-                                      QSIMPLEQ_FIRST(&audiodevs)->dev->id);
-                }
-                return false;
+            if (!QSIMPLEQ_EMPTY(&audiodevs)) {
+                error_append_hint(errp, "Perhaps you wanted to use -audio or set audiodev=%s?\n",
+                                  QSIMPLEQ_FIRST(&audiodevs)->dev->id);
             }
         }
-        card->state = default_audio_state;
+    }
+
+    return default_audio_state;
+}
+
+bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp)
+{
+    if (!card->state) {
+        card->state = audio_get_default_audio_state(errp);
+        if (!card->state) {
+            return false;
+        }
     }
 
     card->name = g_strdup (name);