All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Sergei Heifetz <heifetz@yandex-team.com>
Cc: qemu-devel@nongnu.org, "Eric Blake" <eblake@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [PATCH v3 09/11] audio: do not build audio-related sources with --disable-audio
Date: Thu, 19 Mar 2026 09:36:55 +0100	[thread overview]
Message-ID: <87fr5wcj14.fsf@pond.sub.org> (raw)
In-Reply-To: <20260315201646.96862-10-heifetz@yandex-team.com> (Sergei Heifetz's message of "Mon, 16 Mar 2026 01:16:44 +0500")

Sergei Heifetz <heifetz@yandex-team.com> 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.
>
> - 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.
>
> - Other source files:
>   Wrap audio-related code in ifdefs.
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>

[...]

> diff --git a/qapi/audio.json b/qapi/audio.json
> index 2df87b97101..28fda7c8ac3 100644
> --- a/qapi/audio.json
> +++ b/qapi/audio.json
> @@ -540,4 +540,5 @@
>  # Since: 8.0
>  ##
>  { 'command': 'query-audiodevs',
> -  'returns': ['Audiodev'] }
> +  'returns': ['Audiodev'],
> +  'if': 'CONFIG_AUDIO' }

Could we disable all the audio stuff here?

I tried, patch appended.  What do you think?

