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]> --- audio/audio-stub.c | 22 ++++++++++++++++++++++ audio/meson.build | 5 +++++ hmp-commands-info.hx | 2 ++ hmp-commands.hx | 2 ++ hw/core/qdev-properties-system.c | 2 ++ qapi/audio.json | 3 ++- replay/meson.build | 9 ++++++++- replay/replay-audio-stub.c | 21 +++++++++++++++++++++ replay/stubs-system.c | 12 ------------ 9 files changed, 64 insertions(+), 14 deletions(-) create mode 100644 audio/audio-stub.c create mode 100644 replay/replay-audio-stub.c diff --git a/audio/audio-stub.c b/audio/audio-stub.c new file mode 100644 index 0000000000..f58f88cd83 --- /dev/null +++ b/audio/audio-stub.c @@ -0,0 +1,22 @@ +/* + * 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/audio/meson.build b/audio/meson.build index 0e33b6f983..19d43dc315 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -1,4 +1,9 @@ audio_ss = ss.source_set() +if not have_audio + audio_ss.add(files('audio-stub.c')) + subdir_done() +endif + audio_ss.add(files( 'audio.c', 'audio-be.c', diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 74c741f80e..a959479024 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -364,6 +364,7 @@ SRST ERST /* BEGIN deprecated */ +#ifdef CONFIG_AUDIO { .name = "capture", .args_type = "", @@ -376,6 +377,7 @@ SRST ``info capture`` Show capture information (deprecated). ERST +#endif /* END deprecated */ { diff --git a/hmp-commands.hx b/hmp-commands.hx index 5cc4788f12..e8b8175bb9 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -765,6 +765,7 @@ SRST ERST /* BEGIN deprecated */ +#ifdef CONFIG_AUDIO { .name = "wavcapture", .args_type = "path:F,audiodev:s,freq:i?,bits:i?,nchannels:i?", @@ -802,6 +803,7 @@ SRST Deprecated. ERST +#endif /* END deprecated */ { diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index a402321f42..8679a71b53 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -483,6 +483,7 @@ const PropertyInfo qdev_prop_netdev = { }; +#ifdef CONFIG_AUDIO /* --- audiodev --- */ static void get_audiodev(Object *obj, Visitor *v, const char* name, void *opaque, Error **errp) @@ -519,6 +520,7 @@ const PropertyInfo qdev_prop_audiodev = { .get = get_audiodev, .set = set_audiodev, }; +#endif bool qdev_prop_set_drive_err(DeviceState *dev, const char *name, BlockBackend *value, Error **errp) diff --git a/qapi/audio.json b/qapi/audio.json index 2df87b9710..28fda7c8ac 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' } diff --git a/replay/meson.build b/replay/meson.build index 4b4175e8dd..dc2e94e897 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 0000000000..b3da8e1558 --- /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) +{ +} diff --git a/replay/stubs-system.c b/replay/stubs-system.c index b2c52bc404..454415ae8e 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) { } -- 2.34.1
