Il mar 24 feb 2026, 09:02 Markus Armbruster <[email protected]> ha scritto:

> Sergei Heifetz <[email protected]> writes:
>
> > When QEMU is configured with `--disable-audio`, do not build any
> > audio-related sources.
> >
> > - audio/meson.build and replay/meson.build:
> >   Exclude audio-related sources when audio is disabled.
> >
> > - audio/audio-stub.c:
> >   Provide a minimal set of straightforward stubs.
> >
> > - replay/replay-audio-stub.c:
> >   Move the existing stubs from replay/stubs-system.c into a separate
> >   file.
> >
> > - qapi/audio.json:
> >   Remove the QMP `query-audiodevs` command.
> >
> > - hmp-commands*.hx:
> >   Remove the HMP `info capture`, `stopcapture` and `wavcapture`
> >   commands.
> >
> > Signed-off-by: Sergei Heifetz <[email protected]>
>
> [...]
>
> diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h
> index f1319c9002..f80f6c98d4 100644
> --- a/include/qemu/audio-capture.h
> +++ b/include/qemu/audio-capture.h
> @@ -8,6 +8,8 @@
>
>  #include "audio.h"
>
> +#ifdef CONFIG_AUDIO
> +
>  struct capture_ops {
>      void (*info) (void *opaque);
>      void (*destroy) (void *opaque);
> @@ -30,4 +32,6 @@ void audio_be_del_capture(
>      CaptureVoiceOut *cap,
>      void *cb_opaque);
>
> +#endif
> +
>  #endif /* QEMU_AUDIO_CAPTURE_H */
> diff --git a/include/qemu/audio.h b/include/qemu/audio.h
> index cff8a334f3..552689116c 100644
> --- a/include/qemu/audio.h
> +++ b/include/qemu/audio.h
> @@ -32,6 +32,8 @@
>  #include "gio/gio.h"
>  #endif
>
> +#ifdef CONFIG_AUDIO
> +
>  typedef void (*audio_callback_fn) (void *opaque, int avail);
>
>  typedef struct audsettings {
> @@ -240,4 +242,7 @@ static inline bool audio_format_is_signed(AudioFormat
> fmt)
>  #define TYPE_AUDIO_BACKEND "audio-backend"
>  OBJECT_DECLARE_TYPE(AudioBackend, AudioBackendClass, AUDIO_BACKEND)
>
> +#else
> +#define audio_cleanup() ((void)0)
> +#endif
>  #endif /* QEMU_AUDIO_H */
> diff --git a/ui/vnc.h b/ui/vnc.h
> index ec8d0c91b5..89e0199be1 100644
> --- a/ui/vnc.h
> +++ b/ui/vnc.h
> @@ -184,7 +184,9 @@ struct VncDisplay
>      VncDisplaySASL sasl;
>  #endif
>
> +#ifdef CONFIG_AUDIO
>      AudioBackend *audio_be;
> +#endif
>
>      VMChangeStateEntry *vmstate_handler_entry;
>  };
> @@ -325,8 +327,10 @@ struct VncState
>      pixman_format_code_t client_format;
>      int client_endian; /* G_LITTLE_ENDIAN or G_BIG_ENDIAN */
>
> +#ifdef CONFIG_AUDIO
>      CaptureVoiceOut *audio_cap;
>      struct audsettings as;
> +#endif
>
>      VncReadEvent *read_handler;
>      size_t read_handler_expect;
> diff --git a/audio/audio-stub.c b/audio/audio-stub.c
> index f58f88cd83..e69de29bb2 100644
> --- a/audio/audio-stub.c
> +++ b/audio/audio-stub.c
> @@ -1,22 +0,0 @@
> -/*
> - * Stub for audio.c
> - *
> - * SPDX-License-Identifier: GPL-2.0-or-later
> - */
> -
> -#include "qemu/osdep.h"
> -#include "qapi/qapi-commands-audio.h"
> -#include "qemu/audio.h"
> -#include "qapi/error.h"
> -
> -void audio_cleanup(void) {}
> -
> -AudioBackend *audio_be_by_name(const char *name, Error **errp)
> -{
> -  error_setg(errp, "audio disabled");
> -  return NULL;
> -}
> -
> -void audio_init_audiodevs(void) {}
> -
> -void audio_create_default_audiodevs(void) {}
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index d4ef620c17..12fbe0b0a6 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -750,6 +750,7 @@ static char *machine_get_audiodev(Object *obj, Error
> **errp)
>  static void machine_set_audiodev(Object *obj, const char *value,
>                                   Error **errp)
>  {
> +#ifdef CONFIG_AUDIO
>      MachineState *ms = MACHINE(obj);
>
>      if (!audio_be_by_name(value, errp)) {
> @@ -758,6 +759,9 @@ static void machine_set_audiodev(Object *obj, const
> char *value,
>
>      g_free(ms->audiodev);
>      ms->audiodev = g_strdup(value);
> +#else
> +    error_setg(errp, "audio disabled");
> +#endif
>  }
>
>  HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState
> *machine)
> diff --git a/system/vl.c b/system/vl.c
> index 1034a4688f..6b2e7bc26e 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -2067,10 +2067,12 @@ static void qemu_create_early_backends(void)
>       * setting machine properties, so they can be referred to.
>       */
>      configure_blockdev(&bdo_queue, machine_class, snapshot);
> +#ifdef CONFIG_AUDIO
>      audio_init_audiodevs();
>      if (default_audio) {
>          audio_create_default_audiodevs();
>      }
> +#endif
>  }
>
>
> diff --git a/ui/dbus.c b/ui/dbus.c
> index 60c8e0b473..2354e5d805 100644
> --- a/ui/dbus.c
> +++ b/ui/dbus.c
> @@ -35,7 +35,9 @@
>  #include "ui/egl-context.h"
>  #endif
>  #include "qemu/audio.h"
> +#ifdef CONFIG_AUDIO
>  #include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of
> drv->name */
> +#endif
>  #include "qapi/error.h"
>  #include "trace.h"
>
>
>

Reply via email to