> diff --git a/replay/meson.build b/replay/meson.build
> index 4b4175e8dd4..dc2e94e8975 100644
> --- a/replay/meson.build
> +++ b/replay/meson.build
> @@ -7,7 +7,14 @@ system_ss.add(when: 'CONFIG_TCG', if_true: files(
>    'replay-char.c',
>    'replay-snapshot.c',
>    'replay-net.c',
> -  'replay-audio.c',
>    'replay-random.c',
>    'replay-debugging.c',
>  ), if_false: files('stubs-system.c'))
> +
> +if have_audio
> +  system_ss.add(when: 'CONFIG_TCG',
> +  if_true: files('replay-audio.c'),
> +  if_false: files('replay-audio-stub.c'))
> +else
> +  system_ss.add(files('replay-audio-stub.c'))
> +endif
> diff --git a/replay/replay-audio-stub.c b/replay/replay-audio-stub.c
> new file mode 100644
> index 00000000000..b3da8e15583
> --- /dev/null
> +++ b/replay/replay-audio-stub.c
> @@ -0,0 +1,21 @@
> +/*
> + * Stub for replay-audio.c
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "system/replay.h"
> +
> +void replay_audio_in_start(size_t *nsamples)
> +{
> +}
> +void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right)
> +{
> +}
> +void replay_audio_in_finish(void)
> +{
> +}
> +void replay_audio_out(size_t *played)
> +{
> +}

Should this go into stubs/ instead?  Genuine question!  I can't tell
when we use stubs/foo*.c and when we use foo/*stub.c.

> diff --git a/replay/stubs-system.c b/replay/stubs-system.c
> index b2c52bc4043..454415ae8e4 100644
> --- a/replay/stubs-system.c
> +++ b/replay/stubs-system.c
> @@ -15,18 +15,6 @@ void replay_input_sync_event(void)
>  void replay_add_blocker(const char *feature)
>  {
>  }
> -void replay_audio_in_start(size_t *nsamples)
> -{
> -}
> -void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right)
> -{
> -}
> -void replay_audio_in_finish(void)
> -{
> -}
> -void replay_audio_out(size_t *played)
> -{
> -}
>  void replay_breakpoint(void)
>  {
>  }

[...]

Note on the appended patch: the change to ui/dbus.c should be a separate
cleanup patch.


diff --git a/qapi/audio.json b/qapi/audio.json
index 28fda7c8ac..4f5f5dd988 100644
--- a/qapi/audio.json
+++ b/qapi/audio.json
@@ -49,7 +49,8 @@
     '*channels':       'uint32',
     '*voices':         'uint32',
     '*format':         'AudioFormat',
-    '*buffer-length':  'uint32' } }
+    '*buffer-length':  'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevGenericOptions:
@@ -65,7 +66,8 @@
 { 'struct': 'AudiodevGenericOptions',
   'data': {
     '*in':  'AudiodevPerDirectionOptions',
-    '*out': 'AudiodevPerDirectionOptions' } }
+    '*out': 'AudiodevPerDirectionOptions' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevDBusOptions:
@@ -85,7 +87,8 @@
   'data': {
     '*in':  'AudiodevPerDirectionOptions',
     '*out': 'AudiodevPerDirectionOptions',
-    '*nsamples': 'uint32'} }
+    '*nsamples': 'uint32'},
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevAlsaPerDirectionOptions:
@@ -107,7 +110,8 @@
   'data': {
     '*dev':           'str',
     '*period-length': 'uint32',
-    '*try-poll':      'bool' } }
+    '*try-poll':      'bool' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevAlsaOptions:
@@ -126,7 +130,8 @@
   'data': {
     '*in':        'AudiodevAlsaPerDirectionOptions',
     '*out':       'AudiodevAlsaPerDirectionOptions',
-    '*threshold': 'uint32' } }
+    '*threshold': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevSndioOptions:
@@ -148,7 +153,8 @@
     '*in':        'AudiodevPerDirectionOptions',
     '*out':       'AudiodevPerDirectionOptions',
     '*dev':       'str',
-    '*latency':   'uint32'} }
+    '*latency':   'uint32'},
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevCoreaudioPerDirectionOptions:
@@ -163,7 +169,8 @@
 { 'struct': 'AudiodevCoreaudioPerDirectionOptions',
   'base': 'AudiodevPerDirectionOptions',
   'data': {
-    '*buffer-count': 'uint32' } }
+      '*buffer-count': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevCoreaudioOptions:
@@ -179,7 +186,8 @@
 { 'struct': 'AudiodevCoreaudioOptions',
   'data': {
     '*in':  'AudiodevCoreaudioPerDirectionOptions',
-    '*out': 'AudiodevCoreaudioPerDirectionOptions' } }
+    '*out': 'AudiodevCoreaudioPerDirectionOptions' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevDsoundOptions:
@@ -199,7 +207,8 @@
   'data': {
     '*in':      'AudiodevPerDirectionOptions',
     '*out':     'AudiodevPerDirectionOptions',
-    '*latency': 'uint32' } }
+    '*latency': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevJackPerDirectionOptions:
@@ -233,7 +242,8 @@
     '*client-name':   'str',
     '*connect-ports': 'str',
     '*start-server':  'bool',
-    '*exact-name':    'bool' } }
+    '*exact-name':    'bool' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevJackOptions:
@@ -249,7 +259,8 @@
 { 'struct': 'AudiodevJackOptions',
   'data': {
     '*in':  'AudiodevJackPerDirectionOptions',
-    '*out': 'AudiodevJackPerDirectionOptions' } }
+    '*out': 'AudiodevJackPerDirectionOptions' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevOssPerDirectionOptions:
@@ -271,7 +282,8 @@
   'data': {
     '*dev':          'str',
     '*buffer-count': 'uint32',
-    '*try-poll':     'bool' } }
+    '*try-poll':     'bool' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevOssOptions:
@@ -301,7 +313,8 @@
     '*out':        'AudiodevOssPerDirectionOptions',
     '*try-mmap':   'bool',
     '*exclusive':  'bool',
-    '*dsp-policy': 'uint32' } }
+    '*dsp-policy': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevPaPerDirectionOptions:
@@ -326,7 +339,8 @@
   'data': {
     '*name': 'str',
     '*stream-name': 'str',
-    '*latency': 'uint32' } }
+    '*latency': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevPaOptions:
@@ -345,7 +359,8 @@
   'data': {
     '*in':     'AudiodevPaPerDirectionOptions',
     '*out':    'AudiodevPaPerDirectionOptions',
-    '*server': 'str' } }
+    '*server': 'str' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevPipewirePerDirectionOptions:
@@ -370,7 +385,8 @@
   'data': {
     '*name': 'str',
     '*stream-name': 'str',
-    '*latency': 'uint32' } }
+    '*latency': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevPipewireOptions:
@@ -386,7 +402,8 @@
 { 'struct': 'AudiodevPipewireOptions',
   'data': {
     '*in':     'AudiodevPipewirePerDirectionOptions',
-    '*out':    'AudiodevPipewirePerDirectionOptions' } }
+    '*out':    'AudiodevPipewirePerDirectionOptions' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevSdlPerDirectionOptions:
@@ -401,7 +418,8 @@
 { 'struct': 'AudiodevSdlPerDirectionOptions',
   'base': 'AudiodevPerDirectionOptions',
   'data': {
-    '*buffer-count': 'uint32' } }
+    '*buffer-count': 'uint32' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevSdlOptions:
@@ -417,7 +435,8 @@
 { 'struct': 'AudiodevSdlOptions',
   'data': {
     '*in':  'AudiodevSdlPerDirectionOptions',
-    '*out': 'AudiodevSdlPerDirectionOptions' } }
+    '*out': 'AudiodevSdlPerDirectionOptions' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevWavOptions:
@@ -436,7 +455,8 @@
   'data': {
     '*in':   'AudiodevPerDirectionOptions',
     '*out':  'AudiodevPerDirectionOptions',
-    '*path': 'str' } }
+    '*path': 'str' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudioFormat:
@@ -460,7 +480,8 @@
 # Since: 4.0
 ##
 { 'enum': 'AudioFormat',
-  'data': [ 'u8', 's8', 'u16', 's16', 'u32', 's32', 'f32' ] }
+  'data': [ 'u8', 's8', 'u16', 's16', 'u32', 's32', 'f32' ],
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @AudiodevDriver:
@@ -484,7 +505,8 @@
             { 'name': 'sdl', 'if': 'CONFIG_AUDIO_SDL' },
             { 'name': 'sndio', 'if': 'CONFIG_AUDIO_SNDIO' },
             { 'name': 'spice', 'if': 'CONFIG_SPICE' },
-            'wav' ] }
+            'wav' ],
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @Audiodev:
@@ -530,7 +552,8 @@
                    'if': 'CONFIG_AUDIO_SNDIO' },
     'spice':     { 'type': 'AudiodevGenericOptions',
                    'if': 'CONFIG_SPICE' },
-    'wav':       'AudiodevWavOptions' } }
+    'wav':       'AudiodevWavOptions' },
+  'if': 'CONFIG_AUDIO' }
 
 ##
 # @query-audiodevs:
diff --git a/audio/mixeng.h b/audio/mixeng.h
index f63283f408..0dfd5204a6 100644
--- a/audio/mixeng.h
+++ b/audio/mixeng.h
@@ -25,6 +25,8 @@
 #ifndef QEMU_MIXENG_H
 #define QEMU_MIXENG_H
 
+#ifdef CONFIG_AUDIO
+
 #ifdef FLOAT_MIXENG
 typedef float mixeng_real;
 struct mixeng_volume { int mute; mixeng_real r; mixeng_real l; };
@@ -56,4 +58,5 @@ uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out);
 void mixeng_clear (struct st_sample *buf, int len);
 void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol);
 
+#endif
 #endif /* QEMU_MIXENG_H */
diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h
index f1319c9002..5774967c0e 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,5 @@ 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..1788a54877 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/ui/dbus.c b/ui/dbus.c
index 99dac3e7fe..6086efd017 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -35,7 +35,6 @@
 #include "ui/egl-context.h"
 #endif
 #include "qemu/audio.h"
-#include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of drv->name */
 #include "qapi/error.h"
 #include "trace.h"
 
diff --git a/ui/vnc.c b/ui/vnc.c
index 0ee5502d1e..7004c875a1 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1103,7 +1103,13 @@ static void vnc_update_throttle_offset(VncState *vs)
     if (vs->throttle_output_offset != offset) {
         trace_vnc_client_throttle_threshold(
             vs, vs->ioc, vs->throttle_output_offset, offset, vs->client_width,
-            vs->client_height, vs->client_pf.bytes_per_pixel, vs->audio_cap);
+            vs->client_height, vs->client_pf.bytes_per_pixel,
+#ifdef CONFIG_AUDIO
+            vs->audio_cap
+#else
+            NULL
+#endif
+            );
     }
 
     vs->throttle_output_offset = offset;



  reply	other threads:[~2026-03-19  8:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-15 20:16 [PATCH v3 00/11] add build option to disable audio subsystem Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 01/11] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 02/11] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
2026-04-01 10:07   ` Philippe Mathieu-Daudé
2026-04-01 21:54     ` Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 03/11] tests/qtest: remove -audio none " Sergei Heifetz
2026-04-01 10:08   ` Philippe Mathieu-Daudé
2026-03-15 20:16 ` [PATCH v3 04/11] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 05/11] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 06/11] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 07/11] ui/dbus: run without Audio interface " Sergei Heifetz
2026-03-19  7:58   ` Markus Armbruster
2026-04-01  4:16     ` Sergei Heifetz
2026-04-01 10:43       ` Markus Armbruster
2026-04-01 21:06         ` Sergei Heifetz
2026-04-01 10:57     ` Daniel P. Berrangé
2026-03-15 20:16 ` [PATCH v3 08/11] tests/audio: do not compile if " Sergei Heifetz
2026-04-01 10:10   ` Philippe Mathieu-Daudé
2026-04-01 21:02     ` Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 09/11] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
2026-03-19  8:36   ` Markus Armbruster [this message]
2026-04-01  4:20     ` Sergei Heifetz
2026-04-01  8:11       ` Markus Armbruster
2026-03-15 20:16 ` [PATCH v3 10/11] qom: remove audiodevs root container if audio is disabled Sergei Heifetz
2026-03-15 20:16 ` [PATCH v3 11/11] meson.build: ignore audio drivers when configured with --disable-audio Sergei Heifetz
2026-04-01 10:10   ` Philippe Mathieu-Daudé
2026-04-01 10:13     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fr5wcj14.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=heifetz@yandex-team.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.