On 2/17/26 14:14, Thomas Huth wrote:
On 17/02/2026 06.27, Sergei Heifetz wrote:
PCSPK (PC Speaker) is an embedded audio device. We don't want it to
use audio
when QEMU is configured with `--disable-audio`. This is achieved with
minimal,
non-invasive changes to the code.
In essence, the changes ensure that PCSPK does not use the corresponding
audio backend, while functioning the same way in non-audio aspects.
Signed-off-by: Sergei Heifetz <[email protected]>
---
hw/audio/pcspk.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 916c56fa4c..03fe816024 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -36,10 +36,12 @@
#include "qom/object.h"
#include "trace.h"
+#ifdef CONFIG_AUDIO
#define PCSPK_BUF_LEN 1792
#define PCSPK_SAMPLE_RATE 32000
#define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
#define PCSPK_MIN_COUNT DIV_ROUND_UP(PIT_FREQ, PCSPK_MAX_FREQ)
+#endif
OBJECT_DECLARE_SIMPLE_TYPE(PCSpkState, PC_SPEAKER)
@@ -48,18 +50,25 @@ struct PCSpkState {
MemoryRegion ioport;
uint32_t iobase;
+#ifdef CONFIG_AUDIO
uint8_t sample_buf[PCSPK_BUF_LEN];
+#endif
AudioBackend *audio_be;
+#ifdef CONFIG_AUDIO
SWVoiceOut *voice;
+#endif
PITCommonState *pit;
+#ifdef CONFIG_AUDIO
unsigned int pit_count;
unsigned int samples;
unsigned int play_pos;
+#endif
Could you maybe group the fields that should get disabled together in
one #ifdef here? ... AFAIK the order of the fields should not matter,
so it should be ok to move them together.
Thomas
Yes, I agree — I don’t see any reason why the order would matter here. I
just wanted to be extra careful. I’ll change it.
Thanks for reviewing.