D-Bus display can be used even when QEMU is configured with
`--disable-audio`. In that case, audio interface will not be available
on `/org/qemu/Display1/Audio`.

(The current handling of the situation when audio is enabled but
no D-Bus-compatible audio backend is available is different and
hasn’t been changed.)

Signed-off-by: Sergei Heifetz <[email protected]>
---
 qapi/ui.json    | 2 +-
 qemu-options.hx | 4 ++++
 ui/dbus.c       | 8 ++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index e3da77632a8..62eb05c6091 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1385,7 +1385,7 @@
   'data'    : { '*rendernode' : 'str',
                 '*addr': 'str',
                 '*p2p': 'bool',
-                '*audiodev': 'str' } }
+                '*audiodev': { 'type': 'str', 'if': 'CONFIG_AUDIO' } } }
 
 ##
 # @DisplayGLMode:
diff --git a/qemu-options.hx b/qemu-options.hx
index 29dc865820a..20d15c0004f 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2232,6 +2232,10 @@ SRST
         If no audio backend is specified and the dbus display backend is
         specified, the dbus audio backend is used by default.
 
+        (If audio is disabled at compile time via the ``--disable-audio`` 
option,
+        no audio backend is used, and none of the audio-related D-Bus 
interfaces
+        are exported.)
+
         The connection is registered with the "org.qemu" name (and queued when
         already owned).
 
diff --git a/ui/dbus.c b/ui/dbus.c
index 4f24215555a..99dac3e7feb 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -217,6 +217,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
         return;
     }
 
+#ifdef CONFIG_AUDIO
     {
         AudioBackend *audio_be = audio_get_default_audio_be(NULL);
         if (audio_be && !audio_be_can_set_dbus_server(audio_be)) {
@@ -232,6 +233,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
             return;
         }
     }
+#endif
 
     consoles = g_array_new(FALSE, FALSE, sizeof(guint32));
     for (idx = 0;; idx++) {
@@ -370,6 +372,7 @@ set_dbus_addr(Object *o, const char *str, Error **errp)
     dd->dbus_addr = g_strdup(str);
 }
 
+#ifdef CONFIG_AUDIO
 static char *
 get_audiodev(Object *o, Error **errp)
 {
@@ -386,6 +389,7 @@ set_audiodev(Object *o, const char *str, Error **errp)
     g_free(dd->audiodev);
     dd->audiodev = g_strdup(str);
 }
+#endif
 
 
 static int
@@ -412,7 +416,9 @@ dbus_display_class_init(ObjectClass *oc, const void *data)
     ucc->complete = dbus_display_complete;
     object_class_property_add_bool(oc, "p2p", get_dbus_p2p, set_dbus_p2p);
     object_class_property_add_str(oc, "addr", get_dbus_addr, set_dbus_addr);
+#ifdef CONFIG_AUDIO
     object_class_property_add_str(oc, "audiodev", get_audiodev, set_audiodev);
+#endif
     object_class_property_add_enum(oc, "gl-mode",
                                    "DisplayGLMode", &DisplayGLMode_lookup,
                                    get_gl_mode, set_gl_mode);
@@ -502,7 +508,9 @@ dbus_init(DisplayState *ds, DisplayOptions *opts)
                           object_get_objects_root(),
                           "dbus-display", &error_fatal,
                           "addr", opts->u.dbus.addr ?: "",
+#ifdef CONFIG_AUDIO
                           "audiodev", opts->u.dbus.audiodev ?: "",
+#endif
                           "gl-mode", DisplayGLMode_str(mode),
                           "p2p", yes_no(opts->u.dbus.p2p),
                           NULL);
-- 
2.34.1


Reply via email to