Audio clean-ups
Subsystems (2)
cover Audio clean-ups
From: Marc-André Lureau <[email protected]>
Hi,
This is part of continuous and overdue clean up / modernization effort for the audio subsystem. (there is more in the pipeline)
thanks
Marc-André Lureau (43):
hw/audio: improve error reports
hw/audio: rename model list function
hw/audio: remove global pcspk
hw/pcspk: use explicitly the required PIT types hw/pcspk: make 'pit' a class property
hw/pcspk: check the "pit" is set
docs: update -soundhw -> -device list
qdev: add qdev_find_default_bus()
hw/audio: look up the default bus from the device class
audio: rename audio_define->audio_add_audiodev() hw/audio: use better naming for -audio model handling code hw/audio/virtio-snd-pci: remove custom model callback hw/audio: simplify 'hda' audio init code
hw/audio: generalize audio_model.init()
hw/audio: drop audio_model.isa
audio: start making AudioState a QOM Object
audio: register backends in /audiodevs container
audio: use /audiodevs qom container
audio/paaudio: remove needless return value audio/dsound: simplify init()
audio/dsound: report init error via **errp
audio: simplify audio_driver_init()
audio: move period tick initialization
audio: drop needless error message
audio: clean-up vmstate change handler on finalize
audio: unregister vmstate description
audio: initialize card_head during object init
audio: remove some needless headers
audio: remove AUDIO_HOST_ENDIANNESS
audio: introduce AUD_set_volume_{in,out}_lr() hw/audio: replace AUD_log() usage
audio/replay: fix type punning
audio: move internal APIs to audio_int.h
audio: rename AudioState -> AudioBE
audio: rename QEMUSoundCard -> AudioFE
audio: rename audio_get_id()
audio/dbus: use a helper function to set the backend dbus server
audio: move audio.h under include/qemu/
audio: remove dependency on spice header
audio: cleanup, use bool for booleans
audio: drop needless list of FE
audio: move capture API to own header
audio: drop needless audio_driver "descr" field
docs/qdev-device-use.txt | 6 +-
audio/audio_int.h | 64 ++--
audio/audio_template.h | 30 +-
audio/mixeng.h | 1 -
hw/audio/lm4549.h | 4 +-
include/hw/audio/asc.h | 4 +-
include/hw/audio/model.h | 13 +
include/hw/audio/soundhw.h | 13 -
include/hw/audio/virtio-snd.h | 4 +-
include/hw/display/xlnx_dp.h | 4 +-
include/hw/isa/vt82c686.h | 4 +-
include/hw/qdev-properties-system.h | 2 +-
include/hw/timer/i8254.h | 4 +-
include/monitor/qdev.h | 3 +
include/qemu/audio-capture.h | 43 +++
{audio => include/qemu}/audio.h | 125 +++-----
include/system/replay.h | 3 +-
ui/vnc.h | 4 +-
audio/alsaaudio.c | 5 +-
audio/audio-hmp-cmds.c | 4 +-
audio/audio.c | 303 +++++++++---------
audio/audio_win_int.c | 2 +-
audio/dbusaudio.c | 17 +-
audio/dsoundaudio.c | 213 ++++++------
audio/jackaudio.c | 3 +-
audio/mixeng.c | 12 +-
audio/noaudio.c | 5 +-
audio/ossaudio.c | 7 +-
audio/paaudio.c | 16 +-
audio/pwaudio.c | 3 +-
audio/sdlaudio.c | 3 +-
audio/sndioaudio.c | 3 +-
audio/spiceaudio.c | 7 +-
audio/wavaudio.c | 6 +-
audio/wavcapture.c | 5 +-
hw/arm/integratorcp.c | 2 +-
hw/arm/musicpal.c | 2 +-
hw/arm/realview.c | 2 +-
hw/arm/versatilepb.c | 2 +-
hw/arm/vexpress.c | 2 +-
hw/arm/xlnx-zcu102.c | 2 +-
hw/audio/ac97.c | 137 ++++----
hw/audio/adlib.c | 34 +-
hw/audio/asc.c | 12 +-
hw/audio/cs4231a.c | 52 ++-
hw/audio/es1370.c | 37 ++-
hw/audio/gus.c | 35 +-
hw/audio/hda-codec.c | 12 +-
hw/audio/intel-hda.c | 20 +-
hw/audio/lm4549.c | 6 +-
hw/audio/marvell_88w8618.c | 2 +-
hw/audio/model.c | 121 +++++++
hw/audio/pcspk.c | 27 +-
hw/audio/sb16.c | 104 +++---
hw/audio/soundhw.c | 143 ---------
hw/audio/via-ac97.c | 6 +-
hw/audio/virtio-snd-pci.c | 18 +-
hw/audio/virtio-snd.c | 8 +-
hw/audio/wm8750.c | 20 +-
hw/core/machine.c | 4 +-
hw/core/qdev-properties-system.c | 14 +-
hw/display/xlnx_dp.c | 4 +-
hw/ppc/prep.c | 2 +-
hw/timer/i8254_common.c | 6 +-
hw/usb/dev-audio.c | 12 +-
qom/object.c | 1 +
replay/replay-audio.c | 4 +-
replay/stubs-system.c | 2 +-
system/qdev-monitor.c | 21 +-
system/runstate.c | 2 +-
system/vl.c | 16 +-
ui/dbus.c | 13 +-
ui/vnc.c | 10 +-
audio/coreaudio.m | 3 +-
audio/meson.build | 2 +-
hw/audio/meson.build | 2 +-
.../codeconverter/test_regexps.py | 4 +-
77 files changed, 903 insertions(+), 970 deletions(-)
create mode 100644 include/hw/audio/model.h
delete mode 100644 include/hw/audio/soundhw.h
create mode 100644 include/qemu/audio-capture.h
rename {audio => include/qemu}/audio.h (50%)
create mode 100644 hw/audio/model.c
delete mode 100644 hw/audio/soundhw.cSignature · 1 line
2.51.0
PATCH 1/43 hw/audio: improve error reports
From: Marc-André Lureau <[email protected]>
The -audiodev argument is 'model=..', use same terminology.
--- hw/audio/soundhw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/audio/soundhw.c +3 -4
@@ -70,7 +70,7 @@ void show_valid_soundhw(void)struct soundhw *c;if (soundhw_count) { -printf ("Valid sound card names (comma separated):\n" ); +printf ("Valid audio device model names:\n" );for (c = soundhw; c->name; ++c) {printf ("%-11s %s\n" , c->name, c->descr); }
@@ -88,7 +88,7 @@ void select_soundhw(const char *name, const char *audiodev)struct soundhw *c;if (selected) { -error_report ("only one -soundhw option is allowed" ); +error_report ("only one -audio option is allowed" );exit (1 ); }
@@ -101,7 +101,7 @@ void select_soundhw(const char *name, const char *audiodev) }if (!c->name) { -error_report ("Unknown sound card name `%s'" , name); +error_report ("Unknown audio device model `%s'" , name);show_valid_soundhw ();exit (1 ); }
@@ -140,4 +140,3 @@ void soundhw_init(void) c->init_pci (pci_bus, audiodev_id); } } -
Signature · 1 line
2.51.0
Re: [PATCH 01/43] hw/audio: improve error reports
Quoted 8 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The -audiodev argument is 'model=..', use same terminology.
Signed-off-by Marc-André Lureau <[email protected]>--- hw/audio/soundhw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
PATCH 2/43 hw/audio: rename model list function
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- include/hw/audio/soundhw.h | 2 +- hw/audio/soundhw.c | 4 ++-- system/vl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
include/hw/audio/soundhw.h +1 -1
@@ -7,7 +7,7 @@ void deprecated_register_soundhw(const char *name, const char *descr, int isa, const char *typename);void soundhw_init (void ); -void show_valid_soundhw (void ); +void audio_print_available_models (void );void select_soundhw (const char *name,const char *audiodev);#endif
hw/audio/soundhw.c +2 -2
@@ -65,7 +65,7 @@ void deprecated_register_soundhw(const char *name, const char *descr, soundhw_count++; } -void show_valid_soundhw (void ) +void audio_print_available_models (void ) {struct soundhw *c;
@@ -102,7 +102,7 @@ void select_soundhw(const char *name, const char *audiodev)if (!c->name) {error_report ("Unknown audio device model `%s'" , name); -show_valid_soundhw (); +audio_print_available_models ();exit (1 ); } }
system/vl.c +1 -1
@@ -3077,7 +3077,7 @@ void qemu_init(int argc, char **argv) model =g_strdup (qdict_get_str (dict,"model" ));qdict_del (dict,"model" );if (is_help_option (model)) { -show_valid_soundhw (); +audio_print_available_models ();exit (0 ); } }
Signature · 1 line
2.51.0
Re: [PATCH 02/43] hw/audio: rename model list function
Quoted 8 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- include/hw/audio/soundhw.h | 2 +- hw/audio/soundhw.c | 4 ++-- system/vl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
PATCH 3/43 hw/audio: remove global pcspk
In reply to [email protected]From: Marc-André Lureau <[email protected]>
It is no longer used since commit 6033b9ecd4 ("pc: remove -soundhw pcspk")
--- hw/audio/pcspk.c | 4 ---- 1 file changed, 4 deletions(-)
hw/audio/pcspk.c +0 -4
@@ -60,7 +60,6 @@ struct PCSpkState { };static const char *s_spk ="pcspk" ; -static PCSpkState *pcspk_state;static inline void generate_samples (PCSpkState *s) {
@@ -192,8 +191,6 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)if (s->card.state &&AUD_register_card (s_spk, &s->card, errp)) {pcspk_audio_init (s); } - - pcspk_state = s; }static bool migrate_needed (void *opaque)
@@ -229,7 +226,6 @@ static void pcspk_class_initfn(ObjectClass *klass, const void *data)set_bit (DEVICE_CATEGORY_SOUND , dc->categories); dc->vmsd = &vmstate_spk;device_class_set_props (dc, pcspk_properties); -/* Reason: realize sets global pcspk_state */ /* Reason: pit object link */ dc->user_creatable = false; }
Signature · 1 line
2.51.0
Re: [PATCH 03/43] hw/audio: remove global pcspk
Quoted 8 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
It is no longer used since commit
6033b9ecd4("pc: remove -soundhw pcspk")Signed-off-by Marc-André Lureau <[email protected]>--- hw/audio/pcspk.c | 4 ---- 1 file changed, 4 deletions(-)
PATCH 4/43 hw/pcspk: use explicitly the required PIT types
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- include/hw/timer/i8254.h | 4 ++-- hw/audio/pcspk.c | 2 +- hw/timer/i8254_common.c | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-)
include/hw/timer/i8254.h +2 -2
@@ -75,7 +75,7 @@ static inline ISADevice *kvm_pit_init(ISABus *bus, int base) return d; } -void pit_set_gate (ISADevice *dev,int channel,int val); -void pit_get_channel_info (ISADevice *dev,int channel,PITChannelInfo *info); +void pit_set_gate (PITCommonState *pit,int channel,int val); +void pit_get_channel_info (PITCommonState *pit,int channel,PITChannelInfo *info);#endif /* HW_I8254_H */
hw/audio/pcspk.c +1 -1
@@ -50,7 +50,7 @@ struct PCSpkState {uint8_t sample_buf[PCSPK_BUF_LEN ];QEMUSoundCard card;SWVoiceOut *voice; -void *pit; +PITCommonState *pit;unsigned int pit_count;unsigned int samples;unsigned int play_pos;
hw/timer/i8254_common.c +2 -4
@@ -32,9 +32,8 @@#include "migration/vmstate.h" /* val must be 0 or 1 */ -void pit_set_gate (ISADevice *dev,int channel,int val) +void pit_set_gate (PITCommonState *pit,int channel,int val) { -PITCommonState *pit =PIT_COMMON (dev);PITChannelState *s = &pit->channels[channel];PITCommonClass *c =PIT_COMMON_GET_CLASS (pit);
@@ -139,9 +138,8 @@ void pit_get_channel_info_common(PITCommonState *s, PITChannelState *sc, info->out =pit_get_out (sc,qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL )); } -void pit_get_channel_info (ISADevice *dev,int channel,PITChannelInfo *info) +void pit_get_channel_info (PITCommonState *pit,int channel,PITChannelInfo *info) { -PITCommonState *pit =PIT_COMMON (dev);PITChannelState *s = &pit->channels[channel];PITCommonClass *c =PIT_COMMON_GET_CLASS (pit);
Signature · 1 line
2.51.0
Re: [PATCH 04/43] hw/pcspk: use explicitly the required PIT types
Quoted 8 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- include/hw/timer/i8254.h | 4 ++-- hw/audio/pcspk.c | 2 +- hw/timer/i8254_common.c | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-)
PATCH 5/43 hw/pcspk: make 'pit' a class property
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This should be functionally equivalent. (for some reason, the device property was convert to an object instance property in commit 873b4d3f0571)
--- hw/audio/pcspk.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
hw/audio/pcspk.c +1 -5
@@ -174,11 +174,6 @@ static void pcspk_initfn(Object *obj)PCSpkState *s =PC_SPEAKER (obj);memory_region_init_io (&s->ioport,OBJECT (s), &pcspk_io_ops, s,"pcspk" ,1 ); - -object_property_add_link (obj,"pit" ,TYPE_PIT_COMMON , - (Object **)&s->pit, - qdev_prop_allow_set_link_before_realize, -0 ); }static void pcspk_realizefn (DeviceState *dev,Error **errp)
@@ -216,6 +211,7 @@ static const Property pcspk_properties[] = {DEFINE_AUDIO_PROPERTIES (PCSpkState, card),DEFINE_PROP_UINT32 ("iobase" , PCSpkState, iobase,0x61 ),DEFINE_PROP_BOOL ("migrate" , PCSpkState, migrate, true), + DEFINE_PROP_LINK("pit", PCSpkState, pit, TYPE_PIT_COMMON, PITCommonState *), };static void pcspk_class_initfn (ObjectClass *klass,const void *data)
Signature · 1 line
2.51.0
Re: [PATCH 05/43] hw/pcspk: make 'pit' a class property
Quoted 4 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This should be functionally equivalent. (for some reason, the device property was convert to an object instance property in commit
873b4d3f0571)
This commit is from 2016; DEFINE_PROP_LINK() was added in 2017, in commit 5b4ff3c6613.
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- hw/audio/pcspk.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
PATCH 6/43 hw/pcspk: check the "pit" is set
In reply to [email protected]From: Marc-André Lureau <[email protected]>
We don't let the user create a "isa-pcspk" via -device yet (in theory, we could, and fallback on a lookup PIT), but we can add some safety checks that the property was correctly set nonetheless.
--- hw/audio/pcspk.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/audio/pcspk.c +5 -0
@@ -181,6 +181,11 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)ISADevice *isadev =ISA_DEVICE (dev);PCSpkState *s =PC_SPEAKER (dev); +if (!s->pit) { +error_setg (errp,"pcspk: No \"pit\" set or available" ); +return ; + } +isa_register_ioport (isadev, &s->ioport, s->iobase);if (s->card.state &&AUD_register_card (s_spk, &s->card, errp)) {
Signature · 1 line
2.51.0
Re: [PATCH 06/43] hw/pcspk: check the "pit" is set
Quoted 10 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
We don't let the user create a "isa-pcspk" via -device yet (in theory, we could, and fallback on a lookup PIT), but we can add some safety checks that the property was correctly set nonetheless.
Signed-off-by Marc-André Lureau <[email protected]>--- hw/audio/pcspk.c | 5 +++++ 1 file changed, 5 insertions(+)
PATCH 7/43 docs: update -soundhw -> -device list
In reply to [email protected]From: Marc-André Lureau <[email protected]>
(note: I wonder if pcspk was really an option when -soundhw was available, since it was not user-creatable)
--- docs/qdev-device-use.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
docs/qdev-device-use.txt +4 -2
@@ -324,8 +324,10 @@ Map from -soundhw sound card name to -device: gus -device gus,iobase=IOADDR,irq=IRQ,dma=DMA,freq=F hda -device intel-hda,msi=MSI -device hda-duplex sb16 -device sb16,iobase=IOADDR,irq=IRQ,dma=DMA,dma16=DMA16,version=V - adlib not yet available with -device - pcspk not yet available with -device + adlib -device adlib,iobase=IOADDR,freq=F + + pcspk Not available with -device, + but audiodev can be set with -machine pcspk-audiodev=<name> For PCI devices, you can add bus=PCI-BUS,addr=DEVFN to control the PCI device address, as usual.
Signature · 1 line
2.51.0
Re: [PATCH 07/43] docs: update -soundhw -> -device list
Quoted 4 lines · On 21/10/2025 11.02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
(note: I wonder if pcspk was really an option when -soundhw was available, since it was not user-creatable)
Running an old version of QEMU:
$ i386-softmmu/qemu-system-i386 -soundhw help Valid sound card names (comma separated): sb16 Creative Sound Blaster 16 es1370 ENSONIQ AudioPCI ES1370 ac97 Intel 82801AA AC97 Audio adlib Yamaha YM3812 (OPL2) gus Gravis Ultrasound GF1 cs4231a CS4231A hda Intel HD Audio pcspk PC speaker
... it seems like it was at least selectable there (no clue whether it worked as expected, though).
Quoted 12 lines
Signed-off-by Marc-André Lureau <[email protected]>--- docs/qdev-device-use.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)docs/qdev-device-use.txt +0
-0@@ -324,8 +324,10 @@ Map from -soundhw sound card name to -device: gus -device gus,iobase=IOADDR,irq=IRQ,dma=DMA,freq=F hda -device intel-hda,msi=MSI -device hda-duplex
docs/qdev-device-use.txt Map from -soundhw sound card name to -device: · line 333
Quoted 10 lines
docs/qdev-device-use.txt +4
-2sb16 -device sb16,iobase=IOADDR,irq=IRQ,dma=DMA,dma16=DMA16,version=V - adlib not yet available with -device - pcspk not yet available with -device + adlib -device adlib,iobase=IOADDR,freq=F + + pcspk Not available with -device, + but audiodev can be set with -machine pcspk-audiodev=<name> For PCI devices, you can add bus=PCI-BUS,addr=DEVFN to control the PCI device address, as usual.
PATCH 8/43 qdev: add qdev_find_default_bus()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This helper is used next by -audio code.
--- include/monitor/qdev.h | 3 +++ system/qdev-monitor.c | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-)
include/monitor/qdev.h +3 -0
@@ -1,6 +1,8 @@#ifndef MONITOR_QDEV_H #define MONITOR_QDEV_H +#include "hw/qdev-core.h" +/*** monitor commands ***/ void hmp_info_qtree (Monitor *mon,const QDict *qdict);
@@ -11,6 +13,7 @@ int qdev_device_help(QemuOpts *opts);DeviceState *qdev_device_add (QemuOpts *opts,Error **errp);DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp); +BusState *qdev_find_default_bus (DeviceClass *dc,Error **errp);/** * qdev_set_id: parent the device and set its id if provided.
system/qdev-monitor.c +17 -4
@@ -621,6 +621,21 @@ const char *qdev_set_id(DeviceState *dev, char *id, Error **errp)return prop->name; } +BusState *qdev_find_default_bus (DeviceClass *dc,Error **errp) +{ +BusState *bus =NULL ; + +assert (dc->bus_type !=NULL ); + bus =qbus_find_recursive (sysbus_get_default (),NULL , dc->bus_type); +if (!bus ||qbus_is_full (bus)) { +error_setg (errp,"No '%s' bus found for device '%s'" , + dc->bus_type,object_class_get_name (OBJECT_CLASS (dc))); +return NULL ; + } + +return bus; +} +DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp) {
@@ -657,10 +672,8 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,return NULL ; } }else if (dc->bus_type !=NULL ) { - bus =qbus_find_recursive (sysbus_get_default (),NULL , dc->bus_type); -if (!bus ||qbus_is_full (bus)) { -error_setg (errp,"No '%s' bus found for device '%s'" , - dc->bus_type, driver); + bus =qdev_find_default_bus (dc, errp); +if (!bus) {return NULL ; } }
Signature · 1 line
2.51.0
Re: [PATCH 08/43] qdev: add qdev_find_default_bus()
Quoted 39 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This helper is used next by -audio code.
Signed-off-by Marc-André Lureau <[email protected]>---
include/monitor/qdev.h| 3 +++system/qdev-monitor.c| 21 +++++++++++++++++----2 files changed, 20 insertions(+), 4 deletions(-)include/monitor/qdev.h +3
-0@@ -1,6 +1,8 @@#ifndef MONITOR_QDEV_H #define MONITOR_QDEV_H +#include "hw/qdev-core.h" +/*** monitor commands ***/ void hmp_info_qtree (Monitor *mon,const QDict *qdict);@@ -11,6 +13,7 @@ int qdev_device_help(QemuOpts *opts);DeviceState *qdev_device_add (QemuOpts *opts,Error **errp);DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp); +BusState *qdev_find_default_bus (DeviceClass *dc,Error **errp);/** * qdev_set_id: parent the device and set its id if provided. system/qdev-monitor.c +0
-0@@ -621,6 +621,21 @@ const char *qdev_set_id(DeviceState *dev, char *id, Error **errp)return prop->name; }
system/qdev-monitor.c const char *qdev_set_id(DeviceState *dev, char *id, Error **errp) · line 633
Quoted 10 lines
system/qdev-monitor.c +10
-0+BusState *qdev_find_default_bus (DeviceClass *dc,Error **errp) +{ +BusState *bus =NULL ; + +assert (dc->bus_type !=NULL ); + bus =qbus_find_recursive (sysbus_get_default (),NULL , dc->bus_type); +if (!bus ||qbus_is_full (bus)) { +error_setg (errp,"No '%s' bus found for device '%s'" , + dc->bus_type,object_class_get_name (OBJECT_CLASS (dc))); +return NULL ;
Should it differrentiate between no bus and a bus that exists but full and return different error to help debugging?
Regards,
BALATON Zoltan
Quoted 22 lines
system/qdev-monitor.c +7
-4+ } + +return bus; +} +DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp) {@@ -657,10 +672,8 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,return NULL ; } }else if (dc->bus_type !=NULL ) { - bus =qbus_find_recursive (sysbus_get_default (),NULL , dc->bus_type); -if (!bus ||qbus_is_full (bus)) { -error_setg (errp,"No '%s' bus found for device '%s'" , - dc->bus_type, driver); + bus =qdev_find_default_bus (dc, errp); +if (!bus) {return NULL ; } }
Re: [PATCH 08/43] qdev: add qdev_find_default_bus()
Hi
Quoted 41 lines · BALATON Zoltan
Quoted 39 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This helper is used next by -audio code.
Signed-off-by Marc-André Lureau <[email protected]>---
include/monitor/qdev.h| 3 +++system/qdev-monitor.c| 21 +++++++++++++++++----2 files changed, 20 insertions(+), 4 deletions(-)include/monitor/qdev.h +3
-0@@ -1,6 +1,8 @@#ifndef MONITOR_QDEV_H #define MONITOR_QDEV_H +#include "hw/qdev-core.h" +/*** monitor commands ***/ void hmp_info_qtree (Monitor *mon,const QDict *qdict);@@ -11,6 +13,7 @@ int qdev_device_help(QemuOpts *opts);DeviceState *qdev_device_add (QemuOpts *opts,Error **errp);DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp); +BusState *qdev_find_default_bus (DeviceClass *dc,Error **errp);/** * qdev_set_id: parent the device and set its id if provided. system/qdev-monitor.c +0
-0@@ -621,6 +621,21 @@ const char *qdev_set_id(DeviceState *dev, char *id, Error **errp)return prop->name; }
Quoted 14 lines
system/qdev-monitor.c const char *qdev_set_id(DeviceState *dev, char *id, Error **errp) · line 633
Quoted 10 lines
system/qdev-monitor.c +10
-0+BusState *qdev_find_default_bus (DeviceClass *dc,Error **errp) +{ +BusState *bus =NULL ; + +assert (dc->bus_type !=NULL ); + bus =qbus_find_recursive (sysbus_get_default (),NULL , dc->bus_type); +if (!bus ||qbus_is_full (bus)) { +error_setg (errp,"No '%s' bus found for device '%s'" , + dc->bus_type,object_class_get_name (OBJECT_CLASS (dc))); +return NULL ;Should it differrentiate between no bus and a bus that exists but full and return different error to help debugging?
qdev_device_add_from_qdict() doesn't distinguish it either, but it could be useful indeed. I will report a different error.
Quoted 25 lines
Regards,
BALATON ZoltanQuoted 22 lines
system/qdev-monitor.c +7
-4+ } + +return bus; +} +DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp) {@@ -657,10 +672,8 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,return NULL ; } }else if (dc->bus_type !=NULL ) { - bus =qbus_find_recursive (sysbus_get_default (),NULL , dc->bus_type); -if (!bus ||qbus_is_full (bus)) { -error_setg (errp,"No '%s' bus found for device '%s'" , - dc->bus_type, driver); + bus =qdev_find_default_bus (dc, errp); +if (!bus) {return NULL ; } }
Signature · 1 line
Marc-André Lureau
PATCH 9/43 hw/audio: look up the default bus from the device class
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Generalize and simplify the device model creation.
--- hw/audio/soundhw.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
hw/audio/soundhw.c +4 -16
@@ -22,6 +22,8 @@* THE SOFTWARE. */ #include "qemu/osdep.h" +#include "hw/qdev-core.h" +#include "monitor/qdev.h" #include "qemu/option.h" #include "qemu/help_option.h" #include "qemu/error-report.h"
@@ -110,33 +112,19 @@ void select_soundhw(const char *name, const char *audiodev)void soundhw_init (void ) {struct soundhw *c = selected; -ISABus *isa_bus = (ISABus *)object_resolve_path_type ("" ,TYPE_ISA_BUS ,NULL ); -PCIBus *pci_bus = (PCIBus *)object_resolve_path_type ("" ,TYPE_PCI_BUS ,NULL ); -BusState *bus;if (!c) {return ; } -if (c->isa) { -if (!isa_bus) { -error_report ("ISA bus not available for %s" , c->name); -exit (1 ); - } - bus =BUS (isa_bus); - }else { -if (!pci_bus) { -error_report ("PCI bus not available for %s" , c->name); -exit (1 ); - } - bus =BUS (pci_bus); - }if (c->typename) {DeviceState *dev =qdev_new (c->typename); +BusState *bus =qdev_find_default_bus (DEVICE_GET_CLASS (dev), &error_fatal);qdev_prop_set_string (dev,"audiodev" , audiodev_id);qdev_realize_and_unref (dev, bus, &error_fatal); }else {assert (!c->isa); +PCIBus *pci_bus = (PCIBus *)object_resolve_path_type ("" ,TYPE_PCI_BUS ,NULL ); c->init_pci (pci_bus, audiodev_id); } }
Signature · 1 line
2.51.0
PATCH 10/43 audio: rename audio_define->audio_add_audiodev()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
For readability.
--- audio/audio.h | 4 ++-- audio/audio.c | 8 ++++---- system/vl.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
audio/audio.h +2 -2
@@ -168,8 +168,8 @@ void audio_sample_to_uint64(const void *samples, int pos,void audio_sample_from_uint64 (void *samples,int pos,uint64_t left,uint64_t right); -void audio_define (Audiodev *audio); -void audio_define_default (Audiodev *dev,Error **errp); +void audio_add_audiodev (Audiodev *audio); +void audio_add_default_audiodev (Audiodev *dev,Error **errp);void audio_parse_option (const char *opt);void audio_create_default_audiodevs (void );void audio_init_audiodevs (void );
audio/audio.c +4 -4
@@ -1712,7 +1712,7 @@ void audio_create_default_audiodevs(void)visit_type_Audiodev (v,NULL , &dev, &error_fatal);visit_free (v); -audio_define_default (dev, &error_abort); +audio_add_default_audiodev (dev, &error_abort); } } }
@@ -2142,10 +2142,10 @@ void audio_parse_option(const char *opt)visit_type_Audiodev (v,NULL , &dev, &error_fatal);visit_free (v); -audio_define (dev); +audio_add_audiodev (dev); } -void audio_define (Audiodev *dev) +void audio_add_audiodev (Audiodev *dev) {AudiodevListEntry *e;
@@ -2156,7 +2156,7 @@ void audio_define(Audiodev *dev)QSIMPLEQ_INSERT_TAIL (&audiodevs, e, next); } -void audio_define_default (Audiodev *dev,Error **errp) +void audio_add_default_audiodev (Audiodev *dev,Error **errp) {AudiodevListEntry *e;
system/vl.c +3 -3
@@ -2264,7 +2264,7 @@ static void qemu_record_config_group(const char *group, QDict *dict,Audiodev *dev =NULL ;Visitor *v =qobject_input_visitor_new_keyval (QOBJECT (dict));if (visit_type_Audiodev (v,NULL , &dev, errp)) { -audio_define (dev); +audio_add_audiodev (dev); }visit_free (v);
@@ -3086,11 +3086,11 @@ void qemu_init(int argc, char **argv)visit_type_Audiodev (v,NULL , &dev, &error_fatal);visit_free (v);if (model) { -audio_define (dev); +audio_add_audiodev (dev);select_soundhw (model, dev->id);g_free (model); }else { -audio_define_default (dev, &error_fatal); +audio_add_default_audiodev (dev, &error_fatal); }break ; }
Signature · 1 line
2.51.0
Re: [PATCH 10/43] audio: rename audio_define->audio_add_audiodev()
Quoted 10 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
For readability.
Signed-off-by Marc-André Lureau <[email protected]>--- audio/audio.h | 4 ++-- audio/audio.c | 8 ++++---- system/vl.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
PATCH 11/43 hw/audio: use better naming for -audio model handling code
In reply to [email protected]From: Marc-André Lureau <[email protected]>
All the functions are about "-audio model=" handling, a simpler way to setup audio. Rename functions/variables to reflect this better.
audio_register_model_with_cb() dropped "pci" from the name, since it will be generalized next.
---
include/hw/audio/model.h | 13 +++++
include/hw/audio/soundhw.h | 13 -----
hw/audio/ac97.c | 5 +-
hw/audio/adlib.c | 4 +-
hw/audio/cs4231a.c | 4 +-
hw/audio/es1370.c | 5 +-
hw/audio/gus.c | 4 +-
hw/audio/intel-hda.c | 4 +-
hw/audio/{soundhw.c => model.c} | 58 +++++++++----------
hw/audio/pcspk.c | 2 +-
hw/audio/sb16.c | 5 +-
hw/audio/virtio-snd-pci.c | 4 +-
system/vl.c | 6 +-
hw/audio/meson.build | 2 +-
.../codeconverter/test_regexps.py | 2 +-
15 files changed, 64 insertions(+), 67 deletions(-)
create mode 100644 include/hw/audio/model.h
delete mode 100644 include/hw/audio/soundhw.h
rename hw/audio/{soundhw.c => model.c} (68%)include/hw/audio/model.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef HW_AUDIO_MODEL_H +#define HW_AUDIO_MODEL_H + +void audio_register_model_with_cb (const char *name,const char *descr, +int (*init_pci)(PCIBus *bus,const char *audiodev)); +void audio_register_model (const char *name,const char *descr, +int isa,const char *typename); + +void audio_model_init (void ); +void audio_print_available_models (void ); +void audio_set_model (const char *name,const char *audiodev); + +#endif
include/hw/audio/soundhw.h deleted +0 -13
@@ -1,13 +0,0 @@ -#ifndef HW_SOUNDHW_H -#define HW_SOUNDHW_H - -void pci_register_soundhw (const char *name,const char *descr, -int (*init_pci)(PCIBus *bus,const char *audiodev)); -void deprecated_register_soundhw (const char *name,const char *descr, -int isa,const char *typename); - -void soundhw_init (void ); -void audio_print_available_models (void ); -void select_soundhw (const char *name,const char *audiodev); - -#endif
hw/audio/ac97.c +2 -3
@@ -18,7 +18,7 @@*/ #include "qemu/osdep.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/pci/pci_device.h" #include "hw/qdev-properties.h"
@@ -1360,8 +1360,7 @@ static const TypeInfo ac97_info = {static void ac97_register_types (void ) {type_register_static (&ac97_info); -deprecated_register_soundhw ("ac97" ,"Intel 82801AA AC97 Audio" , -0 ,TYPE_AC97 ); +audio_register_model ("ac97" ,"Intel 82801AA AC97 Audio" ,0 ,TYPE_AC97 ); }type_init (ac97_register_types)
hw/audio/adlib.c +2 -2
@@ -25,7 +25,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h"
@@ -323,7 +323,7 @@ static const TypeInfo adlib_info = {static void adlib_register_types (void ) {type_register_static (&adlib_info); -deprecated_register_soundhw ("adlib" ,ADLIB_DESC ,1 ,TYPE_ADLIB ); +audio_register_model ("adlib" ,ADLIB_DESC ,1 ,TYPE_ADLIB ); }type_init (adlib_register_types)
hw/audio/cs4231a.c +2 -2
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/irq.h" #include "hw/isa/isa.h"
@@ -723,7 +723,7 @@ static const TypeInfo cs4231a_info = {static void cs4231a_register_types (void ) {type_register_static (&cs4231a_info); -deprecated_register_soundhw ("cs4231a" ,"CS4231A" ,1 ,TYPE_CS4231A ); +audio_register_model ("cs4231a" ,"CS4231A" ,1 ,TYPE_CS4231A ); }type_init (cs4231a_register_types)
hw/audio/es1370.c +2 -3
@@ -26,7 +26,7 @@#define VERBOSE_ES1370 0#include "qemu/osdep.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/pci/pci_device.h" #include "migration/vmstate.h"
@@ -905,8 +905,7 @@ static const TypeInfo es1370_info = {static void es1370_register_types (void ) {type_register_static (&es1370_info); -deprecated_register_soundhw ("es1370" ,"ENSONIQ AudioPCI ES1370" , -0 ,TYPE_ES1370 ); +audio_register_model ("es1370" ,"ENSONIQ AudioPCI ES1370" ,0 ,TYPE_ES1370 ); }type_init (es1370_register_types)
hw/audio/gus.c +2 -2
@@ -25,7 +25,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/irq.h" #include "hw/isa/isa.h"
@@ -319,7 +319,7 @@ static const TypeInfo gus_info = {static void gus_register_types (void ) {type_register_static (&gus_info); -deprecated_register_soundhw ("gus" ,"Gravis Ultrasound GF1" ,1 ,TYPE_GUS ); +audio_register_model ("gus" ,"Gravis Ultrasound GF1" ,1 ,TYPE_GUS ); }type_init (gus_register_types)
hw/audio/intel-hda.c +2 -2
@@ -26,7 +26,7 @@#include "qemu/log.h" #include "qemu/module.h" #include "qemu/error-report.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "intel-hda.h" #include "migration/vmstate.h" #include "intel-hda-defs.h"
@@ -1324,7 +1324,7 @@ static void intel_hda_register_types(void)type_register_static (&intel_hda_info_ich6);type_register_static (&intel_hda_info_ich9);type_register_static (&hda_codec_device_type_info); -pci_register_soundhw ("hda" ,"Intel HD Audio" , intel_hda_and_codec_init); +audio_register_model_with_cb ("hda" ,"Intel HD Audio" , intel_hda_and_codec_init); }type_init (intel_hda_register_types)
hw/audio/model.c renamed from hw/audio/soundhw.c +29 -29
104 lines not on this page · raw message
hw/audio/pcspk.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/osdep.h" #include "hw/isa/isa.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "qemu/module.h" #include "qemu/timer.h"
hw/audio/sb16.c +2 -3
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/irq.h" #include "hw/isa/isa.h"
@@ -1471,8 +1471,7 @@ static const TypeInfo sb16_info = {static void sb16_register_types (void ) {type_register_static (&sb16_info); -deprecated_register_soundhw ("sb16" ,"Creative Sound Blaster 16" , -1 ,TYPE_SB16 ); +audio_register_model ("sb16" ,"Creative Sound Blaster 16" ,1 ,TYPE_SB16 ); }type_init (sb16_register_types)
hw/audio/virtio-snd-pci.c +2 -2
@@ -11,7 +11,7 @@#include "qemu/osdep.h" #include "qom/object.h" #include "qapi/error.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "hw/virtio/virtio-pci.h" #include "hw/audio/virtio-snd.h"
@@ -88,7 +88,7 @@ static int virtio_snd_pci_init(PCIBus *bus, const char *audiodev)static void virtio_snd_pci_register (void ) {virtio_pci_types_register (&virtio_snd_pci_info); -pci_register_soundhw ("virtio" ,"Virtio Sound" , virtio_snd_pci_init); +audio_register_model_with_cb ("virtio" ,"Virtio Sound" , virtio_snd_pci_init); }type_init (virtio_snd_pci_register);
system/vl.c +3 -3
@@ -86,7 +86,7 @@#include "migration/snapshot.h" #include "system/tpm.h" #include "system/dma.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "system/cpus.h" #include "system/cpu-timers.h"
@@ -2731,7 +2731,7 @@ static void qemu_create_cli_devices(void) {DeviceOption *opt; -soundhw_init (); +audio_model_init ();qemu_opts_foreach (qemu_find_opts ("fw_cfg" ), parse_fw_cfg,fw_cfg_find (), &error_fatal);
@@ -3087,7 +3087,7 @@ void qemu_init(int argc, char **argv)visit_free (v);if (model) {audio_add_audiodev (dev); -select_soundhw (model, dev->id); +audio_set_model (model, dev->id);g_free (model); }else {audio_add_default_audiodev (dev, &error_fatal);
hw/audio/meson.build +1 -1
@@ -1,4 +1,4 @@ -system_ss.add(files('soundhw.c')) +system_ss.add(files('model.c')) system_ss.add(when: 'CONFIG_AC97', if_true: files('ac97.c')) system_ss.add(when: 'CONFIG_ADLIB', if_true: files('fmopl.c', 'adlib.c')) system_ss.add(when: 'CONFIG_ASC', if_true: files('asc.c'))
scripts/codeconverter/codeconverter/test_regexps.py +1 -1
@@ -264,7 +264,7 @@ def test_initial_includes(): #define SILENT_ES1370 #include "qemu/osdep.h" -#include "hw/audio/soundhw.h" +#include "hw/audio/model.h" #include "audio/audio.h" #include "hw/pci/pci.h" #include "migration/vmstate.h"
Signature · 1 line
2.51.0
PATCH 12/43 hw/audio/virtio-snd-pci: remove custom model callback
In reply to [email protected]From: Marc-André Lureau <[email protected]>
virtio-snd can rely on the default code to instantiate the device and set the audiodev.
--- hw/audio/virtio-snd-pci.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
hw/audio/virtio-snd-pci.c +1 -15
@@ -71,24 +71,10 @@ static const VirtioPCIDeviceTypeInfo virtio_snd_pci_info = { .class_init = virtio_snd_pci_class_init, }; -/* Create a Virtio Sound PCI device, so '-audio driver,model=virtio' works. */ -static int virtio_snd_pci_init (PCIBus *bus,const char *audiodev) -{ -DeviceState *vdev =NULL ; -VirtIOSoundPCI *dev =NULL ; - - vdev =qdev_new (TYPE_VIRTIO_SND_PCI ); -assert (vdev); - dev =VIRTIO_SND_PCI (vdev); -qdev_prop_set_string (DEVICE (&dev->vdev),"audiodev" , audiodev); -qdev_realize_and_unref (vdev,BUS (bus), &error_fatal); -return 0 ; -} -static void virtio_snd_pci_register (void ) {virtio_pci_types_register (&virtio_snd_pci_info); -audio_register_model_with_cb ("virtio" ,"Virtio Sound" , virtio_snd_pci_init); +audio_register_model ("virtio" ,"Virtio Sound" ,0 ,TYPE_VIRTIO_SND_PCI ); }type_init (virtio_snd_pci_register);
Signature · 1 line
2.51.0
PATCH 13/43 hw/audio: simplify 'hda' audio init code
In reply to [email protected]From: Marc-André Lureau <[email protected]>
For consistency, use only qdev_device_add() to instantiate the devices. We can't rely on automatic bus lookup for the "hda-duplex" device though as it may end up on a different "intel-hda" bus...
--- hw/audio/intel-hda.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
hw/audio/intel-hda.c +10 -4
@@ -21,6 +21,7 @@#include "hw/pci/pci.h" #include "hw/qdev-properties.h" #include "hw/pci/msi.h" +#include "monitor/qdev.h" #include "qemu/timer.h" #include "qemu/bitops.h" #include "qemu/log.h"
@@ -30,6 +31,7 @@#include "intel-hda.h" #include "migration/vmstate.h" #include "intel-hda-defs.h" +#include "qobject/qdict.h" #include "system/dma.h" #include "qapi/error.h" #include "qom/object.h"
@@ -1305,15 +1307,19 @@ static const TypeInfo hda_codec_device_type_info = {*/ static int intel_hda_and_codec_init (PCIBus *bus,const char *audiodev) { -DeviceState *controller; +g_autoptr (QDict) props =qdict_new (); +DeviceState *intel_hda, *codec;BusState *hdabus; -DeviceState *codec; - controller =DEVICE (pci_create_simple (bus,-1 ,"intel-hda" )); - hdabus =QLIST_FIRST (&controller->child_bus); +qdict_put_str (props,"driver" ,"intel-hda" ); + intel_hda =qdev_device_add_from_qdict (props, false, &error_fatal); + hdabus =QLIST_FIRST (&intel_hda->child_bus); + codec =qdev_new ("hda-duplex" );qdev_prop_set_string (codec,"audiodev" , audiodev);qdev_realize_and_unref (codec, hdabus, &error_fatal); +object_unref (intel_hda); +return 0 ; }
Signature · 1 line
2.51.0
PATCH 14/43 hw/audio: generalize audio_model.init()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
It is no longer PCI bus only.
--- include/hw/audio/model.h | 2 +- hw/audio/intel-hda.c | 2 +- hw/audio/model.c | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-)
include/hw/audio/model.h +1 -1
@@ -2,7 +2,7 @@#define HW_AUDIO_MODEL_H void audio_register_model_with_cb (const char *name,const char *descr, -int (*init_pci)(PCIBus *bus,const char *audiodev)); +int (*init_audio_model)(const char *audiodev));void audio_register_model (const char *name,const char *descr,int isa,const char *typename);
hw/audio/intel-hda.c +1 -1
@@ -1305,7 +1305,7 @@ static const TypeInfo hda_codec_device_type_info = {* create intel hda controller with codec attached to it, * so '-soundhw hda' works. */ -static int intel_hda_and_codec_init (PCIBus *bus,const char *audiodev) +static int intel_hda_and_codec_init (const char *audiodev) {g_autoptr (QDict) props =qdict_new ();DeviceState *intel_hda, *codec;
hw/audio/model.c +4 -8
@@ -24,14 +24,11 @@#include "qemu/osdep.h" #include "hw/qdev-core.h" #include "monitor/qdev.h" -#include "qemu/option.h" -#include "qemu/help_option.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "qom/object.h" #include "hw/qdev-properties.h" #include "hw/isa/isa.h" -#include "hw/pci/pci.h" #include "hw/audio/model.h" struct audio_model {
@@ -39,20 +36,20 @@ struct audio_model {const char *descr;const char *typename;int isa; -int (*init_pci) (PCIBus *bus,const char *audiodev); +int (*init)(const char *audiodev); };static struct audio_model audio_models[9 ];static int audio_models_count;void audio_register_model_with_cb (const char *name,const char *descr, -int (*init_pci)(PCIBus *bus,const char *audiodev)) +int (*init_audio_model)(const char *audiodev)) {assert (audio_models_count <ARRAY_SIZE (audio_models) -1 ); audio_models[audio_models_count].name = name; audio_models[audio_models_count].descr = descr; audio_models[audio_models_count].isa =0 ; - audio_models[audio_models_count].init_pci = init_pci; + audio_models[audio_models_count].init = init_audio_model; audio_models_count++; }
@@ -124,7 +121,6 @@ void audio_model_init(void)qdev_realize_and_unref (dev, bus, &error_fatal); }else {assert (!c->isa); -PCIBus *pci_bus = (PCIBus *)object_resolve_path_type ("" ,TYPE_PCI_BUS ,NULL ); - c->init_pci (pci_bus, audiodev_id); + c->init (audiodev_id); } }
Signature · 1 line
2.51.0
PATCH 15/43 hw/audio: drop audio_model.isa
In reply to [email protected]From: Marc-André Lureau <[email protected]>
That's no longer necessary, the code is bus-agnostic.
--- include/hw/audio/model.h | 2 +- hw/audio/ac97.c | 2 +- hw/audio/adlib.c | 2 +- hw/audio/cs4231a.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/gus.c | 2 +- hw/audio/model.c | 7 +------ hw/audio/sb16.c | 2 +- hw/audio/virtio-snd-pci.c | 2 +- 9 files changed, 9 insertions(+), 14 deletions(-)
include/hw/audio/model.h +1 -1
@@ -4,7 +4,7 @@void audio_register_model_with_cb (const char *name,const char *descr,int (*init_audio_model)(const char *audiodev));void audio_register_model (const char *name,const char *descr, -int isa,const char *typename); +const char *typename);void audio_model_init (void );void audio_print_available_models (void );
hw/audio/ac97.c +1 -1
@@ -1360,7 +1360,7 @@ static const TypeInfo ac97_info = {static void ac97_register_types (void ) {type_register_static (&ac97_info); -audio_register_model ("ac97" ,"Intel 82801AA AC97 Audio" ,0 ,TYPE_AC97 ); +audio_register_model ("ac97" ,"Intel 82801AA AC97 Audio" ,TYPE_AC97 ); }type_init (ac97_register_types)
hw/audio/adlib.c +1 -1
@@ -323,7 +323,7 @@ static const TypeInfo adlib_info = {static void adlib_register_types (void ) {type_register_static (&adlib_info); -audio_register_model ("adlib" ,ADLIB_DESC ,1 ,TYPE_ADLIB ); +audio_register_model ("adlib" ,ADLIB_DESC ,TYPE_ADLIB ); }type_init (adlib_register_types)
hw/audio/cs4231a.c +1 -1
@@ -723,7 +723,7 @@ static const TypeInfo cs4231a_info = {static void cs4231a_register_types (void ) {type_register_static (&cs4231a_info); -audio_register_model ("cs4231a" ,"CS4231A" ,1 ,TYPE_CS4231A ); +audio_register_model ("cs4231a" ,"CS4231A" ,TYPE_CS4231A ); }type_init (cs4231a_register_types)
hw/audio/es1370.c +1 -1
@@ -905,7 +905,7 @@ static const TypeInfo es1370_info = {static void es1370_register_types (void ) {type_register_static (&es1370_info); -audio_register_model ("es1370" ,"ENSONIQ AudioPCI ES1370" ,0 ,TYPE_ES1370 ); +audio_register_model ("es1370" ,"ENSONIQ AudioPCI ES1370" ,TYPE_ES1370 ); }type_init (es1370_register_types)
hw/audio/gus.c +1 -1
@@ -319,7 +319,7 @@ static const TypeInfo gus_info = {static void gus_register_types (void ) {type_register_static (&gus_info); -audio_register_model ("gus" ,"Gravis Ultrasound GF1" ,1 ,TYPE_GUS ); +audio_register_model ("gus" ,"Gravis Ultrasound GF1" ,TYPE_GUS ); }type_init (gus_register_types)
hw/audio/model.c +1 -6
@@ -28,14 +28,12 @@#include "qapi/error.h" #include "qom/object.h" #include "hw/qdev-properties.h" -#include "hw/isa/isa.h" #include "hw/audio/model.h" struct audio_model {const char *name;const char *descr;const char *typename; -int isa;int (*init)(const char *audiodev); };
@@ -48,18 +46,16 @@ void audio_register_model_with_cb(const char *name, const char *descr,assert (audio_models_count <ARRAY_SIZE (audio_models) -1 ); audio_models[audio_models_count].name = name; audio_models[audio_models_count].descr = descr; - audio_models[audio_models_count].isa =0 ; audio_models[audio_models_count].init = init_audio_model; audio_models_count++; }void audio_register_model (const char *name,const char *descr, -int isa,const char *typename) +const char *typename) {assert (audio_models_count <ARRAY_SIZE (audio_models) -1 ); audio_models[audio_models_count].name = name; audio_models[audio_models_count].descr = descr; - audio_models[audio_models_count].isa = isa; audio_models[audio_models_count].typename = typename; audio_models_count++; }
@@ -120,7 +116,6 @@ void audio_model_init(void)qdev_prop_set_string (dev,"audiodev" , audiodev_id);qdev_realize_and_unref (dev, bus, &error_fatal); }else { -assert (!c->isa); c->init (audiodev_id); } }
hw/audio/sb16.c +1 -1
@@ -1471,7 +1471,7 @@ static const TypeInfo sb16_info = {static void sb16_register_types (void ) {type_register_static (&sb16_info); -audio_register_model ("sb16" ,"Creative Sound Blaster 16" ,1 ,TYPE_SB16 ); +audio_register_model ("sb16" ,"Creative Sound Blaster 16" ,TYPE_SB16 ); }type_init (sb16_register_types)
hw/audio/virtio-snd-pci.c +1 -1
@@ -74,7 +74,7 @@ static const VirtioPCIDeviceTypeInfo virtio_snd_pci_info = {static void virtio_snd_pci_register (void ) {virtio_pci_types_register (&virtio_snd_pci_info); -audio_register_model ("virtio" ,"Virtio Sound" ,0 ,TYPE_VIRTIO_SND_PCI ); +audio_register_model ("virtio" ,"Virtio Sound" ,TYPE_VIRTIO_SND_PCI ); }type_init (virtio_snd_pci_register);
Signature · 1 line
2.51.0
Re: [PATCH 15/43] hw/audio: drop audio_model.isa
Quoted 5 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
That's no longer necessary, the code is bus-agnostic.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 11 lines
--- include/hw/audio/model.h | 2 +- hw/audio/ac97.c | 2 +- hw/audio/adlib.c | 2 +- hw/audio/cs4231a.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/gus.c | 2 +- hw/audio/model.c | 7 +------ hw/audio/sb16.c | 2 +- hw/audio/virtio-snd-pci.c | 2 +- 9 files changed, 9 insertions(+), 14 deletions(-)
PATCH 16/43 audio: start making AudioState a QOM Object
In reply to [email protected]From: Marc-André Lureau <[email protected]>
QOM brings some conveniences for introspection, type checking, reference counting, interfaces etc. This is only the first step to introduce QOM in audio/ (I have more in the pipeline)
--- audio/audio.h | 8 ++++++++ audio/audio_int.h | 2 ++ audio/audio.c | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 11 deletions(-)
audio/audio.h +8 -0
@@ -80,6 +80,11 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; +typedef struct AudioStateClass AudioStateClass ; +struct AudioStateClass { +ObjectClass parent_class; +}; +typedef struct AudioState AudioState ; typedef struct QEMUSoundCard { char *name;
@@ -182,4 +187,7 @@ const char *audio_get_id(QEMUSoundCard *card);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) +#define TYPE_AUDIO_STATE "audio-state" +OBJECT_DECLARE_TYPE(AudioState, AudioStateClass, AUDIO_STATE) +#endif /* QEMU_AUDIO_H */
audio/audio_int.h +2 -0
@@ -217,6 +217,8 @@ struct SWVoiceCap { }; typedef struct AudioState { + Object parent; + struct audio_driver *drv; Audiodev *dev; void *drv_opaque;
audio/audio.c +32 -11
83 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [PATCH 16/43] audio: start making AudioState a QOM Object
Quoted 18 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
QOM brings some conveniences for introspection, type checking, reference counting, interfaces etc. This is only the first step to introduce QOM in audio/ (I have more in the pipeline)
Signed-off-by Marc-André Lureau <[email protected]>--- audio/audio.h | 8 ++++++++ audio/audio_int.h | 2 ++ audio/audio.c | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 11 deletions(-)audio/audio.h +0
-0
audio/audio.h typedef struct SWVoiceOut SWVoiceOut; · line 83
Quoted 4 lines
audio/audio.h +1
-0@@ -80,6 +80,11 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; +typedef struct AudioStateClass AudioStateClass ;
This typedef isn't necessary, as done by OBJECT_DECLARE_TYPE below.
Otherwise (modulo the // comment in audio_state_info):
Quoted 13 lines
audio/audio.h +6
-0+struct AudioStateClass { +ObjectClass parent_class; +}; +typedef struct AudioState AudioState ; typedef struct QEMUSoundCard { char *name;@@ -182,4 +187,7 @@ const char *audio_get_id(QEMUSoundCard *card);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) +#define TYPE_AUDIO_STATE "audio-state" +OBJECT_DECLARE_TYPE (AudioState, AudioStateClass,AUDIO_STATE )
PATCH 17/43 audio: register backends in /audiodevs container
In reply to [email protected]From: Marc-André Lureau <[email protected]>
QOM tree now has /audiodevs objects.
--- audio/audio.c | 8 ++++++++ qom/object.c | 1 + 2 files changed, 9 insertions(+)
audio/audio.c +8 -0
@@ -1726,6 +1726,11 @@ void audio_create_default_audiodevs(void) } } +static Object *get_audiodevs_root (void ) +{ +return object_get_container ("audiodevs" ); +} +/* * if we have dev, this function was called because of an -audiodev argument => * initialize a new state with it
@@ -1742,6 +1747,9 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)struct audio_driver *driver; s =AUDIO_STATE (object_new (TYPE_AUDIO_STATE )); +if (!object_property_try_add_child (get_audiodevs_root (), dev->id,OBJECT (s), errp)) { + goto out; + }if (!atexit_registered) {atexit (audio_cleanup);
qom/object.c +1 -0
@@ -1730,6 +1730,7 @@ const char *object_property_get_type(Object *obj, const char *name, Error **errp }static const char *const root_containers[] = { +"audiodevs" ,"chardevs" ,"objects" ,"backend"
Signature · 1 line
2.51.0
Re: [PATCH 17/43] audio: register backends in /audiodevs container
Quoted 12 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
QOM tree now has /audiodevs objects.
Signed-off-by Marc-André Lureau <[email protected]>--- audio/audio.c | 8 ++++++++ qom/object.c | 1 + 2 files changed, 9 insertions(+)
audio/audio.c static AudioState *audio_init(Audiodev *dev, Error **errp) · line 1750
Quoted 4 lines
audio/audio.c +1
-0@@ -1742,6 +1747,9 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)struct audio_driver *driver; s =AUDIO_STATE (object_new (TYPE_AUDIO_STATE )); +if (!object_property_try_add_child (get_audiodevs_root (), dev->id,OBJECT (s), errp)) {
&error_fatal?
audio/audio.c static AudioState *audio_init(Audiodev *dev, Error **errp) · line 1752
Quoted 2 lines
audio/audio.c +2
-0+ goto out; + }
Re: [PATCH 17/43] audio: register backends in /audiodevs container
In reply to [email protected]Quoted 15 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
QOM tree now has /audiodevs objects.
Signed-off-by Marc-André Lureau <[email protected]>--- audio/audio.c | 8 ++++++++ qom/object.c | 1 + 2 files changed, 9 insertions(+)audio/audio.c +0
-0
audio/audio.c void audio_create_default_audiodevs(void) · line 1732
Quoted 7 lines
audio/audio.c +4
-0@@ -1726,6 +1726,11 @@ void audio_create_default_audiodevs(void) } } +static Object *get_audiodevs_root (void ) +{ +return object_get_container ("audiodevs" ); +}
Move before audio_cleanup() to avoid next patch churn.
PATCH 18/43 audio: use /audiodevs qom container
In reply to [email protected]From: Marc-André Lureau <[email protected]>
audio_cleanup() is already called at exit (similar to chardev)
--- audio/audio_int.h | 2 -- audio/audio.c | 48 ++++++++++++++++++----------------------------- 2 files changed, 18 insertions(+), 32 deletions(-)
audio/audio_int.h +0 -2
@@ -235,8 +235,6 @@ typedef struct AudioState {bool timer_running;uint64_t timer_last; - -QTAILQ_ENTRY (AudioState) list; } AudioState;extern const struct mixeng_volume nominal_volume;
audio/audio.c +18 -30
94 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH 19/43 audio/paaudio: remove needless return value
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/paaudio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
audio/paaudio.c +4 -9
@@ -747,14 +747,13 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol)pa_threaded_mainloop_unlock (c->mainloop); } -static int qpa_validate_per_direction_opts (Audiodev *dev, -AudiodevPaPerDirectionOptions *pdo) +static void qpa_validate_per_direction_opts (Audiodev *dev, +AudiodevPaPerDirectionOptions *pdo) {if (!pdo->has_latency) { pdo->has_latency = true; pdo->latency =46440 ; } -return 1 ; }/* common */
@@ -844,12 +843,8 @@ static void *qpa_audio_init(Audiodev *dev, Error **errp) } } -if (!qpa_validate_per_direction_opts (dev, popts->in)) { -return NULL ; - } -if (!qpa_validate_per_direction_opts (dev, popts->out)) { -return NULL ; - } +qpa_validate_per_direction_opts (dev, popts->in); +qpa_validate_per_direction_opts (dev, popts->out); g =g_new0 (paaudio,1 ); server = popts->server;
Signature · 1 line
2.51.0
Re: [PATCH 19/43] audio/paaudio: remove needless return value
Quoted 6 lines · On 21/10/25 11:02, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- audio/paaudio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
PATCH 20/43 audio/dsound: simplify init()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Use dsound_audio_fini() on error & fail if the capture failed to initialize too.
--- audio/dsoundaudio.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
audio/dsoundaudio.c +11 -18
@@ -638,7 +638,7 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp) hr =CoInitialize (NULL );if (FAILED (hr)) {dsound_logerr (hr,"Could not initialize COM\n" ); -g_free (s); +dsound_audio_fini (s);return NULL ; }
@@ -651,19 +651,14 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp) );if (FAILED (hr)) {dsound_logerr (hr,"Could not create DirectSound instance\n" ); -g_free (s); +dsound_audio_fini (s);return NULL ; } hr =IDirectSound_Initialize (s->dsound,NULL );if (FAILED (hr)) {dsound_logerr (hr,"Could not initialize DirectSound\n" ); - - hr =IDirectSound_Release (s->dsound); -if (FAILED (hr)) { -dsound_logerr (hr,"Could not release DirectSound\n" ); - } -g_free (s); +dsound_audio_fini (s);return NULL ; }
@@ -676,17 +671,15 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp) );if (FAILED (hr)) {dsound_logerr (hr,"Could not create DirectSoundCapture instance\n" ); - }else { - hr =IDirectSoundCapture_Initialize (s->dsound_capture,NULL ); -if (FAILED (hr)) { -dsound_logerr (hr,"Could not initialize DirectSoundCapture\n" ); +dsound_audio_fini (s); +return NULL ; + } - hr =IDirectSoundCapture_Release (s->dsound_capture); -if (FAILED (hr)) { -dsound_logerr (hr,"Could not release DirectSoundCapture\n" ); - } - s->dsound_capture =NULL ; - } + hr =IDirectSoundCapture_Initialize (s->dsound_capture,NULL ); +if (FAILED (hr)) { +dsound_logerr (hr,"Could not initialize DirectSoundCapture\n" ); +dsound_audio_fini (s); +return NULL ; } err =dsound_set_cooperative_level (s);
Signature · 1 line
2.51.0
PATCH 21/43 audio/dsound: report init error via **errp
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Whenever NULL is returned, errp should be set.
Inline SetCooperativeLevel call to simplify code.
--- audio/dsoundaudio.c | 182 +++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 103 deletions(-)
audio/dsoundaudio.c +79 -103
@@ -33,6 +33,7 @@#include "audio_int.h" #include "qemu/host-utils.h" #include "qemu/module.h" +#include "qapi/error.h" #include <windows.h> #include <mmsystem.h>
@@ -64,162 +65,154 @@ typedef struct {dsound *s; } DSoundVoiceIn; -static void dsound_log_hresult (HRESULT hr) +static const char *dserror (HRESULT hr) { -const char *str ="BUG" ; -switch (hr) {case DS_OK : - str ="The method succeeded" ; -break ; +return "The method succeeded" ;#ifdef DS_NO_VIRTUALIZATION case DS_NO_VIRTUALIZATION : - str ="The buffer was created, but another 3D algorithm was substituted" ; -break ; +return "The buffer was created, but another 3D algorithm was substituted" ;#endif #ifdef DS_INCOMPLETE case DS_INCOMPLETE : - str ="The method succeeded, but not all the optional effects were obtained" ; -break ; +return "The method succeeded, but not all the optional effects were obtained" ;#endif #ifdef DSERR_ACCESSDENIED case DSERR_ACCESSDENIED : - str ="The request failed because access was denied" ; -break ; +return "The request failed because access was denied" ;#endif #ifdef DSERR_ALLOCATED case DSERR_ALLOCATED : - str ="The request failed because resources, " -"such as a priority level, were already in use " -"by another caller" ; -break ; +return "The request failed because resources, " +"such as a priority level, were already in use " +"by another caller" ;#endif #ifdef DSERR_ALREADYINITIALIZED case DSERR_ALREADYINITIALIZED : - str ="The object is already initialized" ; -break ; +return "The object is already initialized" ;#endif #ifdef DSERR_BADFORMAT case DSERR_BADFORMAT : - str ="The specified wave format is not supported" ; -break ; +return "The specified wave format is not supported" ;#endif #ifdef DSERR_BADSENDBUFFERGUID case DSERR_BADSENDBUFFERGUID : - str ="The GUID specified in an audiopath file " -"does not match a valid mix-in buffer" ; -break ; +return "The GUID specified in an audiopath file " +"does not match a valid mix-in buffer" ;#endif #ifdef DSERR_BUFFERLOST case DSERR_BUFFERLOST : - str ="The buffer memory has been lost and must be restored" ; -break ; +return "The buffer memory has been lost and must be restored" ;#endif #ifdef DSERR_BUFFERTOOSMALL case DSERR_BUFFERTOOSMALL : - str ="The buffer size is not great enough to " -"enable effects processing" ; -break ; +return "The buffer size is not great enough to " +"enable effects processing" ;#endif #ifdef DSERR_CONTROLUNAVAIL case DSERR_CONTROLUNAVAIL : - str ="The buffer control (volume, pan, and so on) " -"requested by the caller is not available. " -"Controls must be specified when the buffer is created, " -"using the dwFlags member of DSBUFFERDESC" ; -break ; +return "The buffer control (volume, pan, and so on) " +"requested by the caller is not available. " +"Controls must be specified when the buffer is created, " +"using the dwFlags member of DSBUFFERDESC" ;#endif #ifdef DSERR_DS8_REQUIRED case DSERR_DS8_REQUIRED : - str ="A DirectSound object of class CLSID_DirectSound8 or later " -"is required for the requested functionality. " -"For more information, see IDirectSound8 Interface" ; -break ; +return "A DirectSound object of class CLSID_DirectSound8 or later " +"is required for the requested functionality. " +"For more information, see IDirectSound8 Interface" ;#endif #ifdef DSERR_FXUNAVAILABLE case DSERR_FXUNAVAILABLE : - str ="The effects requested could not be found on the system, " -"or they are in the wrong order or in the wrong location; " -"for example, an effect expected in hardware " -"was found in software" ; -break ; +return "The effects requested could not be found on the system, " +"or they are in the wrong order or in the wrong location; " +"for example, an effect expected in hardware " +"was found in software" ;#endif #ifdef DSERR_GENERIC case DSERR_GENERIC : - str ="An undetermined error occurred inside the DirectSound subsystem" ; -break ; +return "An undetermined error occurred inside the DirectSound subsystem" ;#endif #ifdef DSERR_INVALIDCALL case DSERR_INVALIDCALL : - str ="This function is not valid for the current state of this object" ; -break ; +return "This function is not valid for the current state of this object" ;#endif #ifdef DSERR_INVALIDPARAM case DSERR_INVALIDPARAM : - str ="An invalid parameter was passed to the returning function" ; -break ; +return "An invalid parameter was passed to the returning function" ;#endif #ifdef DSERR_NOAGGREGATION case DSERR_NOAGGREGATION : - str ="The object does not support aggregation" ; -break ; +return "The object does not support aggregation" ;#endif #ifdef DSERR_NODRIVER case DSERR_NODRIVER : - str ="No sound driver is available for use, " -"or the given GUID is not a valid DirectSound device ID" ; -break ; +return "No sound driver is available for use, " +"or the given GUID is not a valid DirectSound device ID" ;#endif #ifdef DSERR_NOINTERFACE case DSERR_NOINTERFACE : - str ="The requested COM interface is not available" ; -break ; +return "The requested COM interface is not available" ;#endif #ifdef DSERR_OBJECTNOTFOUND case DSERR_OBJECTNOTFOUND : - str ="The requested object was not found" ; -break ; +return "The requested object was not found" ;#endif #ifdef DSERR_OTHERAPPHASPRIO case DSERR_OTHERAPPHASPRIO : - str ="Another application has a higher priority level, " +return "Another application has a higher priority level, " "preventing this call from succeeding" ; -break ;#endif #ifdef DSERR_OUTOFMEMORY case DSERR_OUTOFMEMORY : - str ="The DirectSound subsystem could not allocate " +return "The DirectSound subsystem could not allocate " "sufficient memory to complete the caller's request" ; -break ;#endif #ifdef DSERR_PRIOLEVELNEEDED case DSERR_PRIOLEVELNEEDED : - str ="A cooperative level of DSSCL_PRIORITY or higher is required" ; -break ; +return "A cooperative level of DSSCL_PRIORITY or higher is required" ;#endif #ifdef DSERR_SENDLOOP case DSERR_SENDLOOP : - str ="A circular loop of send effects was detected" ; -break ; +return "A circular loop of send effects was detected" ;#endif #ifdef DSERR_UNINITIALIZED case DSERR_UNINITIALIZED : - str ="The Initialize method has not been called " -"or has not been called successfully " -"before other methods were called" ; -break ; +return "The Initialize method has not been called " +"or has not been called successfully " +"before other methods were called" ;#endif #ifdef DSERR_UNSUPPORTED case DSERR_UNSUPPORTED : - str ="The function called is not supported at this time" ; -break ; +return "The function called is not supported at this time" ;#endif default : -AUD_log (AUDIO_CAP ,"Reason: Unknown (HRESULT 0x%lx)\n" , hr); -return ; +return NULL ; + } + +} + +static void dserror_set (Error **errp,HRESULT hr,const char *msg) +{ +const char *str =dserror (hr); + +if (str) { +error_setg (errp,"%s: %s" , msg, str); + }else { +error_setg (errp,"%s: Unknown (HRESULT: 0x%lx)" , msg, hr); } +} + +static void dsound_log_hresult (HRESULT hr) +{ +const char *str =dserror (hr); -AUD_log (AUDIO_CAP ,"Reason: %s\n" , str); +if (str) { +AUD_log (AUDIO_CAP ,"Reason: %s\n" , str); + }else { +AUD_log (AUDIO_CAP ,"Reason: Unknown (HRESULT: 0x%lx)\n" , hr); + } } static void G_GNUC_PRINTF (2, 3) dsound_logerr (
@@ -359,27 +352,6 @@ static void dsound_clear_sample (HWVoiceOut *hw, LPDIRECTSOUNDBUFFER dsb,dsound_unlock_out (dsb, p1, p2, blen1, blen2); } -static int dsound_set_cooperative_level (dsound *s) -{ -HRESULT hr; -HWND hwnd; - - hwnd =GetDesktopWindow (); - hr =IDirectSound_SetCooperativeLevel ( - s->dsound, - hwnd, -DSSCL_PRIORITY - ); - -if (FAILED (hr)) { -dsound_logerr (hr,"Could not set cooperative level for window %p\n" , - hwnd); -return -1 ; - } - -return 0 ; -} -static void dsound_enable_out (HWVoiceOut *hw,bool enable) {HRESULT hr;
@@ -621,7 +593,6 @@ static void dsound_audio_fini (void *opaque)static void *dsound_audio_init (Audiodev *dev,Error **errp) { -int err;HRESULT hr;dsound *s =g_new0 (dsound,1 );AudiodevDsoundOptions *dso;
@@ -637,7 +608,7 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp) hr =CoInitialize (NULL );if (FAILED (hr)) { -dsound_logerr (hr,"Could not initialize COM\n" ); +dserror_set (errp, hr,"Could not initialize COM" );dsound_audio_fini (s);return NULL ; }
@@ -650,14 +621,14 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp) (void **) &s->dsound );if (FAILED (hr)) { -dsound_logerr (hr,"Could not create DirectSound instance\n" ); +dserror_set (errp, hr,"Could not create DirectSound instance" );dsound_audio_fini (s);return NULL ; } hr =IDirectSound_Initialize (s->dsound,NULL );if (FAILED (hr)) { -dsound_logerr (hr,"Could not initialize DirectSound\n" ); +dserror_set (errp, hr,"Could not initialize DirectSound" );dsound_audio_fini (s);return NULL ; }
@@ -670,21 +641,26 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp) (void **) &s->dsound_capture );if (FAILED (hr)) { -dsound_logerr (hr,"Could not create DirectSoundCapture instance\n" ); +dserror_set (errp, hr,"Could not create DirectSoundCapture instance" );dsound_audio_fini (s);return NULL ; } hr =IDirectSoundCapture_Initialize (s->dsound_capture,NULL );if (FAILED (hr)) { -dsound_logerr (hr,"Could not initialize DirectSoundCapture\n" ); +dserror_set (errp, hr,"Could not initialize DirectSoundCapture" );dsound_audio_fini (s);return NULL ; } - err =dsound_set_cooperative_level (s); -if (err) { -dsound_audio_fini (s); + hr =IDirectSound_SetCooperativeLevel ( + s->dsound, +GetDesktopWindow (), +DSSCL_PRIORITY + ); +if (FAILED (hr)) { +dserror_set (errp, hr,"Could not set cooperative level" ); +dsound_audio_fini (s);return NULL ; }
Signature · 1 line
2.51.0
PATCH 22/43 audio: simplify audio_driver_init()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Catch and return from error early to avoid indentations and ease the flow & return a bool for success value. All driver init() calls have been checked to set errp on error.
--- audio/audio.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-)
audio/audio.c +20 -28
@@ -1562,35 +1562,27 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)return total; } -static int audio_driver_init (AudioState *s,struct audio_driver *drv, -Audiodev *dev,Error **errp) +static bool audio_driver_init (AudioState *s,struct audio_driver *drv, +Audiodev *dev,Error **errp) { -Error *local_err =NULL ; - - s->drv_opaque = drv->init (dev, &local_err); - -if (s->drv_opaque) { -if (!drv->pcm_ops->get_buffer_in) { - drv->pcm_ops->get_buffer_in = audio_generic_get_buffer_in; - drv->pcm_ops->put_buffer_in = audio_generic_put_buffer_in; - } -if (!drv->pcm_ops->get_buffer_out) { - drv->pcm_ops->get_buffer_out = audio_generic_get_buffer_out; - drv->pcm_ops->put_buffer_out = audio_generic_put_buffer_out; - } + s->drv_opaque = drv->init (dev, errp); +if (!s->drv_opaque) { +return false; + } -audio_init_nb_voices_out (s, drv,1 ); -audio_init_nb_voices_in (s, drv,0 ); - s->drv = drv; -return 0 ; - }else { -if (local_err) { -error_propagate (errp, local_err); - }else { -error_setg (errp,"Could not init `%s' audio driver" , drv->name); - } -return -1 ; +if (!drv->pcm_ops->get_buffer_in) { + drv->pcm_ops->get_buffer_in = audio_generic_get_buffer_in; + drv->pcm_ops->put_buffer_in = audio_generic_put_buffer_in; } +if (!drv->pcm_ops->get_buffer_out) { + drv->pcm_ops->get_buffer_out = audio_generic_get_buffer_out; + drv->pcm_ops->put_buffer_out = audio_generic_put_buffer_out; + } + +audio_init_nb_voices_out (s, drv,1 ); +audio_init_nb_voices_in (s, drv,0 ); + s->drv = drv; +return true; } static void audio_vm_change_state_handler (void *opaque, bool running,
@@ -1748,7 +1740,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) drvname =AudiodevDriver_str (dev->driver); driver =audio_driver_lookup (drvname);if (driver) { - done = !audio_driver_init (s, driver, dev, errp); + done =audio_driver_init (s, driver, dev, errp); }else {error_setg (errp,"Unknown audio driver `%s'" , drvname); }
@@ -1768,7 +1760,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)g_free (e); drvname =AudiodevDriver_str (dev->driver); driver =audio_driver_lookup (drvname); -if (!audio_driver_init (s, driver, dev,NULL )) { +if (audio_driver_init (s, driver, dev,NULL )) {break ; }qapi_free_Audiodev (dev);
Signature · 1 line
2.51.0
PATCH 23/43 audio: move period tick initialization
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Part of QOM-ification.
--- audio/audio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
audio/audio.c +7 -6
@@ -1582,6 +1582,13 @@ static bool audio_driver_init(AudioState *s, struct audio_driver *drv,audio_init_nb_voices_out (s, drv,1 );audio_init_nb_voices_in (s, drv,0 ); s->drv = drv; + +if (dev->timer_period <=0 ) { + s->period_ticks =1 ; + }else { + s->period_ticks = dev->timer_period * (int64_t )SCALE_US ; + } +return true; }
@@ -1768,12 +1775,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) } } -if (dev->timer_period <=0 ) { - s->period_ticks =1 ; - }else { - s->period_ticks = dev->timer_period * (int64_t )SCALE_US ; - } - vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);if (!vmse) { dolog ("warning: Could not register change state handler\n"
Signature · 1 line
2.51.0
PATCH 24/43 audio: drop needless error message
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The only reason it would fail to add the handler is if it's calling a stub. But this cannot happen as audio is only supported with system qemu.
--- audio/audio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
audio/audio.c +1 -4
@@ -1776,10 +1776,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) } vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); -if (!vmse) { -dolog ("warning: Could not register change state handler\n" -"(Audio can continue looping even after stopping the VM)\n" ); - } +assert (vmse !=NULL );if (!object_property_try_add_child (get_audiodevs_root (), dev->id,OBJECT (s), errp)) { goto out;
Signature · 1 line
2.51.0
PATCH 25/43 audio: clean-up vmstate change handler on finalize
In reply to [email protected]From: Marc-André Lureau <[email protected]>
QOM-ification continues.
--- audio/audio_int.h | 1 + audio/audio.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
audio/audio_int.h +1 -0
@@ -235,6 +235,7 @@ typedef struct AudioState {bool timer_running;uint64_t timer_last; +VMChangeStateEntry *vmse; } AudioState;extern const struct mixeng_volume nominal_volume;
audio/audio.c +8 -4
@@ -1622,6 +1622,9 @@ static void audio_state_init(Object *obj)QLIST_INIT (&s->hw_head_in);QLIST_INIT (&s->cap_head); s->ts =timer_new_ns (QEMU_CLOCK_VIRTUAL , audio_timer, s); + + s->vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); +assert (s->vmse !=NULL ); }static void audio_state_finalize (Object *obj)
@@ -1671,6 +1674,11 @@ static void audio_state_finalize(Object *obj)timer_free (s->ts); s->ts =NULL ; } + +if (s->vmse) { +qemu_del_vm_change_state_handler (s->vmse); + s->vmse =NULL ; + } }static Object *get_audiodevs_root (void )
@@ -1735,7 +1743,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) {int done =0 ;const char *drvname; -VMChangeStateEntry *vmse;AudioState *s;struct audio_driver *driver;
@@ -1775,9 +1782,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) } } - vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); -assert (vmse !=NULL ); -if (!object_property_try_add_child (get_audiodevs_root (), dev->id,OBJECT (s), errp)) { goto out; }
Signature · 1 line
2.51.0
PATCH 26/43 audio: unregister vmstate description
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
audio/audio.c +6 -1
@@ -1614,6 +1614,8 @@ static void audio_vm_change_state_handler (void *opaque, bool running,audio_reset_timer (s); } +static const VMStateDescription vmstate_audio; +static void audio_state_init (Object *obj) {AudioState *s =AUDIO_STATE (obj);
@@ -1625,6 +1627,8 @@ static void audio_state_init(Object *obj) s->vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);assert (s->vmse !=NULL ); + +vmstate_register_any (NULL , &vmstate_audio, s); }static void audio_state_finalize (Object *obj)
@@ -1679,6 +1683,8 @@ static void audio_state_finalize(Object *obj)qemu_del_vm_change_state_handler (s->vmse); s->vmse =NULL ; } + +vmstate_unregister (NULL , &vmstate_audio, s); }static Object *get_audiodevs_root (void )
@@ -1787,7 +1793,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) }object_unref (s);QLIST_INIT (&s->card_head); -vmstate_register_any (NULL , &vmstate_audio, s);return s; out:
Signature · 1 line
2.51.0
PATCH 27/43 audio: initialize card_head during object init
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/audio.c +1 -1
@@ -1623,6 +1623,7 @@ static void audio_state_init(Object *obj)QLIST_INIT (&s->hw_head_out);QLIST_INIT (&s->hw_head_in);QLIST_INIT (&s->cap_head); +QLIST_INIT (&s->card_head); s->ts =timer_new_ns (QEMU_CLOCK_VIRTUAL , audio_timer, s); s->vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
@@ -1792,7 +1793,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) goto out; }object_unref (s); -QLIST_INIT (&s->card_head);return s; out:
Signature · 1 line
2.51.0
PATCH 28/43 audio: remove some needless headers
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 1 - audio/audio.c | 3 --- audio/dbusaudio.c | 2 -- audio/dsoundaudio.c | 1 - audio/mixeng.c | 4 +++- audio/noaudio.c | 2 -- audio/wavaudio.c | 3 --- audio/wavcapture.c | 1 - 8 files changed, 3 insertions(+), 14 deletions(-)
audio/audio.h +0 -1
@@ -27,7 +27,6 @@#include "qemu/queue.h" #include "qapi/qapi-types-audio.h" -#include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" typedef void (*audio_callback_fn ) (void *opaque,int avail);
audio/audio.c +0 -3
@@ -25,7 +25,6 @@#include "qemu/osdep.h" #include "audio.h" #include "migration/vmstate.h" -#include "monitor/monitor.h" #include "qemu/timer.h" #include "qapi/error.h" #include "qapi/clone-visitor.h"
@@ -33,7 +32,6 @@#include "qapi/qapi-visit-audio.h" #include "qapi/qapi-commands-audio.h" #include "qobject/qdict.h" -#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/module.h"
@@ -41,7 +39,6 @@#include "system/system.h" #include "system/replay.h" #include "system/runstate.h" -#include "ui/qemu-spice.h" #include "trace.h" #define AUDIO_CAP "audio"
audio/dbusaudio.c +0 -2
@@ -24,9 +24,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" -#include "qemu/host-utils.h" #include "qemu/module.h" -#include "qemu/timer.h" #include "qemu/dbus.h" #ifdef G_OS_UNIX
audio/dsoundaudio.c +0 -1
@@ -31,7 +31,6 @@#define AUDIO_CAP "dsound"#include "audio_int.h" -#include "qemu/host-utils.h" #include "qemu/module.h" #include "qapi/error.h"
audio/mixeng.c +3 -1
@@ -24,11 +24,13 @@*/ #include "qemu/osdep.h" #include "qemu/bswap.h" -#include "qemu/error-report.h" #include "audio.h" #define AUDIO_CAP "mixeng"#include "audio_int.h" +#ifdef FLOAT_MIXENG +#include "qemu/error-report.h" +#endif /* 8 bit */ #define ENDIAN_CONVERSION natural
audio/noaudio.c +0 -2
@@ -23,10 +23,8 @@*/ #include "qemu/osdep.h" -#include "qemu/host-utils.h" #include "qemu/module.h" #include "audio.h" -#include "qemu/timer.h" #define AUDIO_CAP "noaudio"#include "audio_int.h"
audio/wavaudio.c +0 -3
@@ -23,10 +23,7 @@*/ #include "qemu/osdep.h" -#include "qemu/host-utils.h" #include "qemu/module.h" -#include "qemu/timer.h" -#include "qapi/opts-visitor.h" #include "audio.h" #define AUDIO_CAP "wav"
audio/wavcapture.c +0 -1
@@ -1,6 +1,5 @@#include "qemu/osdep.h" #include "qemu/qemu-print.h" -#include "qapi/error.h" #include "qemu/error-report.h" #include "audio.h"
Signature · 1 line
2.51.0
PATCH 29/43 audio: remove AUDIO_HOST_ENDIANNESS
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 6 ------ audio/audio.c | 6 +++--- audio/spiceaudio.c | 4 ++-- hw/audio/adlib.c | 2 +- hw/audio/asc.c | 2 +- hw/audio/cs4231a.c | 2 +- hw/audio/gus.c | 2 +- 7 files changed, 9 insertions(+), 15 deletions(-)
audio/audio.h +0 -6
@@ -31,12 +31,6 @@typedef void (*audio_callback_fn ) (void *opaque,int avail); -#if HOST_BIG_ENDIAN -#define AUDIO_HOST_ENDIANNESS 1 -#else -#define AUDIO_HOST_ENDIANNESS 0 -#endif - typedef struct audsettings { int freq; int nchannels;
audio/audio.c +3 -3
@@ -274,7 +274,7 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, struct audsettings *a && info->is_signed == is_signed && info->is_float == is_float && info->bits == bits - && info->swap_endianness == (as->endianness !=AUDIO_HOST_ENDIANNESS ); + && info->swap_endianness == (as->endianness !=HOST_BIG_ENDIAN ); }void audio_pcm_init_info (struct audio_pcm_info *info,struct audsettings *as)
@@ -320,7 +320,7 @@ void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as) info->nchannels = as->nchannels; info->bytes_per_frame = as->nchannels * mul; info->bytes_per_second = info->freq * info->bytes_per_frame; - info->swap_endianness = (as->endianness !=AUDIO_HOST_ENDIANNESS ); + info->swap_endianness = (as->endianness !=HOST_BIG_ENDIAN ); }void audio_pcm_info_clear_buf (struct audio_pcm_info *info,void *buf,int len)
@@ -2179,7 +2179,7 @@ audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) .freq = pdo->frequency, .nchannels = pdo->channels, .fmt = pdo->format, - .endianness = AUDIO_HOST_ENDIANNESS, + .endianness = HOST_BIG_ENDIAN, }; }
audio/spiceaudio.c +2 -2
@@ -102,7 +102,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as,#endif settings.nchannels =SPICE_INTERFACE_PLAYBACK_CHAN ; settings.fmt =AUDIO_FORMAT_S16 ; - settings.endianness =AUDIO_HOST_ENDIANNESS ; + settings.endianness =HOST_BIG_ENDIAN ;audio_pcm_init_info (&hw->info, &settings); hw->samples =LINE_OUT_SAMPLES ;
@@ -218,7 +218,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)#endif settings.nchannels =SPICE_INTERFACE_RECORD_CHAN ; settings.fmt =AUDIO_FORMAT_S16 ; - settings.endianness =AUDIO_HOST_ENDIANNESS ; + settings.endianness =HOST_BIG_ENDIAN ;audio_pcm_init_info (&hw->info, &settings); hw->samples =LINE_IN_SAMPLES ;
hw/audio/adlib.c +1 -1
@@ -272,7 +272,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp) as.freq = s->freq; as.nchannels =SHIFT ; as.fmt =AUDIO_FORMAT_S16 ; - as.endianness =AUDIO_HOST_ENDIANNESS ; + as.endianness =HOST_BIG_ENDIAN ; s->voice = AUD_open_out ( &s->card,
hw/audio/asc.c +1 -1
@@ -650,7 +650,7 @@ static void asc_realize(DeviceState *dev, Error **errp) as.freq =ASC_FREQ ; as.nchannels =2 ; as.fmt =AUDIO_FORMAT_U8 ; - as.endianness =AUDIO_HOST_ENDIANNESS ; + as.endianness =HOST_BIG_ENDIAN ; s->voice =AUD_open_out (&s->card, s->voice,"asc.out" , s, asc_out_cb, &as);
hw/audio/cs4231a.c +1 -1
@@ -305,7 +305,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) s->tab = ALawDecompressTable; x_law: as.fmt =AUDIO_FORMAT_S16 ; - as.endianness =AUDIO_HOST_ENDIANNESS ; + as.endianness =HOST_BIG_ENDIAN ; s->shift = as.nchannels ==2 ;break ;
hw/audio/gus.c +1 -1
@@ -254,7 +254,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp) as.freq = s->freq; as.nchannels =2 ; as.fmt =AUDIO_FORMAT_S16 ; - as.endianness =AUDIO_HOST_ENDIANNESS ; + as.endianness =HOST_BIG_ENDIAN ; s->voice = AUD_open_out ( &s->card,
Signature · 1 line
2.51.0
PATCH 30/43 audio: introduce AUD_set_volume_{in,out}_lr()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Keep the AUD_ prefix for consistency. Introduce a macro to call the more flexible Volume function.
--- audio/audio.h | 8 ++++---- audio/audio.c | 16 ++-------------- hw/audio/ac97.c | 4 ++-- hw/audio/asc.c | 2 +- hw/audio/hda-codec.c | 4 ++-- hw/audio/lm4549.c | 2 +- hw/audio/via-ac97.c | 2 +- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 12 ++++++------ hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 4 ++-- 11 files changed, 24 insertions(+), 36 deletions(-)
audio/audio.h +4 -4
@@ -120,8 +120,8 @@ int AUD_is_active_out (SWVoiceOut *sw);void AUD_init_time_stamp_out (SWVoiceOut *sw,QEMUAudioTimeStamp *ts);uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw,QEMUAudioTimeStamp *ts); -void AUD_set_volume_out (SWVoiceOut *sw,int mute,uint8_t lvol,uint8_t rvol); -void AUD_set_volume_in (SWVoiceIn *sw,int mute,uint8_t lvol,uint8_t rvol); +#define AUD_set_volume_out_lr (sw, mut, lvol, rvol) AUD_set_volume_out(sw, &(Volume) { .mute = mut, .channels = 2, .vol = { lvol, rvol } }) +#define AUD_set_volume_in_lr (sw, mut, lvol, rvol) AUD_set_volume_in(sw, &(Volume) { .mute = mut, .channels = 2, .vol = { lvol, rvol } })#define AUDIO_MAX_CHANNELS 16 typedef struct Volume {
@@ -130,8 +130,8 @@ typedef struct Volume {uint8_t vol[AUDIO_MAX_CHANNELS ]; } Volume; -void audio_set_volume_out (SWVoiceOut *sw,Volume *vol); -void audio_set_volume_in (SWVoiceIn *sw,Volume *vol); +void AUD_set_volume_out (SWVoiceOut *sw,Volume *vol); +void AUD_set_volume_in (SWVoiceIn *sw,Volume *vol); SWVoiceIn *AUD_open_in ( QEMUSoundCard *card,
audio/audio.c +2 -14
@@ -1949,13 +1949,7 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque) } } -void AUD_set_volume_out (SWVoiceOut *sw,int mute,uint8_t lvol,uint8_t rvol) -{ -Volume vol = { .mute = mute, .channels =2 , .vol = { lvol, rvol } }; -audio_set_volume_out (sw, &vol); -} - -void audio_set_volume_out (SWVoiceOut *sw,Volume *vol) +void AUD_set_volume_out (SWVoiceOut *sw,Volume *vol) {if (sw) {HWVoiceOut *hw = sw->hw;
@@ -1971,13 +1965,7 @@ void audio_set_volume_out(SWVoiceOut *sw, Volume *vol) } } -void AUD_set_volume_in (SWVoiceIn *sw,int mute,uint8_t lvol,uint8_t rvol) -{ -Volume vol = { .mute = mute, .channels =2 , .vol = { lvol, rvol } }; -audio_set_volume_in (sw, &vol); -} - -void audio_set_volume_in (SWVoiceIn *sw,Volume *vol) +void AUD_set_volume_in (SWVoiceIn *sw,Volume *vol) {if (sw) {HWVoiceIn *hw = sw->hw;
hw/audio/ac97.c +2 -2
@@ -414,7 +414,7 @@ static void update_combined_volume_out(AC97LinkState *s) lvol = (lvol * plvol) /255 ; rvol = (rvol * prvol) /255 ; -AUD_set_volume_out (s->voice_po, mute, lvol, rvol); +AUD_set_volume_out_lr (s->voice_po, mute, lvol, rvol); }static void update_volume_in (AC97LinkState *s)
@@ -425,7 +425,7 @@ static void update_volume_in(AC97LinkState *s)get_volume (mixer_load (s, AC97_Record_Gain_Mute),0x0f ,0 , &mute, &lvol, &rvol); -AUD_set_volume_in (s->voice_pi, mute, lvol, rvol); +AUD_set_volume_in_lr (s->voice_pi, mute, lvol, rvol); }static void set_volume (AC97LinkState *s,int index,uint32_t val)
hw/audio/asc.c +1 -1
@@ -489,7 +489,7 @@ static void asc_write(void *opaque, hwaddr addr, uint64_t value, {int vol = (value &0xe0 ); -AUD_set_volume_out (s->voice,0 , vol, vol); +AUD_set_volume_out_lr (s->voice,0 , vol, vol);break ; } }
hw/audio/hda-codec.c +2 -2
@@ -466,9 +466,9 @@ static void hda_audio_set_amp(HDAAudioStream *st)return ; }if (st->output) { -AUD_set_volume_out (st->voice.out, muted, left, right); +AUD_set_volume_out_lr (st->voice.out, muted, left, right); }else { -AUD_set_volume_in (st->voice.in, muted, left, right); +AUD_set_volume_in_lr (st->voice.in, muted, left, right); } }
hw/audio/lm4549.c +1 -1
@@ -308,7 +308,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_req_cb, void* opaque, &as ); -AUD_set_volume_out (s->voice,0 ,255 ,255 ); +AUD_set_volume_out_lr (s->voice,0 ,255 ,255 ); s->voice_is_active =0 ;
hw/audio/via-ac97.c +1 -1
@@ -53,7 +53,7 @@ static void codec_volume_set_out(ViaAC97State *s) rvol /=255 ; mute =CODEC_REG (s, AC97_Master_Volume_Mute) >>MUTE_SHIFT ; mute |=CODEC_REG (s, AC97_PCM_Out_Volume_Mute) >>MUTE_SHIFT ; -AUD_set_volume_out (s->vo, mute, lvol, rvol); +AUD_set_volume_out_lr (s->vo, mute, lvol, rvol); }static void codec_reset (ViaAC97State *s)
hw/audio/virtio-snd.c +2 -2
@@ -463,7 +463,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id) stream, virtio_snd_pcm_out_cb, &as); -AUD_set_volume_out (stream->voice.out,0 ,255 ,255 ); +AUD_set_volume_out_lr (stream->voice.out,0 ,255 ,255 ); }else { stream->voice.in = AUD_open_in(&s->card, stream->voice.in,
@@ -471,7 +471,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id) stream, virtio_snd_pcm_in_cb, &as); -AUD_set_volume_in (stream->voice.in,0 ,255 ,255 ); +AUD_set_volume_in_lr (stream->voice.in,0 ,255 ,255 ); }return cpu_to_le32 (VIRTIO_SND_S_OK );
hw/audio/wm8750.c +6 -6
@@ -145,30 +145,30 @@ static void wm8750_vol_update(WM8750State *s) {/* FIXME: multiply all volumes by s->invol[2], s->invol[3] */ -AUD_set_volume_in (s->adc_voice[0 ], s->mute, +AUD_set_volume_in_lr (s->adc_voice[0 ], s->mute, s->inmute[0 ] ?0 :WM8750_INVOL_TRANSFORM (s->invol[0 ]), s->inmute[1 ] ?0 :WM8750_INVOL_TRANSFORM (s->invol[1 ])); -AUD_set_volume_in (s->adc_voice[1 ], s->mute, +AUD_set_volume_in_lr (s->adc_voice[1 ], s->mute, s->inmute[0 ] ?0 :WM8750_INVOL_TRANSFORM (s->invol[0 ]), s->inmute[1 ] ?0 :WM8750_INVOL_TRANSFORM (s->invol[1 ])); -AUD_set_volume_in (s->adc_voice[2 ], s->mute, +AUD_set_volume_in_lr (s->adc_voice[2 ], s->mute, s->inmute[0 ] ?0 :WM8750_INVOL_TRANSFORM (s->invol[0 ]), s->inmute[1 ] ?0 :WM8750_INVOL_TRANSFORM (s->invol[1 ]));/* FIXME: multiply all volumes by s->outvol[0], s->outvol[1] */ /* Speaker: LOUT2VOL ROUT2VOL */ -AUD_set_volume_out (s->dac_voice[0 ], s->mute, +AUD_set_volume_out_lr (s->dac_voice[0 ], s->mute, s->outmute[0 ] ?0 :WM8750_OUTVOL_TRANSFORM (s->outvol[4 ]), s->outmute[1 ] ?0 :WM8750_OUTVOL_TRANSFORM (s->outvol[5 ]));/* Headphone: LOUT1VOL ROUT1VOL */ -AUD_set_volume_out (s->dac_voice[1 ], s->mute, +AUD_set_volume_out_lr (s->dac_voice[1 ], s->mute, s->outmute[0 ] ?0 :WM8750_OUTVOL_TRANSFORM (s->outvol[2 ]), s->outmute[1 ] ?0 :WM8750_OUTVOL_TRANSFORM (s->outvol[3 ]));/* MONOOUT: MONOVOL MONOVOL */ -AUD_set_volume_out (s->dac_voice[2 ], s->mute, +AUD_set_volume_out_lr (s->dac_voice[2 ], s->mute, s->outmute[0 ] ?0 :WM8750_OUTVOL_TRANSFORM (s->outvol[6 ]), s->outmute[1 ] ?0 :WM8750_OUTVOL_TRANSFORM (s->outvol[6 ])); }
hw/display/xlnx_dp.c +1 -1
@@ -1334,7 +1334,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp) s, xlnx_dp_audio_callback, &as); -AUD_set_volume_out (s->amixer_output_stream,0 ,255 ,255 ); +AUD_set_volume_out_lr (s->amixer_output_stream,0 ,255 ,255 );xlnx_dp_audio_activate (s); s->vblank =ptimer_init (vblank_hit, s,DP_VBLANK_PTIMER_POLICY );ptimer_transaction_begin (s->vblank);
hw/usb/dev-audio.c +2 -2
@@ -805,7 +805,7 @@ static int usb_audio_set_control(USBAudioState *s, uint8_t attrib, }fprintf (stderr,"\n" ); } -audio_set_volume_out (s->out.voice, &s->out.vol); +AUD_set_volume_out (s->out.voice, &s->out.vol); }return ret;
@@ -981,7 +981,7 @@ static void usb_audio_reinit(USBDevice *dev, unsigned channels) s->out.voice =AUD_open_out (&s->card, s->out.voice,TYPE_USB_AUDIO , s, output_callback, &s->out.as); -audio_set_volume_out (s->out.voice, &s->out.vol); +AUD_set_volume_out (s->out.voice, &s->out.vol);AUD_set_active_out (s->out.voice,0 ); }
Signature · 1 line
2.51.0
PATCH 31/43 hw/audio: replace AUD_log() usage
In reply to [email protected]From: Marc-André Lureau <[email protected]>
AUD_log() is just printf(stderr, "prefix: "..), we can use error_report() or warn_report() appropriately instead.
Ideally it should be converted to traces, but there are many places to convert, this is left for another day.
Avoid bit-rot by using conditionals.
The patch could be splitted if necessary.
--- hw/audio/ac97.c | 120 ++++++++++++++++++++++----------------------- hw/audio/adlib.c | 20 +++----- hw/audio/cs4231a.c | 40 +++++++-------- hw/audio/es1370.c | 24 ++++----- hw/audio/gus.c | 21 ++++---- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 93 +++++++++++++++++------------------ 7 files changed, 151 insertions(+), 169 deletions(-)
hw/audio/ac97.c +59 -61
@@ -26,6 +26,7 @@#include "qemu/module.h" #include "system/dma.h" #include "qom/object.h" +#include "qemu/error-report.h" #include "ac97.h" #define SOFT_VOLUME
@@ -141,11 +142,8 @@ enum {BUP_LAST =2 }; -#ifdef DEBUG_AC97 -#define dolog (...) AUD_log("ac97", __VA_ARGS__) -#else -#define dolog (...) -#endif +#define DEBUG_AC97 0 +#define dolog (fmt, ...) do { if (DEBUG_AC97) error_report("ac97: " fmt, ##__VA_ARGS__); } while (0)#define MKREGS (prefix, start) \ enum { \
@@ -190,7 +188,7 @@ static void fetch_bd(AC97LinkState *s, AC97BusMasterRegs *r) r->bd.addr =le32_to_cpu (*(uint32_t *) &b[0 ]) & ~3 ; r->bd.ctl_len =le32_to_cpu (*(uint32_t *) &b[4 ]); r->picb = r->bd.ctl_len &0xffff ; -dolog ("bd %2d addr=0x%x ctl=0x%06x len=0x%x(%d bytes)\n" , +dolog ("bd %2d addr=0x%x ctl=0x%06x len=0x%x(%d bytes)" , r->civ, r->bd.addr, r->bd.ctl_len >>16 , r->bd.ctl_len &0xffff , (r->bd.ctl_len &0xffff ) <<1 ); }
@@ -222,7 +220,7 @@ static void update_sr(AC97LinkState *s, AC97BusMasterRegs *r, uint32_t new_sr) r->sr = new_sr; -dolog ("IOC%d LVB%d sr=0x%x event=%d level=%d\n" , +dolog ("IOC%d LVB%d sr=0x%x event=%d level=%d" , r->sr &SR_BCIS , r->sr &SR_LVBCI , r->sr, event, level);if (!event) {
@@ -231,11 +229,11 @@ static void update_sr(AC97LinkState *s, AC97BusMasterRegs *r, uint32_t new_sr)if (level) { s->glob_sta |= masks[r - s->bm_regs]; -dolog ("set irq level=1\n" ); +dolog ("set irq level=1" );pci_irq_assert (&s->dev); }else { s->glob_sta &= ~masks[r - s->bm_regs]; -dolog ("set irq level=0\n" ); +dolog ("set irq level=0" );pci_irq_deassert (&s->dev); } }
@@ -256,14 +254,14 @@ static void voice_set_active(AC97LinkState *s, int bm_index, int on)break ;default : -AUD_log ("ac97" ,"invalid bm_index(%d) in voice_set_active" , bm_index); +error_report ("ac97: invalid bm_index(%d) in voice_set_active" , bm_index);break ; } }static void reset_bm_regs (AC97LinkState *s,AC97BusMasterRegs *r) { -dolog ("reset_bm_regs\n" ); +dolog ("reset_bm_regs" ); r->bdbar =0 ; r->civ =0 ; r->lvi =0 ;
@@ -281,7 +279,7 @@ static void reset_bm_regs(AC97LinkState *s, AC97BusMasterRegs *r)static void mixer_store (AC97LinkState *s,uint32_t i,uint16_t v) {if (i +2 >sizeof (s->mixer_data)) { -dolog ("mixer_store: index %d out of bounds %zd\n" , +dolog ("mixer_store: index %d out of bounds %zd" , i,sizeof (s->mixer_data));return ; }
@@ -295,7 +293,7 @@ static uint16_t mixer_load(AC97LinkState *s, uint32_t i)uint16_t val =0xffff ;if (i +2 >sizeof (s->mixer_data)) { -dolog ("mixer_load: index %d out of bounds %zd\n" , +dolog ("mixer_load: index %d out of bounds %zd" , i,sizeof (s->mixer_data)); }else { val = s->mixer_data[i +0 ] | (s->mixer_data[i +1 ] <<8 );
@@ -460,7 +458,7 @@ static void mixer_reset(AC97LinkState *s) {uint8_t active[LAST_INDEX ]; -dolog ("mixer_reset\n" ); +dolog ("mixer_reset" );memset (s->mixer_data,0 ,sizeof (s->mixer_data));memset (active,0 ,sizeof (active));mixer_store (s, AC97_Reset,0x0000 );/* 6940 */
@@ -508,7 +506,7 @@ static void mixer_reset(AC97LinkState *s)static uint32_t nam_readb (void *opaque,uint32_t addr) {AC97LinkState *s = opaque; -dolog ("U nam readb 0x%x\n" , addr); +dolog ("U nam readb 0x%x" , addr); s->cas =0 ;return ~0U ; }
@@ -523,7 +521,7 @@ static uint32_t nam_readw(void *opaque, uint32_t addr)static uint32_t nam_readl (void *opaque,uint32_t addr) {AC97LinkState *s = opaque; -dolog ("U nam readl 0x%x\n" , addr); +dolog ("U nam readl 0x%x" , addr); s->cas =0 ;return ~0U ; }
@@ -535,7 +533,7 @@ static uint32_t nam_readl(void *opaque, uint32_t addr)static void nam_writeb (void *opaque,uint32_t addr,uint32_t val) {AC97LinkState *s = opaque; -dolog ("U nam writeb 0x%x <- 0x%x\n" , addr, val); +dolog ("U nam writeb 0x%x <- 0x%x" , addr, val); s->cas =0 ; }
@@ -563,10 +561,10 @@ static void nam_writew(void *opaque, uint32_t addr, uint32_t val)break ;case AC97_Vendor_ID1:case AC97_Vendor_ID2: -dolog ("Attempt to write vendor ID to 0x%x\n" , val); +dolog ("Attempt to write vendor ID to 0x%x" , val);break ;case AC97_Extended_Audio_ID: -dolog ("Attempt to write extended audio ID to 0x%x\n" , val); +dolog ("Attempt to write extended audio ID to 0x%x" , val);break ;case AC97_Extended_Audio_Ctrl_Stat:if (!(val &EACS_VRA )) {
@@ -579,36 +577,36 @@ static void nam_writew(void *opaque, uint32_t addr, uint32_t val)mixer_store (s, AC97_MIC_ADC_Rate,0xbb80 );open_voice (s,MC_INDEX ,48000 ); } -dolog ("Setting extended audio control to 0x%x\n" , val); +dolog ("Setting extended audio control to 0x%x" , val);mixer_store (s, AC97_Extended_Audio_Ctrl_Stat, val);break ;case AC97_PCM_Front_DAC_Rate:if (mixer_load (s, AC97_Extended_Audio_Ctrl_Stat) &EACS_VRA ) {mixer_store (s, addr, val); -dolog ("Set front DAC rate to %d\n" , val); +dolog ("Set front DAC rate to %d" , val);open_voice (s,PO_INDEX , val); }else { -dolog ("Attempt to set front DAC rate to %d, but VRA is not set\n" , +dolog ("Attempt to set front DAC rate to %d, but VRA is not set" , val); }break ;case AC97_MIC_ADC_Rate:if (mixer_load (s, AC97_Extended_Audio_Ctrl_Stat) &EACS_VRM ) {mixer_store (s, addr, val); -dolog ("Set MIC ADC rate to %d\n" , val); +dolog ("Set MIC ADC rate to %d" , val);open_voice (s,MC_INDEX , val); }else { -dolog ("Attempt to set MIC ADC rate to %d, but VRM is not set\n" , +dolog ("Attempt to set MIC ADC rate to %d, but VRM is not set" , val); }break ;case AC97_PCM_LR_ADC_Rate:if (mixer_load (s, AC97_Extended_Audio_Ctrl_Stat) &EACS_VRA ) {mixer_store (s, addr, val); -dolog ("Set front LR ADC rate to %d\n" , val); +dolog ("Set front LR ADC rate to %d" , val);open_voice (s,PI_INDEX , val); }else { -dolog ("Attempt to set LR ADC rate to %d, but VRA is not set\n" , +dolog ("Attempt to set LR ADC rate to %d, but VRA is not set" , val); }break ;
@@ -630,7 +628,7 @@ static void nam_writew(void *opaque, uint32_t addr, uint32_t val)/* None of the features in these regs are emulated, so they are RO */ break ;default : -dolog ("U nam writew 0x%x <- 0x%x\n" , addr, val); +dolog ("U nam writew 0x%x <- 0x%x" , addr, val);mixer_store (s, addr, val);break ; }
@@ -639,7 +637,7 @@ static void nam_writew(void *opaque, uint32_t addr, uint32_t val)static void nam_writel (void *opaque,uint32_t addr,uint32_t val) {AC97LinkState *s = opaque; -dolog ("U nam writel 0x%x <- 0x%x\n" , addr, val); +dolog ("U nam writel 0x%x <- 0x%x" , addr, val); s->cas =0 ; }
@@ -655,7 +653,7 @@ static uint32_t nabm_readb(void *opaque, uint32_t addr)switch (addr) {case CAS : -dolog ("CAS %d\n" , s->cas); +dolog ("CAS %d" , s->cas); val = s->cas; s->cas =1 ;break ;
@@ -664,38 +662,38 @@ static uint32_t nabm_readb(void *opaque, uint32_t addr)case MC_CIV : r = &s->bm_regs[GET_BM (addr)]; val = r->civ; -dolog ("CIV[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("CIV[%d] -> 0x%x" ,GET_BM (addr), val);break ;case PI_LVI :case PO_LVI :case MC_LVI : r = &s->bm_regs[GET_BM (addr)]; val = r->lvi; -dolog ("LVI[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("LVI[%d] -> 0x%x" ,GET_BM (addr), val);break ;case PI_PIV :case PO_PIV :case MC_PIV : r = &s->bm_regs[GET_BM (addr)]; val = r->piv; -dolog ("PIV[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("PIV[%d] -> 0x%x" ,GET_BM (addr), val);break ;case PI_CR :case PO_CR :case MC_CR : r = &s->bm_regs[GET_BM (addr)]; val = r->cr; -dolog ("CR[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("CR[%d] -> 0x%x" ,GET_BM (addr), val);break ;case PI_SR :case PO_SR :case MC_SR : r = &s->bm_regs[GET_BM (addr)]; val = r->sr &0xff ; -dolog ("SRb[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("SRb[%d] -> 0x%x" ,GET_BM (addr), val);break ;default : -dolog ("U nabm readb 0x%x -> 0x%x\n" , addr, val); +dolog ("U nabm readb 0x%x -> 0x%x" , addr, val);break ; }return val;
@@ -713,17 +711,17 @@ static uint32_t nabm_readw(void *opaque, uint32_t addr)case MC_SR : r = &s->bm_regs[GET_BM (addr)]; val = r->sr; -dolog ("SR[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("SR[%d] -> 0x%x" ,GET_BM (addr), val);break ;case PI_PICB :case PO_PICB :case MC_PICB : r = &s->bm_regs[GET_BM (addr)]; val = r->picb; -dolog ("PICB[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("PICB[%d] -> 0x%x" ,GET_BM (addr), val);break ;default : -dolog ("U nabm readw 0x%x -> 0x%x\n" , addr, val); +dolog ("U nabm readw 0x%x -> 0x%x" , addr, val);break ; }return val;
@@ -741,14 +739,14 @@ static uint32_t nabm_readl(void *opaque, uint32_t addr)case MC_BDBAR : r = &s->bm_regs[GET_BM (addr)]; val = r->bdbar; -dolog ("BMADDR[%d] -> 0x%x\n" ,GET_BM (addr), val); +dolog ("BMADDR[%d] -> 0x%x" ,GET_BM (addr), val);break ;case PI_CIV :case PO_CIV :case MC_CIV : r = &s->bm_regs[GET_BM (addr)]; val = r->civ | (r->lvi <<8 ) | (r->sr <<16 ); -dolog ("CIV LVI SR[%d] -> 0x%x, 0x%x, 0x%x\n" ,GET_BM (addr), +dolog ("CIV LVI SR[%d] -> 0x%x, 0x%x, 0x%x" ,GET_BM (addr), r->civ, r->lvi, r->sr);break ;case PI_PICB :
@@ -756,19 +754,19 @@ static uint32_t nabm_readl(void *opaque, uint32_t addr)case MC_PICB : r = &s->bm_regs[GET_BM (addr)]; val = r->picb | (r->piv <<16 ) | (r->cr <<24 ); -dolog ("PICB PIV CR[%d] -> 0x%x 0x%x 0x%x 0x%x\n" ,GET_BM (addr), +dolog ("PICB PIV CR[%d] -> 0x%x 0x%x 0x%x 0x%x" ,GET_BM (addr), val, r->picb, r->piv, r->cr);break ;case GLOB_CNT : val = s->glob_cnt; -dolog ("glob_cnt -> 0x%x\n" , val); +dolog ("glob_cnt -> 0x%x" , val);break ;case GLOB_STA : val = s->glob_sta |GS_S0CR ; -dolog ("glob_sta -> 0x%x\n" , val); +dolog ("glob_sta -> 0x%x" , val);break ;default : -dolog ("U nabm readl 0x%x -> 0x%x\n" , addr, val); +dolog ("U nabm readl 0x%x -> 0x%x" , addr, val);break ; }return val;
@@ -795,7 +793,7 @@ static void nabm_writeb(void *opaque, uint32_t addr, uint32_t val)fetch_bd (s, r); } r->lvi = val %32 ; -dolog ("LVI[%d] <- 0x%x\n" ,GET_BM (addr), val); +dolog ("LVI[%d] <- 0x%x" ,GET_BM (addr), val);break ;case PI_CR :case PO_CR :
@@ -816,7 +814,7 @@ static void nabm_writeb(void *opaque, uint32_t addr, uint32_t val)voice_set_active (s, r - s->bm_regs,1 ); } } -dolog ("CR[%d] <- 0x%x (cr 0x%x)\n" ,GET_BM (addr), val, r->cr); +dolog ("CR[%d] <- 0x%x (cr 0x%x)" ,GET_BM (addr), val, r->cr);break ;case PI_SR :case PO_SR :
@@ -824,10 +822,10 @@ static void nabm_writeb(void *opaque, uint32_t addr, uint32_t val) r = &s->bm_regs[GET_BM (addr)]; r->sr |= val & ~(SR_RO_MASK |SR_WCLEAR_MASK );update_sr (s, r, r->sr & ~(val &SR_WCLEAR_MASK )); -dolog ("SR[%d] <- 0x%x (sr 0x%x)\n" ,GET_BM (addr), val, r->sr); +dolog ("SR[%d] <- 0x%x (sr 0x%x)" ,GET_BM (addr), val, r->sr);break ;default : -dolog ("U nabm writeb 0x%x <- 0x%x\n" , addr, val); +dolog ("U nabm writeb 0x%x <- 0x%x" , addr, val);break ; } }
@@ -844,10 +842,10 @@ static void nabm_writew(void *opaque, uint32_t addr, uint32_t val) r = &s->bm_regs[GET_BM (addr)]; r->sr |= val & ~(SR_RO_MASK |SR_WCLEAR_MASK );update_sr (s, r, r->sr & ~(val &SR_WCLEAR_MASK )); -dolog ("SR[%d] <- 0x%x (sr 0x%x)\n" ,GET_BM (addr), val, r->sr); +dolog ("SR[%d] <- 0x%x (sr 0x%x)" ,GET_BM (addr), val, r->sr);break ;default : -dolog ("U nabm writew 0x%x <- 0x%x\n" , addr, val); +dolog ("U nabm writew 0x%x <- 0x%x" , addr, val);break ; } }
@@ -863,22 +861,22 @@ static void nabm_writel(void *opaque, uint32_t addr, uint32_t val)case MC_BDBAR : r = &s->bm_regs[GET_BM (addr)]; r->bdbar = val & ~3 ; -dolog ("BDBAR[%d] <- 0x%x (bdbar 0x%x)\n" ,GET_BM (addr), val, r->bdbar); +dolog ("BDBAR[%d] <- 0x%x (bdbar 0x%x)" ,GET_BM (addr), val, r->bdbar);break ;case GLOB_CNT :/* TODO: Handle WR or CR being set (warm/cold reset requests) */ if (!(val & (GC_WR |GC_CR ))) { s->glob_cnt = val &GC_VALID_MASK ; } -dolog ("glob_cnt <- 0x%x (glob_cnt 0x%x)\n" , val, s->glob_cnt); +dolog ("glob_cnt <- 0x%x (glob_cnt 0x%x)" , val, s->glob_cnt);break ;case GLOB_STA : s->glob_sta &= ~(val &GS_WCLEAR_MASK ); s->glob_sta |= (val & ~(GS_WCLEAR_MASK |GS_RO_MASK )) &GS_VALID_MASK ; -dolog ("glob_sta <- 0x%x (glob_sta 0x%x)\n" , val, s->glob_sta); +dolog ("glob_sta <- 0x%x (glob_sta 0x%x)" , val, s->glob_sta);break ;default : -dolog ("U nabm writel 0x%x <- 0x%x\n" , addr, val); +dolog ("U nabm writel 0x%x <- 0x%x" , addr, val);break ; } }
@@ -903,7 +901,7 @@ static int write_audio(AC97LinkState *s, AC97BusMasterRegs *r, to_copy =MIN (temp,sizeof (tmpbuf));pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =AUD_write (s->voice_po, tmpbuf, to_copy); -dolog ("write_audio max=%x to_copy=%x copied=%x\n" , +dolog ("write_audio max=%x to_copy=%x copied=%x" , max, to_copy, copied);if (!copied) { *stop =1 ;
@@ -916,7 +914,7 @@ static int write_audio(AC97LinkState *s, AC97BusMasterRegs *r,if (!temp) {if (to_copy <4 ) { -dolog ("whoops\n" ); +dolog ("whoops" ); s->last_samp =0 ; }else { s->last_samp = *(uint32_t *)&tmpbuf[to_copy -4 ];
@@ -929,7 +927,7 @@ static int write_audio(AC97LinkState *s, AC97BusMasterRegs *r,static void write_bup (AC97LinkState *s,int elapsed) { -dolog ("write_bup\n" ); +dolog ("write_bup" );if (!(s->bup_flag &BUP_SET )) {if (s->bup_flag &BUP_LAST ) {int i;
@@ -997,7 +995,7 @@ static void transfer_audio(AC97LinkState *s, int index, int elapsed)int stop =0 ;if (s->invalid_freq[index]) { -AUD_log ("ac97" ,"attempt to use voice %d with invalid frequency %d\n" , +error_report ("ac97: attempt to use voice %d with invalid frequency %d" , index, s->invalid_freq[index]);return ; }
@@ -1017,12 +1015,12 @@ static void transfer_audio(AC97LinkState *s, int index, int elapsed)int temp;if (!r->bd_valid) { -dolog ("invalid bd\n" ); +dolog ("invalid bd" );fetch_bd (s, r); }if (!r->picb) { -dolog ("fresh bd %d is empty 0x%x 0x%x\n" , +dolog ("fresh bd %d is empty 0x%x 0x%x" , r->civ, r->bd.addr, r->bd.ctl_len);if (r->civ == r->lvi) { r->sr |=SR_DCH ;/* CELV? */
@@ -1059,7 +1057,7 @@ static void transfer_audio(AC97LinkState *s, int index, int elapsed) }if (r->civ == r->lvi) { -dolog ("Underrun civ (%d) == lvi (%d)\n" , r->civ, r->lvi); +dolog ("Underrun civ (%d) == lvi (%d)" , r->civ, r->lvi); new_sr |=SR_LVBCI |SR_DCH |SR_CELV ; stop =1 ;
hw/audio/adlib.c +8 -12
@@ -29,24 +29,20 @@#include "audio/audio.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "qemu/error-report.h" #include "qom/object.h" -//#define DEBUG +#define DEBUG 0#define ADLIB_KILL_TIMERS 1#define ADLIB_DESC "Yamaha YM3812 (OPL2)" -#ifdef DEBUG +#if DEBUG #include "qemu/timer.h" #endif -#define dolog (...) AUD_log ("adlib", __VA_ARGS__) -#ifdef DEBUG -#define ldebug (...) dolog (__VA_ARGS__) -#else -#define ldebug (...) -#endif +#define ldebug (fmt, ...) do { if (DEBUG) error_report("adlib: " fmt, ##__VA_ARGS__); } while(0)#include "fmopl.h" #define SHIFT 1
@@ -64,7 +60,7 @@ struct AdlibState {int enabled;int active;int bufpos; -#ifdef DEBUG +#if DEBUG int64_t exp[2 ];#endif int16_t *mixbuf;
@@ -92,7 +88,7 @@ static void adlib_kill_timers (AdlibState *s) delta =AUD_get_elapsed_usec_out (s->voice, &s->ats);ldebug ( -"delta = %f dexp = %f expired => %d\n" , +"delta = %f dexp = %f expired => %d" , delta /1000000.0 , s->dexp[i] /1000000.0 , delta >= s->dexp[i]
@@ -131,7 +127,7 @@ static void timer_handler (void *opaque, int c, double interval_Sec) {AdlibState *s = opaque;unsigned n = c &1 ; -#ifdef DEBUG +#if DEBUG double interval;int64_t exp;#endif
@@ -142,7 +138,7 @@ static void timer_handler (void *opaque, int c, double interval_Sec) } s->ticking[n] =1 ; -#ifdef DEBUG +#if DEBUG interval =NANOSECONDS_PER_SECOND * interval_Sec; exp =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + interval; s->exp[n] = exp;
hw/audio/cs4231a.c +18 -22
@@ -30,7 +30,7 @@#include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "qemu/module.h" -#include "qemu/timer.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "qom/object.h"
@@ -43,21 +43,17 @@More... */ -/* #define DEBUG */ +#define DEBUG 0/* #define DEBUG_XLAW */ static struct {int aci_counter; } conf = {1 }; -#ifdef DEBUG -#define dolog (...) AUD_log ("cs4231a", __VA_ARGS__) -#else -#define dolog (...) -#endif +#define dolog (fmt, ...) do { if (DEBUG) error_report("cs4231a: " fmt, ##__VA_ARGS__); } while(0) -#define lwarn (...) AUD_log ("cs4231a", "warning: " __VA_ARGS__) -#define lerr (...) AUD_log ("cs4231a", "error: " __VA_ARGS__) +#define lwarn (fmt, ...) warn_report("cs4231a: " fmt, ##__VA_ARGS__) +#define lerr (fmt, ...) error_report("cs4231a: " fmt, ##__VA_ARGS__)#define CS_REGS 16#define CS_DREGS 32
@@ -284,7 +280,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) as.freq = freqs[xtal][(val >>1 ) &7 ];if (as.freq ==-1 ) { -lerr ("unsupported frequency (val=%#x)\n" , val); +lerr ("unsupported frequency (val=%#x)" , val); goto error; }
@@ -319,11 +315,11 @@ static void cs_reset_voices (CSState *s, uint32_t val)case 7 :case 4 : -lerr ("attempt to use reserved format value (%#x)\n" , val); +lerr ("attempt to use reserved format value (%#x)" , val); goto error;case 5 : -lerr ("ADPCM 4 bit IMA compatible format is not supported\n" ); +lerr ("ADPCM 4 bit IMA compatible format is not supported" ); goto error; }
@@ -393,7 +389,7 @@ static uint64_t cs_read (void *opaque, hwaddr addr, unsigned size) ret = s->regs[saddr];break ; } -dolog ("read %d:%d -> %d\n" , saddr, iaddr, ret); +dolog ("read %d:%d -> %d" , saddr, iaddr, ret);return ret; }
@@ -425,7 +421,7 @@ static void cs_write (void *opaque, hwaddr addr,case RESERVED :case RESERVED_2 :case RESERVED_3 : -lwarn ("attempt to write %#x to reserved indirect register %d\n" , +lwarn ("attempt to write %#x to reserved indirect register %d" , val, iaddr);break ;
@@ -439,7 +435,7 @@ static void cs_write (void *opaque, hwaddr addr,cs_reset_voices (s, val); }else { -lwarn ("[P]MCE(%#x, %#x) is not set, val=%#x\n" , +lwarn ("[P]MCE(%#x, %#x) is not set, val=%#x" , s->regs[Index_Address], s->dregs[Alternate_Feature_Status], val);
@@ -453,7 +449,7 @@ static void cs_write (void *opaque, hwaddr addr, val &= ~(1 <<5 );/* D5 is reserved */ s->dregs[iaddr] = val;if (val &PPIO ) { -lwarn ("PIO is not supported (%#x)\n" , val); +lwarn ("PIO is not supported (%#x)" , val);break ; }if (val &PEN ) {
@@ -472,11 +468,11 @@ static void cs_write (void *opaque, hwaddr addr,break ;case Error_Status_And_Initialization: -lwarn ("attempt to write to read only register %d\n" , iaddr); +lwarn ("attempt to write to read only register %d" , iaddr);break ;case MODE_And_ID: -dolog ("val=%#x\n" , val); +dolog ("val=%#x" , val);if (val &MODE2 ) s->dregs[iaddr] |=MODE2 ;else
@@ -485,7 +481,7 @@ static void cs_write (void *opaque, hwaddr addr,case Alternate_Feature_Enable_I:if (val &TE ) -lerr ("timer is not yet supported\n" ); +lerr ("timer is not yet supported" ); s->dregs[iaddr] = val;break ;
@@ -499,7 +495,7 @@ static void cs_write (void *opaque, hwaddr addr,break ;case Version_Chip_ID: -lwarn ("write to Version_Chip_ID register %#x\n" , val); +lwarn ("write to Version_Chip_ID register %#x" , val); s->dregs[iaddr] = val;break ;
@@ -507,7 +503,7 @@ static void cs_write (void *opaque, hwaddr addr, s->dregs[iaddr] = val;break ; } -dolog ("written value %#x to indirect register %d\n" , val, iaddr); +dolog ("written value %#x to indirect register %d" , val, iaddr);break ;case Status:
@@ -519,7 +515,7 @@ static void cs_write (void *opaque, hwaddr addr,break ;case PIO_Data: -lwarn ("attempt to write value %#x to PIO register\n" , val); +lwarn ("attempt to write value %#x to PIO register" , val);break ; } }
hw/audio/es1370.c +12 -12
@@ -32,7 +32,7 @@#include "migration/vmstate.h" #include "qemu/cutils.h" #include "qemu/module.h" -#include "system/dma.h" +#include "qemu/error-report.h" #include "qom/object.h" #include "trace.h"
@@ -190,7 +190,7 @@ static void print_ctl(uint32_t val)a (CDC_EN );a (SERR_DIS );#undef a - AUD_log("es1370", "ctl - PCLKDIV %d(DAC2 freq %d), freq %d,%s\n", + error_report("es1370: ctl - PCLKDIV %d(DAC2 freq %d), freq %d,%s\n", (val & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV, DAC2_DIVTOSR((val & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV), dac1_samplerate[(val & CTRL_WTSRSEL) >> CTRL_SH_WTSRSEL],
@@ -226,7 +226,7 @@ static void print_sctl(uint32_t val) }#undef b#undef a - AUD_log("es1370", + error_report("es1370: " "%s p2_end_inc %d, p2_st_inc %d," " r1_fmt %s, p2_fmt %s, p1_fmt %s\n", buf,
@@ -238,10 +238,10 @@ static void print_sctl(uint32_t val) } } -#define lwarn (...) \ +#define lwarn (fmt, ...) \ do { \ if (VERBOSE_ES1370) { \ - AUD_log("es1370: warning", __VA_ARGS__); \ + error_report("es1370: " fmt, ##__VA_ARGS__); \ } \ } while (0)
@@ -502,10 +502,10 @@ static void es1370_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)break ;case ES1370_REG_PHANTOM_FRAMECNT : -lwarn ("writing to phantom frame count 0x%" PRIx64"\n" , val); +lwarn ("writing to phantom frame count 0x%" PRIx64, val);break ;case ES1370_REG_PHANTOM_FRAMEADR : -lwarn ("writing to phantom frame address 0x%" PRIx64"\n" , val); +lwarn ("writing to phantom frame address 0x%" PRIx64, val);break ;case ES1370_REG_ADC_FRAMECNT :
@@ -522,7 +522,7 @@ static void es1370_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)break ;default : -lwarn ("writel 0x%" PRIx64" <- 0x%" PRIx64"\n" , addr, val); +lwarn ("writel 0x%" PRIx64" <- 0x%" PRIx64, addr, val);break ; } }
@@ -586,16 +586,16 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)case ES1370_REG_PHANTOM_FRAMECNT : val = ~0U ; -lwarn ("reading from phantom frame count\n" ); +lwarn ("reading from phantom frame count" );break ;case ES1370_REG_PHANTOM_FRAMEADR : val = ~0U ; -lwarn ("reading from phantom frame address\n" ); +lwarn ("reading from phantom frame address" );break ;default : val = ~0U ; -lwarn ("readl 0x%" PRIx64" -> 0x%x\n" , addr, val); +lwarn ("readl 0x%" PRIx64" -> 0x%x" , addr, val);break ; }return val;
@@ -677,7 +677,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,* when the sample count reaches zero) or 1 for stop mode (set * interrupt and stop recording). */ -AUD_log ("es1370: warning" ,"non looping mode\n" ); +warn_report ("es1370: non looping mode" ); }else { d->frame_cnt = size;
hw/audio/gus.c +9 -12
@@ -32,15 +32,12 @@#include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "gusemu.h" -#include "gustate.h" +#include "qemu/error-report.h" #include "qom/object.h" -#define dolog (...) AUD_log ("audio", __VA_ARGS__) -#ifdef DEBUG -#define ldebug (...) dolog (__VA_ARGS__) -#else -#define ldebug (...) -#endif +#define DEBUG 0 + +#define ldebug (fmt, ...) do { if (DEBUG) error_report("gus: " fmt, ##__VA_ARGS__); } while (0)#define TYPE_GUS "gus"OBJECT_DECLARE_SIMPLE_TYPE (GUSState,GUS )
@@ -154,14 +151,14 @@ int GUS_irqrequest (GUSEmuState *emu, int hwirq, int n)/* qemu_irq_lower (s->pic); */ qemu_irq_raise (s->pic); s->irqs += n; -ldebug ("irqrequest %d %d %d\n" , hwirq, n, s->irqs); +ldebug ("irqrequest %d %d %d" , hwirq, n, s->irqs);return n; }void GUS_irqclear (GUSEmuState *emu,int hwirq) {GUSState *s = emu->opaque; -ldebug ("irqclear %d %d\n" , hwirq, s->irqs); +ldebug ("irqclear %d %d" , hwirq, s->irqs);qemu_irq_lower (s->pic); s->irqs -=1 ;#ifdef IRQ_STORM
@@ -175,7 +172,7 @@ void GUS_dmarequest (GUSEmuState *emu) {GUSState *s = emu->opaque;IsaDmaClass *k =ISADMA_GET_CLASS (s->isa_dma); -ldebug ("dma request %d\n" , der->gusdma); +ldebug ("dma request %d" , s->emu.gusdma); k->hold_DREQ (s->isa_dma, s->emu.gusdma); }
@@ -186,13 +183,13 @@ static int GUS_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len) QEMU_UNINITIALIZED char tmpbuf[4096];int pos = dma_pos, mode, left = dma_len - dma_pos; -ldebug ("read DMA %#x %d\n" , dma_pos, dma_len); +ldebug ("read DMA %#x %d" , dma_pos, dma_len); mode = k->has_autoinitialization (s->isa_dma, s->emu.gusdma);while (left) {int to_copy =MIN ((size_t ) left,sizeof (tmpbuf));int copied; -ldebug ("left=%d to_copy=%d pos=%d\n" , left, to_copy, pos); +ldebug ("left=%d to_copy=%d pos=%d" , left, to_copy, pos); copied = k->read_memory (s->isa_dma, nchan, tmpbuf, pos, to_copy);gus_dma_transferdata (&s->emu, tmpbuf, copied, left == copied); left -= copied;
hw/audio/pcspk.c +1 -1
@@ -124,7 +124,7 @@ static int pcspk_audio_init(PCSpkState *s) s->voice =AUD_open_out (&s->card, s->voice, s_spk, s, pcspk_callback, &as);if (!s->voice) { -AUD_log (s_spk,"Could not open voice\n" ); +error_report ("pcspk: Could not open voice" );return -1 ; }
hw/audio/sb16.c +44 -49
327 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [PATCH 31/43] hw/audio: replace AUD_log() usage
Quoted 13 lines · On 21/10/25 11:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
AUD_log()is justprintf(stderr, "prefix: "..), we can useerror_report()orwarn_report()appropriately instead.Ideally it should be converted to traces, but there are many places to convert, this is left for another day.
Avoid bit-rot by using conditionals.
The patch could be splitted if necessary.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 9 lines
--- hw/audio/ac97.c | 120 ++++++++++++++++++++++----------------------- hw/audio/adlib.c | 20 +++----- hw/audio/cs4231a.c | 40 +++++++-------- hw/audio/es1370.c | 24 ++++----- hw/audio/gus.c | 21 ++++---- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 93 +++++++++++++++++------------------ 7 files changed, 151 insertions(+), 169 deletions(-)
PATCH 32/43 audio/replay: fix type punning
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 6 ++++-- audio/mixeng.h | 1 - include/system/replay.h | 3 ++- audio/mixeng.c | 6 ++---- replay/replay-audio.c | 2 +- replay/stubs-system.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
audio/audio.h +4 -2
@@ -161,9 +161,11 @@ int wav_start_capture(AudioState *state, CaptureState *s, const char *path,void audio_cleanup (void ); -void audio_sample_to_uint64 (const void *samples,int pos, +typedef struct st_sample st_sample ; + +void audio_sample_to_uint64 (const st_sample *sample,int pos,uint64_t *left,uint64_t *right); -void audio_sample_from_uint64 (void *samples,int pos, +void audio_sample_from_uint64 (st_sample *sample,int pos,uint64_t left,uint64_t right);void audio_add_audiodev (Audiodev *audio);
audio/mixeng.h +0 -1
@@ -33,7 +33,6 @@ struct st_sample { mixeng_real l; mixeng_real r; };struct mixeng_volume {int mute;int64_t r;int64_t l; };struct st_sample {int64_t l;int64_t r; };#endif -typedef struct st_sample st_sample ;typedef void (t_sample ) (struct st_sample *dst,const void *src,int samples);typedef void (f_sample ) (void *dst,const struct st_sample *src,int samples);
include/system/replay.h +2 -1
@@ -16,6 +16,7 @@#include "qapi/qapi-types-run-state.h" #include "qapi/qapi-types-ui.h" #include "block/aio.h" +#include "audio/audio.h" /* replay clock kinds */ enum ReplayClockKind {
@@ -165,7 +166,7 @@ void replay_net_packet_event(ReplayNetState *rns, unsigned flags,/*! Saves/restores number of played samples of audio out operation. */ void replay_audio_out (size_t *played);/*! Saves/restores recorded samples of audio in operation. */ -void replay_audio_in (size_t *recorded,void *samples,size_t *wpos,size_t size); +void replay_audio_in (size_t *recorded,st_sample *samples,size_t *wpos,size_t size);/* VM state operations */
audio/mixeng.c +2 -4
@@ -404,7 +404,7 @@ f_sample *mixeng_clip_float[2][2] = { } }; -void audio_sample_to_uint64 (const void *samples,int pos, +void audio_sample_to_uint64 (const st_sample *sample,int pos,uint64_t *left,uint64_t *right) {#ifdef FLOAT_MIXENG
@@ -412,14 +412,13 @@ void audio_sample_to_uint64(const void *samples, int pos, "Coreaudio and floating point samples are not supported by replay yet");abort ();#else -const struct st_sample *sample = samples; sample += pos; *left = sample->l; *right = sample->r;#endif } -void audio_sample_from_uint64 (void *samples,int pos, +void audio_sample_from_uint64 (st_sample *sample,int pos,uint64_t left,uint64_t right) {#ifdef FLOAT_MIXENG
@@ -427,7 +426,6 @@ void audio_sample_from_uint64(void *samples, int pos, "Coreaudio and floating point samples are not supported by replay yet");abort ();#else -struct st_sample *sample = samples; sample += pos; sample->l = left; sample->r = right;
replay/replay-audio.c +1 -1
@@ -35,7 +35,7 @@ void replay_audio_out(size_t *played) } } -void replay_audio_in (size_t *recorded,void *samples,size_t *wpos,size_t size) +void replay_audio_in (size_t *recorded,st_sample *samples,size_t *wpos,size_t size) {int pos;uint64_t left, right;
replay/stubs-system.c +1 -1
@@ -15,7 +15,7 @@ void replay_input_sync_event(void)void replay_add_blocker (const char *feature) { } -void replay_audio_in (size_t *recorded,void *samples,size_t *wpos,size_t size) +void replay_audio_in (size_t *recorded,st_sample *samples,size_t *wpos,size_t size) { }void replay_audio_out (size_t *played)
Signature · 1 line
2.51.0
PATCH 33/43 audio: move internal APIs to audio_int.h
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 21 --------------------- audio/audio_int.h | 22 ++++++++++++++++++++++ audio/audio-hmp-cmds.c | 2 +- audio/wavcapture.c | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-)
audio/audio.h +0 -21
@@ -38,15 +38,6 @@ typedef struct audsettings {int endianness; } audsettings; -audsettings audiodev_to_audsettings (AudiodevPerDirectionOptions *pdo); -int audioformat_bytes_per_sample (AudioFormat fmt); -int audio_buffer_frames (AudiodevPerDirectionOptions *pdo, -audsettings *as,int def_usecs); -int audio_buffer_samples (AudiodevPerDirectionOptions *pdo, -audsettings *as,int def_usecs); -int audio_buffer_bytes (AudiodevPerDirectionOptions *pdo, -audsettings *as,int def_usecs); - typedef enum { AUD_CNOTIFY_ENABLE, AUD_CNOTIFY_DISABLE
@@ -89,9 +80,6 @@ typedef struct QEMUAudioTimeStamp {uint64_t old_ts; } QEMUAudioTimeStamp; -void AUD_vlog (const char *cap, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); -void AUD_log (const char *cap, const char *fmt, ...) G_GNUC_PRINTF(2, 3); -bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp);void AUD_remove_card (QEMUSoundCard *card); CaptureVoiceOut *AUD_add_capture(
@@ -150,15 +138,6 @@ int AUD_is_active_in (SWVoiceIn *sw);void AUD_init_time_stamp_in (SWVoiceIn *sw,QEMUAudioTimeStamp *ts);uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw,QEMUAudioTimeStamp *ts); -static inline void *advance (void *p,int incr) -{ -uint8_t *d = p; -return (d + incr); -} - -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, -int freq,int bits,int nchannels); -void audio_cleanup (void );typedef struct st_sample st_sample ;
audio/audio_int.h +22 -0
@@ -29,12 +29,16 @@#define FLOAT_MIXENG /* #define RECIPROCAL */ #endif +#include "audio.h" #include "mixeng.h" #ifdef CONFIG_GIO #include <gio/gio.h> #endif +void AUD_vlog (const char *cap, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); +void AUD_log (const char *cap, const char *fmt, ...) G_GNUC_PRINTF(2, 3); +struct audio_pcm_ops ;struct audio_callback {
@@ -187,6 +191,24 @@ struct audio_pcm_ops {void (*volume_in)(HWVoiceIn *hw,Volume *vol); }; +audsettings audiodev_to_audsettings (AudiodevPerDirectionOptions *pdo); +int audioformat_bytes_per_sample (AudioFormat fmt); +int audio_buffer_frames (AudiodevPerDirectionOptions *pdo, +audsettings *as,int def_usecs); +int audio_buffer_samples (AudiodevPerDirectionOptions *pdo, +audsettings *as,int def_usecs); +int audio_buffer_bytes (AudiodevPerDirectionOptions *pdo, +audsettings *as,int def_usecs); + +static inline void *advance (void *p,int incr) +{ +uint8_t *d = p; +return (d + incr); +} + +int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int freq,int bits,int nchannels); +void audio_generic_run_buffer_in (HWVoiceIn *hw);void *audio_generic_get_buffer_in (HWVoiceIn *hw,size_t *size);void audio_generic_put_buffer_in (HWVoiceIn *hw,void *buf,size_t size);
audio/audio-hmp-cmds.c +1 -1
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "audio/audio.h" +#include "audio_int.h" #include "monitor/hmp.h" #include "monitor/monitor.h" #include "qapi/error.h"
audio/wavcapture.c +1 -1
@@ -1,7 +1,7 @@#include "qemu/osdep.h" #include "qemu/qemu-print.h" #include "qemu/error-report.h" -#include "audio.h" +#include "audio_int.h" typedef struct { FILE *f;
Signature · 1 line
2.51.0
PATCH 34/43 audio: rename AudioState -> AudioBE
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Naming is hard. But in general in QEMU, a host "backend" is the term used to fullfill the request made by the device "frontend".
Note that "audiodev" is the corresponding QAPI type name (or configuration).
--- audio/audio.h | 18 +++---- audio/audio_int.h | 20 +++---- audio/audio_template.h | 20 +++---- ui/vnc.h | 2 +- audio/alsaaudio.c | 2 +- audio/audio-hmp-cmds.c | 2 +- audio/audio.c | 90 ++++++++++++++++---------------- audio/dbusaudio.c | 8 +-- audio/ossaudio.c | 4 +- audio/wavcapture.c | 2 +- hw/audio/pcspk.c | 2 +- hw/core/machine.c | 2 +- hw/core/qdev-properties-system.c | 6 +-- ui/dbus.c | 8 +-- ui/vnc.c | 10 ++-- 15 files changed, 98 insertions(+), 98 deletions(-)
audio/audio.h +9 -9
@@ -64,15 +64,15 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; -typedef struct AudioStateClass AudioStateClass ; -struct AudioStateClass { +typedef struct AudioBEClass AudioBEClass ; +struct AudioBEClass {ObjectClass parent_class; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ;typedef struct QEMUSoundCard {char *name; -AudioState *state; +AudioBE *be;QLIST_ENTRY (QEMUSoundCard) entries; }QEMUSoundCard ;
@@ -83,7 +83,7 @@ typedef struct QEMUAudioTimeStamp {bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp);void AUD_remove_card (QEMUSoundCard *card);CaptureVoiceOut *AUD_add_capture ( -AudioState *s, +AudioBE *s,struct audsettings *as,struct audio_capture_ops *ops, void *opaque
@@ -154,14 +154,14 @@ void audio_create_default_audiodevs(void);void audio_init_audiodevs (void );void audio_help (void ); -AudioState *audio_state_by_name (const char *name,Error **errp); -AudioState *audio_get_default_audio_state (Error **errp); +AudioBE *audio_be_by_name (const char *name,Error **errp); +AudioBE *audio_get_default_audio_be (Error **errp);const char *audio_get_id (QEMUSoundCard *card);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) -#define TYPE_AUDIO_STATE "audio-state" -OBJECT_DECLARE_TYPE(AudioState, AudioStateClass, AUDIO_STATE) +#define TYPE_AUDIO_BE "audio-be" +OBJECT_DECLARE_TYPE(AudioBE, AudioBEClass, AUDIO_BE)#endif /* QEMU_AUDIO_H */
audio/audio_int.h +10 -10
@@ -57,7 +57,7 @@ struct audio_pcm_info {int swap_endianness; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ;typedef struct SWVoiceCap SWVoiceCap ; typedef struct STSampleBuffer {
@@ -66,7 +66,7 @@ typedef struct STSampleBuffer { } STSampleBuffer; typedef struct HWVoiceOut { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; int pending_disable;
@@ -87,7 +87,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; typedef struct HWVoiceIn { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; struct audio_pcm_info info;
@@ -109,7 +109,7 @@ typedef struct HWVoiceIn {struct SWVoiceOut {QEMUSoundCard *card; -AudioState *s; +AudioBE *s;struct audio_pcm_info info;t_sample *conv;STSampleBuffer resample_buf;
@@ -126,7 +126,7 @@ struct SWVoiceOut {struct SWVoiceIn {QEMUSoundCard *card; -AudioState *s; +AudioBE *s;int active;struct audio_pcm_info info;void *rate;
@@ -147,7 +147,7 @@ struct audio_driver {void *(*init) (Audiodev *,Error **);void (*fini) (void *);#ifdef CONFIG_GIO -void (*set_dbus_server) (AudioState *s,GDBusObjectManagerServer *manager,bool p2p); +void (*set_dbus_server) (AudioBE *s,GDBusObjectManagerServer *manager,bool p2p);#endif struct audio_pcm_ops *pcm_ops;int max_voices_out;
@@ -206,7 +206,7 @@ static inline void *advance (void *p, int incr)return (d + incr); } -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture (AudioBE *state,CaptureState *s,const char *path,int freq,int bits,int nchannels);void audio_generic_run_buffer_in (HWVoiceIn *hw);
@@ -238,7 +238,7 @@ struct SWVoiceCap {QLIST_ENTRY (SWVoiceCap) entries; }; -typedef struct AudioState { +typedef struct AudioBE { Object parent; struct audio_driver *drv;
@@ -258,7 +258,7 @@ typedef struct AudioState {bool timer_running;uint64_t timer_last;VMChangeStateEntry *vmse; -} AudioState; +} AudioBE;extern const struct mixeng_volume nominal_volume;
@@ -271,7 +271,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);int audio_bug (const char *funcname,int cond); -void audio_run (AudioState *s,const char *msg); +void audio_run (AudioBE *s,const char *msg);const char *audio_application_name (void );
audio/audio_template.h +10 -10
@@ -36,7 +36,7 @@#define HWBUF hw->conv_buf#endif -static void glue (audio_init_nb_voices_ ,TYPE )(AudioState *s, +static void glue (audio_init_nb_voices_ ,TYPE )(AudioBE *s,struct audio_driver *drv,int min_voices) {int max_voices =glue (drv->max_voices_,TYPE );
@@ -221,7 +221,7 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)static void glue (audio_pcm_hw_gc_ ,TYPE ) (HW **hwp) {HW *hw = *hwp; -AudioState *s = hw->s; +AudioBE *s = hw->s;if (!hw->sw_head.lh_first) {#ifdef DAC
@@ -236,12 +236,12 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } -static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioState *s,HW *hw) +static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioBE *s,HW *hw) {return hw ? hw->entries.le_next :glue (s->hw_head_,TYPE ).lh_first; } -static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioState *s,HW *hw) +static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioBE *s,HW *hw) {while ((hw =glue (audio_pcm_hw_find_any_,TYPE )(s, hw))) {if (hw->enabled) {
@@ -251,7 +251,7 @@ static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *hw)return NULL ; } -static HW *glue (audio_pcm_hw_find_specific_ ,TYPE )(AudioState *s,HW *hw, +static HW *glue (audio_pcm_hw_find_specific_ ,TYPE )(AudioBE *s,HW *hw,struct audsettings *as) {while ((hw =glue (audio_pcm_hw_find_any_,TYPE )(s, hw))) {
@@ -262,7 +262,7 @@ static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioState *s, HW *hw,return NULL ; } -static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioState *s, +static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;
@@ -398,7 +398,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)abort (); } -static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioState *s,struct audsettings *as) +static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;AudiodevPerDirectionOptions *pdo =glue (audio_get_pdo_,TYPE )(s->dev);
@@ -424,7 +424,7 @@ static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s, struct audsettings *as) }static SW *glue (audio_pcm_create_voice_pair_ ,TYPE )( -AudioState *s, +AudioBE *s,const char *sw_name,struct audsettings *as )
@@ -494,7 +494,7 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as ) { -AudioState *s; +AudioBE *s;AudiodevPerDirectionOptions *pdo;if (audio_bug (__func__, !card || !name || !callback_fn || !as)) {
@@ -503,7 +503,7 @@ SW *glue (AUD_open_, TYPE) ( goto fail; } - s = card->state; + s = card->be; pdo =glue (audio_get_pdo_,TYPE )(s->dev); ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",
ui/vnc.h +1 -1
@@ -184,7 +184,7 @@ struct VncDisplayVncDisplaySASL sasl;#endif -AudioState *audio_state; +AudioBE *audio_be;VMChangeStateEntry *vmstate_handler_entry; };
audio/alsaaudio.c +1 -1
@@ -41,7 +41,7 @@ struct pollhlp {struct pollfd *pfds;int count;int mask; -AudioState *s; +AudioBE *s; }; typedef struct ALSAVoiceOut {
audio/audio-hmp-cmds.c +1 -1
@@ -67,7 +67,7 @@ void hmp_wavcapture(Monitor *mon, const QDict *qdict)const char *audiodev =qdict_get_str (qdict,"audiodev" );CaptureState *s;Error *local_err =NULL ; -AudioState *as =audio_state_by_name (audiodev, &local_err); +AudioBE *as =audio_be_by_name (audiodev, &local_err);if (!as) {error_report_err (local_err);
audio/audio.c +45 -45
269 lines not on this page · raw message
audio/dbusaudio.c +4 -4
@@ -458,7 +458,7 @@ listener_in_vanished_cb(GDBusConnection *connection, } static gboolean -dbus_audio_register_listener(AudioState *s, +dbus_audio_register_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,
@@ -615,7 +615,7 @@ dbus_audio_register_listener(AudioState *s, } static gboolean -dbus_audio_register_out_listener(AudioState *s, +dbus_audio_register_out_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,
@@ -631,7 +631,7 @@ dbus_audio_register_out_listener(AudioState *s, } static gboolean -dbus_audio_register_in_listener(AudioState *s, +dbus_audio_register_in_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,
@@ -646,7 +646,7 @@ dbus_audio_register_in_listener(AudioState *s, }static void -dbus_audio_set_server (AudioState *s,GDBusObjectManagerServer *server,bool p2p) +dbus_audio_set_server (AudioBE *s,GDBusObjectManagerServer *server,bool p2p) {DBusAudio *da = s->drv_opaque;
audio/ossaudio.c +2 -2
@@ -107,13 +107,13 @@ static void oss_anal_close (int *fdp)static void oss_helper_poll_out (void *opaque) { -AudioState *s = opaque; +AudioBE *s = opaque;audio_run (s,"oss_poll_out" ); }static void oss_helper_poll_in (void *opaque) { -AudioState *s = opaque; +AudioBE *s = opaque;audio_run (s,"oss_poll_in" ); }
audio/wavcapture.c +1 -1
@@ -103,7 +103,7 @@ static struct capture_ops wav_capture_ops = { .info = wav_capture_info }; -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture (AudioBE *state,CaptureState *s,const char *path,int freq,int bits,int nchannels) {WAVState *wav;
hw/audio/pcspk.c +1 -1
@@ -188,7 +188,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &s->ioport, s->iobase); -if (s->card.state &&AUD_register_card (s_spk, &s->card, errp)) { +if (s->card.be &&AUD_register_card (s_spk, &s->card, errp)) {pcspk_audio_init (s); } }
hw/core/machine.c +1 -1
@@ -763,7 +763,7 @@ static void machine_set_audiodev(Object *obj, const char *value, {MachineState *ms =MACHINE (obj); -if (!audio_state_by_name (value, errp)) { +if (!audio_be_by_name (value, errp)) {return ; }
hw/core/qdev-properties-system.c +3 -3
@@ -499,16 +499,16 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, {const Property *prop = opaque;QEMUSoundCard *card =object_field_prop_ptr (obj, prop); -AudioState *state; +AudioBE *state; g_autofree char *str = NULL;if (!visit_type_str (v, name, &str, errp)) {return ; } - state =audio_state_by_name (str, errp); + state =audio_be_by_name (str, errp);if (state) { - card->state = state; + card->be = state; } }
ui/dbus.c +4 -4
@@ -220,16 +220,16 @@ dbus_display_complete(UserCreatable *uc, Error **errp) }if (dd->audiodev && *dd->audiodev) { -AudioState *audio_state =audio_state_by_name (dd->audiodev, errp); -if (!audio_state) { +AudioBE *audio_be =audio_be_by_name (dd->audiodev, errp); +if (!audio_be) {return ; } -if (!g_str_equal (audio_state->drv->name,"dbus" )) { +if (!g_str_equal (audio_be->drv->name,"dbus" )) {error_setg (errp,"Audiodev '%s' is not compatible with DBus" , dd->audiodev);return ; } - audio_state->drv->set_dbus_server (audio_state, dd->server, dd->p2p); + audio_be->drv->set_dbus_server (audio_be, dd->server, dd->p2p); } consoles =g_array_new (FALSE, FALSE,sizeof (guint32));
ui/vnc.c +5 -5
@@ -1276,7 +1276,7 @@ static void audio_add(VncState *vs) ops.destroy = audio_capture_destroy; ops.capture = audio_capture; - vs->audio_cap =AUD_add_capture (vs->vd->audio_state, &vs->as, &ops, vs); + vs->audio_cap =AUD_add_capture (vs->vd->audio_be, &vs->as, &ops, vs);if (!vs->audio_cap) {error_report ("Failed to add audio capture" ); }
@@ -2193,7 +2193,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)send_ext_key_event_ack (vs);break ;case VNC_ENCODING_AUDIO : -if (vs->vd->audio_state) { +if (vs->vd->audio_be) {vnc_set_feature (vs,VNC_FEATURE_AUDIO );send_ext_audio_ack (vs); }
@@ -4236,12 +4236,12 @@ void vnc_display_open(const char *id, Error **errp) audiodev =qemu_opt_get (opts,"audiodev" );if (audiodev) { - vd->audio_state =audio_state_by_name (audiodev, errp); -if (!vd->audio_state) { + vd->audio_be =audio_be_by_name (audiodev, errp); +if (!vd->audio_be) { goto fail; } }else { - vd->audio_state =audio_get_default_audio_state (NULL ); + vd->audio_be =audio_get_default_audio_be (NULL ); } device_id =qemu_opt_get (opts,"display" );
Signature · 1 line
2.51.0
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
Quoted 6 lines · On 10/21/25 11:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Naming is hard. But in general in QEMU, a host "backend" is the term used to fullfill the request made by the device "frontend".
Note that "audiodev" is the corresponding QAPI type name (or configuration).
BE and FE aren't used in existing code though. Looking at current use:
- BlockDriverState*/BlockBackend*
- Chardev*/CharBackend
- NetClientState*/NICState*
... it's actually quite common for the *frontend* to have a pointer or object of type FooBackend; that would give Audiodev* and AudioBackend*.
Paolo
Quoted 779 lines
Signed-off-by Marc-André Lureau <[email protected]>--- audio/audio.h | 18 +++---- audio/audio_int.h | 20 +++---- audio/audio_template.h | 20 +++---- ui/vnc.h | 2 +- audio/alsaaudio.c | 2 +- audio/audio-hmp-cmds.c | 2 +- audio/audio.c | 90 ++++++++++++++++---------------- audio/dbusaudio.c | 8 +-- audio/ossaudio.c | 4 +- audio/wavcapture.c | 2 +- hw/audio/pcspk.c | 2 +- hw/core/machine.c | 2 +- hw/core/qdev-properties-system.c | 6 +-- ui/dbus.c | 8 +-- ui/vnc.c | 10 ++-- 15 files changed, 98 insertions(+), 98 deletions(-)audio/audio.h +9
-9@@ -64,15 +64,15 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; -typedef struct AudioStateClass AudioStateClass ; -struct AudioStateClass { +typedef struct AudioBEClass AudioBEClass ; +struct AudioBEClass {ObjectClass parent_class; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ;typedef struct QEMUSoundCard {char *name; -AudioState *state; +AudioBE *be;QLIST_ENTRY (QEMUSoundCard) entries; }QEMUSoundCard ;@@ -83,7 +83,7 @@ typedef struct QEMUAudioTimeStamp {bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp);void AUD_remove_card (QEMUSoundCard *card);CaptureVoiceOut *AUD_add_capture ( -AudioState *s, +AudioBE *s,struct audsettings *as,struct audio_capture_ops *ops, void *opaque@@ -154,14 +154,14 @@ void audio_create_default_audiodevs(void);void audio_init_audiodevs (void );void audio_help (void ); -AudioState *audio_state_by_name (const char *name,Error **errp); -AudioState *audio_get_default_audio_state (Error **errp); +AudioBE *audio_be_by_name (const char *name,Error **errp); +AudioBE *audio_get_default_audio_be (Error **errp);const char *audio_get_id (QEMUSoundCard *card);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) -#define TYPE_AUDIO_STATE "audio-state" -OBJECT_DECLARE_TYPE(AudioState, AudioStateClass, AUDIO_STATE) +#define TYPE_AUDIO_BE "audio-be" +OBJECT_DECLARE_TYPE(AudioBE, AudioBEClass, AUDIO_BE)#endif /* QEMU_AUDIO_H */ audio/audio_int.h +10
-10@@ -57,7 +57,7 @@ struct audio_pcm_info {int swap_endianness; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ;typedef struct SWVoiceCap SWVoiceCap ; typedef struct STSampleBuffer {@@ -66,7 +66,7 @@ typedef struct STSampleBuffer { } STSampleBuffer; typedef struct HWVoiceOut { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; int pending_disable;@@ -87,7 +87,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; typedef struct HWVoiceIn { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; struct audio_pcm_info info;@@ -109,7 +109,7 @@ typedef struct HWVoiceIn {struct SWVoiceOut {QEMUSoundCard *card; -AudioState *s; +AudioBE *s;struct audio_pcm_info info;t_sample *conv;STSampleBuffer resample_buf;@@ -126,7 +126,7 @@ struct SWVoiceOut {struct SWVoiceIn {QEMUSoundCard *card; -AudioState *s; +AudioBE *s;int active;struct audio_pcm_info info;void *rate;@@ -147,7 +147,7 @@ struct audio_driver {void *(*init) (Audiodev *,Error **);void (*fini) (void *);#ifdef CONFIG_GIO -void (*set_dbus_server) (AudioState *s,GDBusObjectManagerServer *manager,bool p2p); +void (*set_dbus_server) (AudioBE *s,GDBusObjectManagerServer *manager,bool p2p);#endif struct audio_pcm_ops *pcm_ops;int max_voices_out;@@ -206,7 +206,7 @@ static inline void *advance (void *p, int incr)return (d + incr); } -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture (AudioBE *state,CaptureState *s,const char *path,int freq,int bits,int nchannels);void audio_generic_run_buffer_in (HWVoiceIn *hw);@@ -238,7 +238,7 @@ struct SWVoiceCap {QLIST_ENTRY (SWVoiceCap) entries; }; -typedef struct AudioState { +typedef struct AudioBE { Object parent; struct audio_driver *drv;@@ -258,7 +258,7 @@ typedef struct AudioState {bool timer_running;uint64_t timer_last;VMChangeStateEntry *vmse; -} AudioState; +} AudioBE;extern const struct mixeng_volume nominal_volume;@@ -271,7 +271,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);int audio_bug (const char *funcname,int cond); -void audio_run (AudioState *s,const char *msg); +void audio_run (AudioBE *s,const char *msg);const char *audio_application_name (void );audio/audio_template.h +10
-10@@ -36,7 +36,7 @@#define HWBUF hw->conv_buf#endif -static void glue (audio_init_nb_voices_ ,TYPE )(AudioState *s, +static void glue (audio_init_nb_voices_ ,TYPE )(AudioBE *s,struct audio_driver *drv,int min_voices) {int max_voices =glue (drv->max_voices_,TYPE );@@ -221,7 +221,7 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)static void glue (audio_pcm_hw_gc_ ,TYPE ) (HW **hwp) {HW *hw = *hwp; -AudioState *s = hw->s; +AudioBE *s = hw->s;if (!hw->sw_head.lh_first) {#ifdef DAC @@ -236,12 +236,12 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } -static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioState *s,HW *hw) +static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioBE *s,HW *hw) {return hw ? hw->entries.le_next :glue (s->hw_head_,TYPE ).lh_first; } -static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioState *s,HW *hw) +static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioBE *s,HW *hw) {while ((hw =glue (audio_pcm_hw_find_any_,TYPE )(s, hw))) {if (hw->enabled) {@@ -251,7 +251,7 @@ static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *hw)return NULL ; } -static HW *glue (audio_pcm_hw_find_specific_ ,TYPE )(AudioState *s,HW *hw, +static HW *glue (audio_pcm_hw_find_specific_ ,TYPE )(AudioBE *s,HW *hw,struct audsettings *as) {while ((hw =glue (audio_pcm_hw_find_any_,TYPE )(s, hw))) {@@ -262,7 +262,7 @@ static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioState *s, HW *hw,return NULL ; } -static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioState *s, +static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;@@ -398,7 +398,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)abort (); } -static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioState *s,struct audsettings *as) +static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;AudiodevPerDirectionOptions *pdo =glue (audio_get_pdo_,TYPE )(s->dev);@@ -424,7 +424,7 @@ static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s, struct audsettings *as) }static SW *glue (audio_pcm_create_voice_pair_ ,TYPE )( -AudioState *s, +AudioBE *s,const char *sw_name,struct audsettings *as )@@ -494,7 +494,7 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as ) { -AudioState *s; +AudioBE *s;AudiodevPerDirectionOptions *pdo;if (audio_bug (__func__, !card || !name || !callback_fn || !as)) {@@ -503,7 +503,7 @@ SW *glue (AUD_open_, TYPE) ( goto fail; } - s = card->state; + s = card->be; pdo =glue (audio_get_pdo_,TYPE )(s->dev); ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",ui/vnc.h +1
-1@@ -184,7 +184,7 @@ struct VncDisplayVncDisplaySASL sasl;#endif -AudioState *audio_state; +AudioBE *audio_be;VMChangeStateEntry *vmstate_handler_entry; };audio/alsaaudio.c +1
-1@@ -41,7 +41,7 @@ struct pollhlp {struct pollfd *pfds;int count;int mask; -AudioState *s; +AudioBE *s; }; typedef struct ALSAVoiceOut {audio/audio-hmp-cmds.c +1
-1@@ -67,7 +67,7 @@ void hmp_wavcapture(Monitor *mon, const QDict *qdict)const char *audiodev =qdict_get_str (qdict,"audiodev" );CaptureState *s;Error *local_err =NULL ; -AudioState *as =audio_state_by_name (audiodev, &local_err); +AudioBE *as =audio_be_by_name (audiodev, &local_err);if (!as) {error_report_err (local_err);audio/audio.c +45
-45@@ -99,7 +99,7 @@ static audio_driver *audio_driver_lookup(const char *name)return NULL ; } -static AudioState *default_audio_state; +static AudioBE *default_audio_be;const struct mixeng_volume nominal_volume = { .mute =0 ,@@ -380,7 +380,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)/* * Capture */ -static CaptureVoiceOut *audio_pcm_capture_find_specific (AudioState *s, +static CaptureVoiceOut *audio_pcm_capture_find_specific (AudioBE *s,struct audsettings *as) {CaptureVoiceOut *cap;@@ -460,7 +460,7 @@ static void audio_detach_capture (HWVoiceOut *hw)static int audio_attach_capture (HWVoiceOut *hw) { -AudioState *s = hw->s; +AudioBE *s = hw->s;CaptureVoiceOut *cap;audio_detach_capture (hw);@@ -798,7 +798,7 @@ static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info)/* * Timer */ -static int audio_is_timer_needed (AudioState *s) +static int audio_is_timer_needed (AudioBE *s) {HWVoiceIn *hwi =NULL ;HWVoiceOut *hwo =NULL ;@@ -816,7 +816,7 @@ static int audio_is_timer_needed(AudioState *s)return 0 ; } -static void audio_reset_timer (AudioState *s) +static void audio_reset_timer (AudioBE *s) {if (audio_is_timer_needed (s)) { timer_mod_anticipate_ns(s->ts,@@ -838,7 +838,7 @@ static void audio_reset_timer (AudioState *s)static void audio_timer (void *opaque) {int64_t now, diff; -AudioState *s = opaque; +AudioBE *s = opaque; now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); diff = now - s->timer_last;@@ -921,7 +921,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) hw = sw->hw;if (sw->active != on) { -AudioState *s = sw->s; +AudioBE *s = sw->s;SWVoiceOut *temp_sw;SWVoiceCap *sc;@@ -969,7 +969,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) hw = sw->hw;if (sw->active != on) { -AudioState *s = sw->s; +AudioBE *s = sw->s;SWVoiceIn *temp_sw;if (on) {@@ -1137,7 +1137,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)return clipped; } -static void audio_run_out (AudioState *s) +static void audio_run_out (AudioBE *s) {HWVoiceOut *hw =NULL ;SWVoiceOut *sw;@@ -1291,7 +1291,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples)return conv; } -static void audio_run_in (AudioState *s) +static void audio_run_in (AudioBE *s) {HWVoiceIn *hw =NULL ;@@ -1339,7 +1339,7 @@ static void audio_run_in (AudioState *s) } } -static void audio_run_capture (AudioState *s) +static void audio_run_capture (AudioBE *s) {CaptureVoiceOut *cap;@@ -1386,7 +1386,7 @@ static void audio_run_capture (AudioState *s) } } -void audio_run (AudioState *s,const char *msg) +void audio_run (AudioBE *s,const char *msg) {audio_run_out (s);audio_run_in (s);@@ -1559,7 +1559,7 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)return total; } -static bool audio_driver_init (AudioState *s,struct audio_driver *drv, +static bool audio_driver_init (AudioBE *s,struct audio_driver *drv,Audiodev *dev,Error **errp) { s->drv_opaque = drv->init (dev, errp);@@ -1592,7 +1592,7 @@ static bool audio_driver_init(AudioState *s, struct audio_driver *drv,static void audio_vm_change_state_handler (void *opaque,bool running,RunState state) { -AudioState *s = opaque; +AudioBE *s = opaque;HWVoiceOut *hwo =NULL ;HWVoiceIn *hwi =NULL ;@@ -1613,9 +1613,9 @@ static void audio_vm_change_state_handler (void *opaque, bool running,static const VMStateDescription vmstate_audio; -static void audio_state_init (Object *obj) +static void audio_be_init (Object *obj) { -AudioState *s =AUDIO_STATE (obj); +AudioBE *s =AUDIO_BE (obj);QLIST_INIT (&s->hw_head_out);QLIST_INIT (&s->hw_head_in);@@ -1629,9 +1629,9 @@ static void audio_state_init(Object *obj)vmstate_register_any (NULL , &vmstate_audio, s); } -static void audio_state_finalize (Object *obj) +static void audio_be_finalize (Object *obj) { -AudioState *s =AUDIO_STATE (obj); +AudioBE *s =AUDIO_BE (obj);HWVoiceOut *hwo, *hwon;HWVoiceIn *hwi, *hwin;@@ -1692,7 +1692,7 @@ static Object *get_audiodevs_root(void)void audio_cleanup (void ) { - default_audio_state =NULL ; + default_audio_be =NULL ;object_unparent (get_audiodevs_root ()); }@@ -1743,14 +1743,14 @@ void audio_create_default_audiodevs(void)* if dev == NULL => legacy implicit initialization, return the already created * state or create a new one */ -static AudioState *audio_init (Audiodev *dev,Error **errp) +static AudioBE *audio_init (Audiodev *dev,Error **errp) {int done =0 ;const char *drvname; -AudioState *s; +AudioBE *s;struct audio_driver *driver; - s =AUDIO_STATE (object_new (TYPE_AUDIO_STATE )); + s =AUDIO_BE (object_new (TYPE_AUDIO_BE ));if (dev) {/* -audiodev option */ @@ -1766,7 +1766,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) goto out; } }else { -assert (!default_audio_state); +assert (!default_audio_be);for (;;) {AudiodevListEntry *e =QSIMPLEQ_FIRST (&default_audiodevs);if (!e) {@@ -1797,11 +1797,11 @@ out:return NULL ; } -AudioState *audio_get_default_audio_state (Error **errp) +AudioBE *audio_get_default_audio_be (Error **errp) { -if (!default_audio_state) { - default_audio_state =audio_init (NULL , errp); -if (!default_audio_state) { +if (!default_audio_be) { + default_audio_be =audio_init (NULL , errp); +if (!default_audio_be) {if (!QSIMPLEQ_EMPTY (&audiodevs)) {error_append_hint (errp,"Perhaps you wanted to use -audio or set audiodev=%s?\n" ,QSIMPLEQ_FIRST (&audiodevs)->dev->id);@@ -1809,21 +1809,21 @@ AudioState *audio_get_default_audio_state(Error **errp) } } -return default_audio_state; +return default_audio_be; }bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp) { -if (!card->state) { - card->state =audio_get_default_audio_state (errp); -if (!card->state) { +if (!card->be) { + card->be =audio_get_default_audio_be (errp); +if (!card->be) {return false; } } card->name =g_strdup (name);memset (&card->entries,0 ,sizeof (card->entries)); -QLIST_INSERT_HEAD (&card->state->card_head, card, entries); +QLIST_INSERT_HEAD (&card->be->card_head, card, entries);return true; }@@ -1837,7 +1837,7 @@ void AUD_remove_card (QEMUSoundCard *card)static struct audio_pcm_ops capture_pcm_ops;CaptureVoiceOut *AUD_add_capture ( -AudioState *s, +AudioBE *s,struct audsettings *as,struct audio_capture_ops *ops, void *cb_opaque@@ -2220,7 +2220,7 @@ int audio_buffer_bytes(AudiodevPerDirectionOptions *pdo,audioformat_bytes_per_sample (as->fmt); } -AudioState *audio_state_by_name (const char *name,Error **errp) +AudioBE *audio_be_by_name (const char *name,Error **errp) {Object *obj =object_resolve_path_component (get_audiodevs_root (), name);@@ -2228,15 +2228,15 @@ AudioState *audio_state_by_name(const char *name, Error **errp)error_setg (errp,"audiodev '%s' not found" , name);return NULL ; }else { -return AUDIO_STATE (obj); +return AUDIO_BE (obj); } }const char *audio_get_id (QEMUSoundCard *card) { -if (card->state) { -assert (card->state->dev); -return card->state->dev->id; +if (card->be) { +assert (card->be->dev); +return card->be->dev->id; }else {return "" ; }@@ -2305,19 +2305,19 @@ AudiodevList *qmp_query_audiodevs(Error **errp)return ret; } -static const TypeInfo audio_state_info = { - .name =TYPE_AUDIO_STATE , +static const TypeInfo audio_be_info = { + .name =TYPE_AUDIO_BE , .parent =TYPE_OBJECT , - .instance_size =sizeof (AudioState), - .instance_init = audio_state_init, - .instance_finalize = audio_state_finalize, + .instance_size =sizeof (AudioBE), + .instance_init = audio_be_init, + .instance_finalize = audio_be_finalize, .abstract = false,// todo, subclass and make it abstract - .class_size =sizeof (AudioStateClass), + .class_size =sizeof (AudioBEClass), };static void register_types (void ) { -type_register_static (&audio_state_info); +type_register_static (&audio_be_info); }type_init (register_types);audio/dbusaudio.c +4
-4@@ -458,7 +458,7 @@ listener_in_vanished_cb(GDBusConnection *connection, } static gboolean -dbus_audio_register_listener(AudioState *s, +dbus_audio_register_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,@@ -615,7 +615,7 @@ dbus_audio_register_listener(AudioState *s, } static gboolean -dbus_audio_register_out_listener(AudioState *s, +dbus_audio_register_out_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,@@ -631,7 +631,7 @@ dbus_audio_register_out_listener(AudioState *s, } static gboolean -dbus_audio_register_in_listener(AudioState *s, +dbus_audio_register_in_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,@@ -646,7 +646,7 @@ dbus_audio_register_in_listener(AudioState *s, }static void -dbus_audio_set_server (AudioState *s,GDBusObjectManagerServer *server,bool p2p) +dbus_audio_set_server (AudioBE *s,GDBusObjectManagerServer *server,bool p2p) {DBusAudio *da = s->drv_opaque;audio/ossaudio.c +2
-2@@ -107,13 +107,13 @@ static void oss_anal_close (int *fdp)static void oss_helper_poll_out (void *opaque) { -AudioState *s = opaque; +AudioBE *s = opaque;audio_run (s,"oss_poll_out" ); }static void oss_helper_poll_in (void *opaque) { -AudioState *s = opaque; +AudioBE *s = opaque;audio_run (s,"oss_poll_in" ); }audio/wavcapture.c +1
-1@@ -103,7 +103,7 @@ static struct capture_ops wav_capture_ops = { .info = wav_capture_info }; -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture (AudioBE *state,CaptureState *s,const char *path,int freq,int bits,int nchannels) {WAVState *wav;hw/audio/pcspk.c +1
-1@@ -188,7 +188,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &s->ioport, s->iobase); -if (s->card.state &&AUD_register_card (s_spk, &s->card, errp)) { +if (s->card.be &&AUD_register_card (s_spk, &s->card, errp)) {pcspk_audio_init (s); } }hw/core/machine.c +1
-1@@ -763,7 +763,7 @@ static void machine_set_audiodev(Object *obj, const char *value, {MachineState *ms =MACHINE (obj); -if (!audio_state_by_name (value, errp)) { +if (!audio_be_by_name (value, errp)) {return ; }hw/core/qdev-properties-system.c +3
-3@@ -499,16 +499,16 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, {const Property *prop = opaque;QEMUSoundCard *card =object_field_prop_ptr (obj, prop); -AudioState *state; +AudioBE *state; g_autofree char *str = NULL;if (!visit_type_str (v, name, &str, errp)) {return ; } - state =audio_state_by_name (str, errp); + state =audio_be_by_name (str, errp);if (state) { - card->state = state; + card->be = state; } }ui/dbus.c +4
-4@@ -220,16 +220,16 @@ dbus_display_complete(UserCreatable *uc, Error **errp) }if (dd->audiodev && *dd->audiodev) { -AudioState *audio_state =audio_state_by_name (dd->audiodev, errp); -if (!audio_state) { +AudioBE *audio_be =audio_be_by_name (dd->audiodev, errp); +if (!audio_be) {return ; } -if (!g_str_equal (audio_state->drv->name,"dbus" )) { +if (!g_str_equal (audio_be->drv->name,"dbus" )) {error_setg (errp,"Audiodev '%s' is not compatible with DBus" , dd->audiodev);return ; } - audio_state->drv->set_dbus_server (audio_state, dd->server, dd->p2p); + audio_be->drv->set_dbus_server (audio_be, dd->server, dd->p2p); } consoles =g_array_new (FALSE, FALSE,sizeof (guint32));ui/vnc.c +5
-5@@ -1276,7 +1276,7 @@ static void audio_add(VncState *vs) ops.destroy = audio_capture_destroy; ops.capture = audio_capture; - vs->audio_cap =AUD_add_capture (vs->vd->audio_state, &vs->as, &ops, vs); + vs->audio_cap =AUD_add_capture (vs->vd->audio_be, &vs->as, &ops, vs);if (!vs->audio_cap) {error_report ("Failed to add audio capture" ); }@@ -2193,7 +2193,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)send_ext_key_event_ack (vs);break ;case VNC_ENCODING_AUDIO : -if (vs->vd->audio_state) { +if (vs->vd->audio_be) {vnc_set_feature (vs,VNC_FEATURE_AUDIO );send_ext_audio_ack (vs); }@@ -4236,12 +4236,12 @@ void vnc_display_open(const char *id, Error **errp) audiodev =qemu_opt_get (opts,"audiodev" );if (audiodev) { - vd->audio_state =audio_state_by_name (audiodev, errp); -if (!vd->audio_state) { + vd->audio_be =audio_be_by_name (audiodev, errp); +if (!vd->audio_be) { goto fail; } }else { - vd->audio_state =audio_get_default_audio_state (NULL ); + vd->audio_be =audio_get_default_audio_be (NULL ); } device_id =qemu_opt_get (opts,"display" );
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
Quoted 10 lines · Paolo Bonzini
Quoted 6 lines · On 10/21/25 11:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Naming is hard. But in general in QEMU, a host "backend" is the term used to fullfill the request made by the device "frontend".
Note that "audiodev" is the corresponding QAPI type name (or configuration).
BE and FE aren't used in existing code though. Looking at current use:
Quoted 7 lines
- BlockDriverState*/BlockBackend*
- Chardev*/CharBackend
- NetClientState*/NICState*
... it's actually quite common for the *frontend* to have a pointer or object of type FooBackend; that would give Audiodev* and AudioBackend*.
Hmm, I have to correct myself.
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
Paolo
Quoted 727 lines
Paolo
Quoted 722 lines
Signed-off-by Marc-André Lureau <[email protected]>---
audio/audio.h | 18 +++---- audio/audio_int.h | 20 +++---- audio/audio_template.h | 20 +++----
ui/vnc.h | 2 +-
audio/alsaaudio.c | 2 +- audio/audio-hmp-cmds.c | 2 +-
audio/audio.c | 90 ++++++++++++++++---------------- audio/dbusaudio.c | 8 +--
audio/ossaudio.c | 4 +- audio/wavcapture.c | 2 +-
hw/audio/pcspk.c | 2 +-
hw/core/machine.c | 2 +-hw/core/qdev-properties-system.c| 6 +--
ui/dbus.c | 8 +--
ui/vnc.c | 10 ++--15 files changed, 98 insertions(+), 98 deletions(-)audio/audio.h +4
-4@@ -64,15 +64,15 @@ typedef struct SWVoiceOut SWVoiceOut; typedef struct CaptureVoiceOut CaptureVoiceOut; typedef struct SWVoiceIn SWVoiceIn; -typedef struct AudioStateClass AudioStateClass ; -struct AudioStateClass { +typedef struct AudioBEClass AudioBEClass ; +struct AudioBEClass { ObjectClass parent_class; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ; typedef struct QEMUSoundCard { char *name; - AudioState *state; + AudioBE *be; QLIST_ENTRY (QEMUSoundCard) entries; } QEMUSoundCard;@@ -83,7 +83,7 @@ typedef struct QEMUAudioTimeStamp { bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp); void AUD_remove_card (QEMUSoundCard *card);CaptureVoiceOut *AUD_add_capture(
- AudioState *s,
+ AudioBE *s,
struct audsettings *as,
structaudio_capture_ops*ops,
void *opaqueaudio/audio.h +4
-4@@ -154,14 +154,14 @@ void audio_create_default_audiodevs(void); void audio_init_audiodevs(void); void audio_help(void); -AudioState *audio_state_by_name (const char *name,Error **errp); -AudioState *audio_get_default_audio_state (Error **errp); +AudioBE *audio_be_by_name (const char *name,Error **errp); +AudioBE *audio_get_default_audio_be (Error **errp); const char *audio_get_id(QEMUSoundCard *card); #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) -#define TYPE_AUDIO_STATE "audio-state" -OBJECT_DECLARE_TYPE(AudioState, AudioStateClass, AUDIO_STATE) +#define TYPE_AUDIO_BE "audio-be" +OBJECT_DECLARE_TYPE(AudioBE, AudioBEClass, AUDIO_BE) #endif /* QEMU_AUDIO_H */audio/audio_int.h +6
-6@@ -57,7 +57,7 @@ struct audio_pcm_info { int swap_endianness; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ; typedef struct SWVoiceCap SWVoiceCap; typedef struct STSampleBuffer {@@ -66,7 +66,7 @@ typedef struct STSampleBuffer { } STSampleBuffer; typedef struct HWVoiceOut { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; int pending_disable;@@ -87,7 +87,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; typedef struct HWVoiceIn { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; struct audio_pcm_info info;@@ -109,7 +109,7 @@ typedef struct HWVoiceIn { struct SWVoiceOut { QEMUSoundCard *card; - AudioState *s; + AudioBE *s; struct audio_pcm_info info; t_sample *conv; STSampleBuffer resample_buf;@@ -126,7 +126,7 @@ struct SWVoiceOut { struct SWVoiceIn { QEMUSoundCard *card; - AudioState *s; + AudioBE *s; int active; struct audio_pcm_info info; void *rate;@@ -147,7 +147,7 @@ struct audio_driver { void *(*init) (Audiodev *, Error **); void (*fini) (void *); #ifdef CONFIG_GIO - void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *manager, bool p2p); + void (*set_dbus_server) (AudioBE *s, GDBusObjectManagerServer *manager,bool p2p); #endifstruct
audio_pcm_ops*pcm_ops;
intmax_voices_out;audio/audio_int.h +4
-4@@ -206,7 +206,7 @@ static inline void *advance (void *p, int incr) return (d + incr); } -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture(AudioBE *state, CaptureState *s, const char *path, int freq, int bits, int nchannels); void audio_generic_run_buffer_in(HWVoiceIn *hw);@@ -238,7 +238,7 @@ struct SWVoiceCap { QLIST_ENTRY (SWVoiceCap) entries; }; -typedef struct AudioState { +typedef struct AudioBE { Object parent; struct audio_driver *drv;@@ -258,7 +258,7 @@ typedef struct AudioState { bool timer_running; uint64_t timer_last; VMChangeStateEntry *vmse; -} AudioState; +} AudioBE; extern const struct mixeng_volume nominal_volume;@@ -271,7 +271,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len); int audio_bug (const char *funcname, int cond); -void audio_run (AudioState *s,const char *msg); +void audio_run (AudioBE *s,const char *msg); const char *audio_application_name(void);audio/audio_template.h +4
-4@@ -36,7 +36,7 @@ #define HWBUF hw->conv_buf #endif -static void glue (audio_init_nb_voices_ ,TYPE )(AudioState *s, +static void glue (audio_init_nb_voices_ ,TYPE )(AudioBE *s, struct audio_driver *drv, int min_voices) { int max_voices = glue (drv->max_voices_, TYPE);@@ -221,7 +221,7 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw) static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) { HW *hw = *hwp; - AudioState *s = hw->s; + AudioBE *s = hw->s; if (!hw->sw_head.lh_first) { #ifdef DAC@@ -236,12 +236,12 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } -static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioState *s,HW *hw) +static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioBE *s,HW *hw) { return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first; } -static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioState *s, HW *hw) +static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioBE *s,HW *hw) { while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {if (
hw->enabled) {audio/audio_template.h +1
-1@@ -251,7 +251,7 @@ static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *hw) return NULL; } -static HW *glue (audio_pcm_hw_find_specific_ ,TYPE )(AudioState *s,HW *hw, +static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioBE *s, HW *hw, struct audsettings *as) {while ((hw =
glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {audio/audio_template.h +2
-2@@ -262,7 +262,7 @@ static HW *glue(audio_pcm_hw_find_specific_, TYPE) (AudioState *s, HW *hw, return NULL; } -static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioState *s, +static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioBE *s, struct audsettings *as) { HW *hw;@@ -398,7 +398,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev) abort(); } -static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioState *s,struct audsettings *as) +static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;
AudiodevPerDirectionOptions *pdo =glue(audio_get_pdo_, TYPE)(s-Quoted 1 line
dev);
audio/audio_template.h +0
-0@@ -424,7 +424,7 @@ static HW *glue(audio_pcm_hw_add_, TYPE) (AudioState *s, struct audsettings *as) }static SW *glue(audio_pcm_create_voice_pair_, TYPE)( - AudioState *s,
+ AudioBE *s,
const char*sw_name,
struct audsettings *as
)audio/audio_template.h +0
-0@@ -494,7 +494,7 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as
)
{
- AudioState *s;
+ AudioBE *s;
AudiodevPerDirectionOptions *pdo;
if (audio_bug(__func__, !card || !name || !callback_fn || !as)) {audio/audio_template.h +1
-1@@ -503,7 +503,7 @@ SW *glue (AUD_open_, TYPE) ( goto fail; } - s = card->state; + s = card->be; pdo = glue(audio_get_pdo_, TYPE)(s->dev); ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",ui/vnc.h +1
-1@@ -184,7 +184,7 @@ struct VncDisplay VncDisplaySASL sasl; #endif - AudioState *audio_state; + AudioBE *audio_be; VMChangeStateEntry *vmstate_handler_entry; };audio/alsaaudio.c +1
-1@@ -41,7 +41,7 @@ struct pollhlp { struct pollfd *pfds; int count; int mask; - AudioState *s; + AudioBE *s; }; typedef struct ALSAVoiceOut {audio/audio-hmp-cmds.c +1
-1@@ -67,7 +67,7 @@ void hmp_wavcapture(Monitor *mon, const QDict *qdict) const char *audiodev = qdict_get_str(qdict, "audiodev"); CaptureState *s; Error *local_err = NULL; - AudioState *as = audio_state_by_name(audiodev, &local_err); + AudioBE *as = audio_be_by_name(audiodev, &local_err); if (!as) { error_report_err(local_err);audio/audio.c +2
-2@@ -99,7 +99,7 @@ static audio_driver *audio_driver_lookup(const char *name) return NULL; } -static AudioState *default_audio_state; +static AudioBE *default_audio_be; const struct mixeng_volume nominal_volume = { .mute = 0,@@ -380,7 +380,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len) /** Capture */ -static CaptureVoiceOut *audio_pcm_capture_find_specific (AudioState *s, +static CaptureVoiceOut *audio_pcm_capture_find_specific (AudioBE *s, struct audsettings *as) {CaptureVoiceOut *cap;
audio/audio.c +2
-2@@ -460,7 +460,7 @@ static void audio_detach_capture (HWVoiceOut *hw) static int audio_attach_capture (HWVoiceOut *hw) { - AudioState *s = hw->s; + AudioBE *s = hw->s; CaptureVoiceOut *cap; audio_detach_capture (hw);@@ -798,7 +798,7 @@ static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info) /** Timer */ -static int audio_is_timer_needed (AudioState *s) +static int audio_is_timer_needed (AudioBE *s) { HWVoiceIn *hwi = NULL;HWVoiceOut *hwo = NULL;
audio/audio.c +19
-19@@ -816,7 +816,7 @@ static int audio_is_timer_needed(AudioState *s) return 0; } -static void audio_reset_timer (AudioState *s) +static void audio_reset_timer (AudioBE *s) { if (audio_is_timer_needed(s)) { timer_mod_anticipate_ns(s->ts,@@ -838,7 +838,7 @@ static void audio_reset_timer (AudioState *s) static void audio_timer (void *opaque) { int64_t now, diff; - AudioState *s = opaque; + AudioBE *s = opaque; now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); diff = now - s->timer_last;@@ -921,7 +921,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) hw = sw->hw; if (sw->active != on) { - AudioState *s = sw->s; + AudioBE *s = sw->s; SWVoiceOut *temp_sw; SWVoiceCap *sc;@@ -969,7 +969,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) hw = sw->hw; if (sw->active != on) { - AudioState *s = sw->s; + AudioBE *s = sw->s; SWVoiceIn *temp_sw; if (on) {@@ -1137,7 +1137,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) return clipped; } -static void audio_run_out (AudioState *s) +static void audio_run_out (AudioBE *s) { HWVoiceOut *hw = NULL; SWVoiceOut *sw;@@ -1291,7 +1291,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples) return conv; } -static void audio_run_in (AudioState *s) +static void audio_run_in (AudioBE *s) { HWVoiceIn *hw = NULL;@@ -1339,7 +1339,7 @@ static void audio_run_in (AudioState *s) } } -static void audio_run_capture (AudioState *s) +static void audio_run_capture (AudioBE *s) { CaptureVoiceOut *cap;@@ -1386,7 +1386,7 @@ static void audio_run_capture (AudioState *s) } } -void audio_run (AudioState *s,const char *msg) +void audio_run (AudioBE *s,const char *msg) { audio_run_out(s); audio_run_in(s);@@ -1559,7 +1559,7 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) return total; } -static bool audio_driver_init (AudioState *s,struct audio_driver *drv, +static bool audio_driver_init (AudioBE *s,struct audio_driver *drv, Audiodev *dev, Error **errp) { s->drv_opaque = drv->init(dev, errp);@@ -1592,7 +1592,7 @@ static bool audio_driver_init(AudioState *s,struct audio_driver *drv, static void audio_vm_change_state_handler (void *opaque, bool running, RunState state) { - AudioState *s = opaque; + AudioBE *s = opaque; HWVoiceOut *hwo = NULL; HWVoiceIn *hwi = NULL;@@ -1613,9 +1613,9 @@ static void audio_vm_change_state_handler (void *opaque, bool running, static const VMStateDescription vmstate_audio; -static void audio_state_init (Object *obj) +static void audio_be_init (Object *obj) { - AudioState *s = AUDIO_STATE(obj); + AudioBE *s = AUDIO_BE(obj); QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in);@@ -1629,9 +1629,9 @@ static void audio_state_init(Object *obj) vmstate_register_any(NULL, &vmstate_audio, s); } -static void audio_state_finalize (Object *obj) +static void audio_be_finalize (Object *obj) { - AudioState *s = AUDIO_STATE(obj); + AudioBE *s = AUDIO_BE(obj); HWVoiceOut *hwo, *hwon; HWVoiceIn *hwi, *hwin;@@ -1692,7 +1692,7 @@ static Object *get_audiodevs_root(void) void audio_cleanup(void) { - default_audio_state = NULL; + default_audio_be = NULL; object_unparent(get_audiodevs_root()); }@@ -1743,14 +1743,14 @@ void audio_create_default_audiodevs(void)* if dev == NULL => legacy implicit initialization, return the already created * state or create a new one */ -static AudioState *audio_init (Audiodev *dev,Error **errp) +static AudioBE *audio_init (Audiodev *dev,Error **errp) { int done = 0; const char *drvname; - AudioState *s; + AudioBE *s; struct audio_driver *driver; - s = AUDIO_STATE(object_new(TYPE_AUDIO_STATE)); + s = AUDIO_BE(object_new(TYPE_AUDIO_BE)); if (dev) { /* -audiodev option */@@ -1766,7 +1766,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) goto out; } } else { - assert(!default_audio_state); + assert(!default_audio_be); for (;;) { AudiodevListEntry *e = QSIMPLEQ_FIRST(&default_audiodevs);if (!e) {
audio/audio.c +9
-9@@ -1797,11 +1797,11 @@ out: return NULL; } -AudioState *audio_get_default_audio_state (Error **errp) +AudioBE *audio_get_default_audio_be (Error **errp) { - if (!default_audio_state) { - default_audio_state = audio_init(NULL, errp); - if (!default_audio_state) { + if (!default_audio_be) { + default_audio_be = audio_init(NULL, errp); + if (!default_audio_be) { if (!QSIMPLEQ_EMPTY(&audiodevs)) { error_append_hint(errp, "Perhaps you wanted to use - audio or set audiodev=%s?\n", QSIMPLEQ_FIRST(&audiodevs)->dev->id);@@ -1809,21 +1809,21 @@ AudioState *audio_get_default_audio_state(Error **errp) } } - return default_audio_state; + return default_audio_be; } bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp) { - if (!card->state) { - card->state = audio_get_default_audio_state(errp); - if (!card->state) { + if (!card->be) { + card->be = audio_get_default_audio_be(errp); + if (!card->be) { return false; } } card->name = g_strdup (name); memset (&card->entries, 0, sizeof (card->entries)); - QLIST_INSERT_HEAD(&card->state->card_head, card, entries); + QLIST_INSERT_HEAD(&card->be->card_head, card, entries); return true; }@@ -1837,7 +1837,7 @@ void AUD_remove_card (QEMUSoundCard *card) static struct audio_pcm_ops capture_pcm_ops;CaptureVoiceOut *AUD_add_capture(
- AudioState *s,
+ AudioBE *s,
struct audsettings *as,
structaudio_capture_ops*ops,
void*cb_opaqueaudio/audio.c +10
-10@@ -2220,7 +2220,7 @@ int audio_buffer_bytes(AudiodevPerDirectionOptions *pdo, audioformat_bytes_per_sample(as->fmt); } -AudioState *audio_state_by_name(const char *name, Error **errp) +AudioBE *audio_be_by_name(const char *name, Error **errp) { Object *obj = object_resolve_path_component(get_audiodevs_root(), name);@@ -2228,15 +2228,15 @@ AudioState *audio_state_by_name(const char *name, Error **errp) error_setg(errp, "audiodev '%s' not found", name); return NULL; } else { - return AUDIO_STATE(obj); + return AUDIO_BE(obj); } } const char *audio_get_id(QEMUSoundCard *card) { - if (card->state) { - assert(card->state->dev); - return card->state->dev->id; + if (card->be) { + assert(card->be->dev); + return card->be->dev->id; } else { return ""; }@@ -2305,19 +2305,19 @@ AudiodevList *qmp_query_audiodevs(Error **errp) return ret; } -static const TypeInfo audio_state_info = { - .name = TYPE_AUDIO_STATE, +static const TypeInfo audio_be_info = { + .name = TYPE_AUDIO_BE, .parent = TYPE_OBJECT, - .instance_size = sizeof(AudioState), - .instance_init = audio_state_init, - .instance_finalize = audio_state_finalize, + .instance_size = sizeof(AudioBE), + .instance_init = audio_be_init, + .instance_finalize = audio_be_finalize,.abstract = false, // todo, subclass and make it abstract - .class_size = sizeof(AudioStateClass),
+ .class_size = sizeof(AudioBEClass),
};
static voidregister_types(void)
{
-type_register_static(&audio_state_info);
+type_register_static(&audio_be_info);
}
type_init(register_types);audio/dbusaudio.c +0
-0@@ -458,7 +458,7 @@ listener_in_vanished_cb(GDBusConnection *connection, }static gboolean
audio/dbusaudio.c +1
-1-dbus_audio_register_listener(AudioState *s, +dbus_audio_register_listener(AudioBE *s,GDBusMethodInvocation *invocation, #ifdef
G_OS_UNIX
GUnixFDList*fd_list,audio/dbusaudio.c +0
-0@@ -615,7 +615,7 @@ dbus_audio_register_listener(AudioState *s, }static gboolean
audio/dbusaudio.c +1
-1-dbus_audio_register_out_listener(AudioState *s, +dbus_audio_register_out_listener(AudioBE *s,GDBusMethodInvocation *invocation, #ifdef
G_OS_UNIX
GUnixFDList*fd_list,audio/dbusaudio.c +0
-0@@ -631,7 +631,7 @@ dbus_audio_register_out_listener(AudioState *s, }static gboolean
audio/dbusaudio.c +1
-1-dbus_audio_register_in_listener(AudioState *s, +dbus_audio_register_in_listener(AudioBE *s,GDBusMethodInvocation *invocation, #ifdef
G_OS_UNIX
GUnixFDList*fd_list,audio/dbusaudio.c +0
-0@@ -646,7 +646,7 @@ dbus_audio_register_in_listener(AudioState *s, }static void
-dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, bool p2p)
+dbus_audio_set_server(AudioBE *s, GDBusObjectManagerServer *server, bool p2p)
{
DBusAudio *da =s->drv_opaque;audio/ossaudio.c +2
-2@@ -107,13 +107,13 @@ static void oss_anal_close (int *fdp) static void oss_helper_poll_out (void *opaque) { - AudioState *s = opaque; + AudioBE *s = opaque; audio_run(s, "oss_poll_out"); } static void oss_helper_poll_in (void *opaque) { - AudioState *s = opaque; + AudioBE *s = opaque; audio_run(s, "oss_poll_in"); }audio/wavcapture.c +0
-0@@ -103,7 +103,7 @@ static struct capture_ops wav_capture_ops = {.info =
wav_capture_info
};
-int wav_start_capture(AudioState *state, CaptureState *s, const char *path,
+intwav_start_capture(AudioBE *state, CaptureState *s, const char *path, int freq, int bits, int nchannels)
{
WAVState *wav;hw/audio/pcspk.c +1
-1@@ -188,7 +188,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp) isa_register_ioport(isadev, &s->ioport, s->iobase); - if (s->card.state && AUD_register_card(s_spk, &s->card, errp)) { + if (s->card.be && AUD_register_card(s_spk, &s->card, errp)) { pcspk_audio_init(s); } }hw/core/machine.c +1
-1@@ -763,7 +763,7 @@ static void machine_set_audiodev(Object *obj,const char *value, { MachineState *ms = MACHINE(obj); - if (!audio_state_by_name(value, errp)) { + if (!audio_be_by_name(value, errp)) { return; }hw/core/qdev-properties-system.c +3
-3@@ -499,16 +499,16 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, { const Property *prop = opaque; QEMUSoundCard *card = object_field_prop_ptr(obj, prop); - AudioState *state; + AudioBE *state; g_autofree char *str = NULL; if (!visit_type_str(v, name, &str, errp)) { return; } - state = audio_state_by_name(str, errp); + state = audio_be_by_name(str, errp); if (state) { - card->state = state; + card->be = state; } }ui/dbus.c +4
-4@@ -220,16 +220,16 @@ dbus_display_complete(UserCreatable *uc, Error **errp) } if (dd->audiodev && *dd->audiodev) { - AudioState *audio_state = audio_state_by_name(dd->audiodev, errp); - if (!audio_state) { + AudioBE *audio_be = audio_be_by_name(dd->audiodev, errp); + if (!audio_be) { return; } - if (!g_str_equal(audio_state->drv->name, "dbus")) { + if (!g_str_equal(audio_be->drv->name, "dbus")) { error_setg(errp, "Audiodev '%s' is not compatible with DBus", dd->audiodev); return; } - audio_state->drv->set_dbus_server(audio_state, dd->server, dd->p2p); + audio_be->drv->set_dbus_server(audio_be, dd->server, dd->p2p); }consoles =
g_array_new(FALSE, FALSE, sizeof(guint32));ui/vnc.c +1
-1@@ -1276,7 +1276,7 @@ static void audio_add(VncState *vs) ops.destroy = audio_capture_destroy; ops.capture = audio_capture; - vs->audio_cap = AUD_add_capture(vs->vd->audio_state, &vs->as, &ops, vs); + vs->audio_cap = AUD_add_capture(vs->vd->audio_be, &vs->as, &ops, vs); if (!vs->audio_cap) { error_report("Failed to add audio capture");}
ui/vnc.c +0
-0@@ -2193,7 +2193,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) send_ext_key_event_ack(vs); break;case
VNC_ENCODING_AUDIO:
- if (vs->vd->audio_state) {
+ if (vs->vd->audio_be) {vnc_set_feature(vs, VNC_FEATURE_AUDIO);send_ext_audio_ack(vs);
}ui/vnc.c +3
-3@@ -4236,12 +4236,12 @@ void vnc_display_open(const char *id, Error **errp) audiodev = qemu_opt_get(opts, "audiodev"); if (audiodev) { - vd->audio_state = audio_state_by_name(audiodev, errp); - if (!vd->audio_state) { + vd->audio_be = audio_be_by_name(audiodev, errp); + if (!vd->audio_be) { goto fail; } } else { - vd->audio_state = audio_get_default_audio_state(NULL); + vd->audio_be = audio_get_default_audio_be(NULL); } device_id = qemu_opt_get(opts, "display");
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
Quoted 15 lines · Paolo Bonzini
Quoted 14 lines · Paolo Bonzini
Quoted 6 lines · On 10/21/25 11:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Naming is hard. But in general in QEMU, a host "backend" is the term used to fullfill the request made by the device "frontend".
Note that "audiodev" is the corresponding QAPI type name (or configuration).
BE and FE aren't used in existing code though. Looking at current use:
- BlockDriverState*/BlockBackend*
- Chardev*/CharBackend
Quoted 7 lines
Quoted 3 lines
- NetClientState*/NICState*
... it's actually quite common for the *frontend* to have a pointer or object of type FooBackend; that would give Audiodev* and AudioBackend*.
Hmm, I have to correct myself.
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
AudioBackend is still a better name than AudioBE though.
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
In reply to Paolo BonziniHi
Quoted 5 lines · Paolo Bonzini
Quoted 3 lines · Paolo Bonzini
Quoted 2 lines · On 10/21/25 11:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Naming is hard. But in general in QEMU, a host "backend" is the term used to fullfill the request made by the device "frontend".
Note that "audiodev" is the corresponding QAPI type name (or configuration).
BE and FE aren't used in existing code though. Looking at current use:
There is a top-level backends/ though. I meant to say that it's usually clearer for everyone when we talk about "backend" vs "frontend" (or not?), and I wish we would follow that naming more in the code.
Quoted 3 lines
Quoted 3 lines
- BlockDriverState*/BlockBackend*
I am not very familiar with the block subsystem, but it is seems BlockBackend is actually the backend and BlockDriverState is implementation data detail. Correct me if I'm wrong
Quoted 2 lines
Quoted 2 lines
- Chardev*/CharBackend
Those are actually always confusing... and I remember I attempted to rename it in the past... CharBackend is the front-end side..
Quoted 10 lines
Quoted 4 lines
- NetClientState*/NICState*
... it's actually quite common for the *frontend* to have a pointer or object of type FooBackend; that would give Audiodev* and AudioBackend*.
Hmm, I have to correct myself.
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
For audio, it's pretty obvious that we have "backend" object to implement the host audio subsystem details, while "QEMUSoundCard" is the "frontend", or "client/user" context.
Imho, it's clearer to see the relation between the two objects if we name them "backend" and "frontend" accordingly. If the "AudioBE" & "AudioFE" short versions aren't readable enough, I am fine naming "AudioBackend" & "AudioFrontend"
Quoted 742 lines
Paolo
Quoted 738 lines
Paolo
Quoted 733 lines
Signed-off-by Marc-André Lureau <[email protected]>--- audio/audio.h | 18 +++---- audio/audio_int.h | 20 +++---- audio/audio_template.h | 20 +++---- ui/vnc.h | 2 +- audio/alsaaudio.c | 2 +- audio/audio-hmp-cmds.c | 2 +- audio/audio.c | 90 ++++++++++++++++---------------- audio/dbusaudio.c | 8 +-- audio/ossaudio.c | 4 +- audio/wavcapture.c | 2 +- hw/audio/pcspk.c | 2 +- hw/core/machine.c | 2 +- hw/core/qdev-properties-system.c | 6 +-- ui/dbus.c | 8 +-- ui/vnc.c | 10 ++-- 15 files changed, 98 insertions(+), 98 deletions(-)audio/audio.h +5
-5@@ -64,15 +64,15 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; -typedef struct AudioStateClass AudioStateClass ; -struct AudioStateClass { +typedef struct AudioBEClass AudioBEClass ; +struct AudioBEClass {ObjectClass parent_class; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ;typedef struct QEMUSoundCard {char *name; -AudioState *state; +AudioBE *be;QLIST_ENTRY (QEMUSoundCard) entries; }QEMUSoundCard ;@@ -83,7 +83,7 @@ typedef struct QEMUAudioTimeStamp {bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp);void AUD_remove_card (QEMUSoundCard *card); CaptureVoiceOut *AUD_add_capture( - AudioState *s, + AudioBE *s, struct audsettings *as, struct audio_capture_ops *ops,void *opaque
audio/audio.h +4
-4@@ -154,14 +154,14 @@ void audio_create_default_audiodevs(void);void audio_init_audiodevs (void );void audio_help (void ); -AudioState *audio_state_by_name (const char *name,Error **errp); -AudioState *audio_get_default_audio_state (Error **errp); +AudioBE *audio_be_by_name (const char *name,Error **errp); +AudioBE *audio_get_default_audio_be (Error **errp);const char *audio_get_id (QEMUSoundCard *card);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) -#define TYPE_AUDIO_STATE "audio-state" -OBJECT_DECLARE_TYPE(AudioState, AudioStateClass, AUDIO_STATE) +#define TYPE_AUDIO_BE "audio-be" +OBJECT_DECLARE_TYPE(AudioBE, AudioBEClass, AUDIO_BE)#endif /* QEMU_AUDIO_H */ audio/audio_int.h +6
-6@@ -57,7 +57,7 @@ struct audio_pcm_info {int swap_endianness; }; -typedef struct AudioState AudioState ; +typedef struct AudioBE AudioBE ;typedef struct SWVoiceCap SWVoiceCap ; typedef struct STSampleBuffer {@@ -66,7 +66,7 @@ typedef struct STSampleBuffer { } STSampleBuffer; typedef struct HWVoiceOut { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; int pending_disable;@@ -87,7 +87,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; typedef struct HWVoiceIn { - AudioState *s; + AudioBE *s; int enabled; int poll_mode; struct audio_pcm_info info;@@ -109,7 +109,7 @@ typedef struct HWVoiceIn {struct SWVoiceOut {QEMUSoundCard *card; -AudioState *s; +AudioBE *s;struct audio_pcm_info info;t_sample *conv;STSampleBuffer resample_buf;@@ -126,7 +126,7 @@ struct SWVoiceOut {struct SWVoiceIn {QEMUSoundCard *card; -AudioState *s; +AudioBE *s;int active;struct audio_pcm_info info;void *rate;@@ -147,7 +147,7 @@ struct audio_driver {void *(*init) (Audiodev *,Error **);void (*fini) (void *);#ifdef CONFIG_GIO -void (*set_dbus_server) (AudioState *s,GDBusObjectManagerServer *manager, bool p2p); +void (*set_dbus_server) (AudioBE *s,GDBusObjectManagerServer *manager,bool p2p);#endif struct audio_pcm_ops *pcm_ops; int max_voices_out;audio/audio_int.h +4
-4@@ -206,7 +206,7 @@ static inline void *advance (void *p, int incr)return (d + incr); } -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture (AudioBE *state,CaptureState *s,const char *path,int freq,int bits,int nchannels);void audio_generic_run_buffer_in (HWVoiceIn *hw);@@ -238,7 +238,7 @@ struct SWVoiceCap {QLIST_ENTRY (SWVoiceCap) entries; }; -typedef struct AudioState { +typedef struct AudioBE { Object parent; struct audio_driver *drv;@@ -258,7 +258,7 @@ typedef struct AudioState {bool timer_running;uint64_t timer_last;VMChangeStateEntry *vmse; -} AudioState; +} AudioBE;extern const struct mixeng_volume nominal_volume;@@ -271,7 +271,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);int audio_bug (const char *funcname,int cond); -void audio_run (AudioState *s,const char *msg); +void audio_run (AudioBE *s,const char *msg);const char *audio_application_name (void );audio/audio_template.h +4
-4@@ -36,7 +36,7 @@#define HWBUF hw->conv_buf#endif -static void glue (audio_init_nb_voices_ ,TYPE )(AudioState *s, +static void glue (audio_init_nb_voices_ ,TYPE )(AudioBE *s,struct audio_driver *drv,int min_voices) {int max_voices =glue (drv->max_voices_,TYPE );@@ -221,7 +221,7 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)static void glue (audio_pcm_hw_gc_ ,TYPE ) (HW **hwp) {HW *hw = *hwp; -AudioState *s = hw->s; +AudioBE *s = hw->s;if (!hw->sw_head.lh_first) {#ifdef DAC @@ -236,12 +236,12 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } -static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioState *s,HW *hw) +static HW *glue (audio_pcm_hw_find_any_ ,TYPE )(AudioBE *s,HW *hw) {return hw ? hw->entries.le_next :glue (s->hw_head_,TYPE ).lh_first; } -static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioState *s, HW *hw) +static HW *glue (audio_pcm_hw_find_any_enabled_ ,TYPE )(AudioBE *s,HW *hw) {while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { if (hw->enabled) {audio/audio_template.h +1
-1@@ -251,7 +251,7 @@ static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *hw) return NULL; } -static HW *glue (audio_pcm_hw_find_specific_ ,TYPE )(AudioState *s,HW *hw, +static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioBE *s, HW *hw,struct audsettings *as){ while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {audio/audio_template.h +2
-2@@ -262,7 +262,7 @@ static HW *glue(audio_pcm_hw_find_specific_, TYPE) (AudioState *s, HW *hw, return NULL; } -static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioState *s, +static HW *glue (audio_pcm_hw_add_new_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;@@ -398,7 +398,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)abort (); } -static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioState *s,struct audsettings *as) +static HW *glue (audio_pcm_hw_add_ ,TYPE )(AudioBE *s,struct audsettings *as) {HW *hw;
AudiodevPerDirectionOptions *pdo =glue(audio_get_pdo_, TYPE)(s-Quoted 1 line
dev);
audio/audio_template.h +3
-3@@ -424,7 +424,7 @@ static HW *glue(audio_pcm_hw_add_, TYPE) (AudioState *s, struct audsettings *as) }static SW *glue (audio_pcm_create_voice_pair_ ,TYPE )( -AudioState *s, +AudioBE *s,const char *sw_name,struct audsettings *as )@@ -494,7 +494,7 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as ) { -AudioState *s; +AudioBE *s;AudiodevPerDirectionOptions *pdo;if (audio_bug (__func__, !card || !name || !callback_fn || !as)) {@@ -503,7 +503,7 @@ SW *glue (AUD_open_, TYPE) ( goto fail; } - s = card->state; + s = card->be; pdo =glue (audio_get_pdo_,TYPE )(s->dev); ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",ui/vnc.h +1
-1@@ -184,7 +184,7 @@ struct VncDisplayVncDisplaySASL sasl;#endif -AudioState *audio_state; +AudioBE *audio_be;VMChangeStateEntry *vmstate_handler_entry; };audio/alsaaudio.c +1
-1@@ -41,7 +41,7 @@ struct pollhlp {struct pollfd *pfds;int count;int mask; -AudioState *s; +AudioBE *s; }; typedef struct ALSAVoiceOut {audio/audio-hmp-cmds.c +1
-1@@ -67,7 +67,7 @@ void hmp_wavcapture(Monitor *mon, const QDict *qdict)const char *audiodev =qdict_get_str (qdict,"audiodev" );CaptureState *s;Error *local_err =NULL ; -AudioState *as =audio_state_by_name (audiodev, &local_err); +AudioBE *as =audio_be_by_name (audiodev, &local_err);if (!as) {error_report_err (local_err);audio/audio.c +2
-2@@ -99,7 +99,7 @@ static audio_driver *audio_driver_lookup(const char *name)return NULL ; } -static AudioState *default_audio_state; +static AudioBE *default_audio_be;const struct mixeng_volume nominal_volume = { .mute =0 ,@@ -380,7 +380,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)/* * Capture */ -static CaptureVoiceOut *audio_pcm_capture_find_specific (AudioState *s, +static CaptureVoiceOut *audio_pcm_capture_find_specific (AudioBE *s,struct audsettings *as){ CaptureVoiceOut *cap;audio/audio.c +2
-2@@ -460,7 +460,7 @@ static void audio_detach_capture (HWVoiceOut *hw)static int audio_attach_capture (HWVoiceOut *hw) { -AudioState *s = hw->s; +AudioBE *s = hw->s;CaptureVoiceOut *cap;audio_detach_capture (hw);@@ -798,7 +798,7 @@ static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info)/* * Timer */ -static int audio_is_timer_needed (AudioState *s) +static int audio_is_timer_needed (AudioBE *s) {HWVoiceIn *hwi =NULL ;HWVoiceOut *hwo = NULL;audio/audio.c +15
-15@@ -816,7 +816,7 @@ static int audio_is_timer_needed(AudioState *s)return 0 ; } -static void audio_reset_timer (AudioState *s) +static void audio_reset_timer (AudioBE *s) {if (audio_is_timer_needed (s)) { timer_mod_anticipate_ns(s->ts,@@ -838,7 +838,7 @@ static void audio_reset_timer (AudioState *s)static void audio_timer (void *opaque) {int64_t now, diff; -AudioState *s = opaque; +AudioBE *s = opaque; now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); diff = now - s->timer_last;@@ -921,7 +921,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) hw = sw->hw;if (sw->active != on) { -AudioState *s = sw->s; +AudioBE *s = sw->s;SWVoiceOut *temp_sw;SWVoiceCap *sc;@@ -969,7 +969,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) hw = sw->hw;if (sw->active != on) { -AudioState *s = sw->s; +AudioBE *s = sw->s;SWVoiceIn *temp_sw;if (on) {@@ -1137,7 +1137,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)return clipped; } -static void audio_run_out (AudioState *s) +static void audio_run_out (AudioBE *s) {HWVoiceOut *hw =NULL ;SWVoiceOut *sw;@@ -1291,7 +1291,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples)return conv; } -static void audio_run_in (AudioState *s) +static void audio_run_in (AudioBE *s) {HWVoiceIn *hw =NULL ;@@ -1339,7 +1339,7 @@ static void audio_run_in (AudioState *s) } } -static void audio_run_capture (AudioState *s) +static void audio_run_capture (AudioBE *s) {CaptureVoiceOut *cap;@@ -1386,7 +1386,7 @@ static void audio_run_capture (AudioState *s) } } -void audio_run (AudioState *s,const char *msg) +void audio_run (AudioBE *s,const char *msg) {audio_run_out (s);audio_run_in (s);@@ -1559,7 +1559,7 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)return total; } -static bool audio_driver_init (AudioState *s,struct audio_driver *drv, +static bool audio_driver_init (AudioBE *s,struct audio_driver *drv,Audiodev *dev,Error **errp) { s->drv_opaque = drv->init (dev, errp);@@ -1592,7 +1592,7 @@ static bool audio_driver_init(AudioState *s,struct audio_driver *drv, static void audio_vm_change_state_handler (void *opaque, bool running, RunState state) { - AudioState *s = opaque; + AudioBE *s = opaque;HWVoiceOut *hwo =NULL ;HWVoiceIn *hwi =NULL ;@@ -1613,9 +1613,9 @@ static void audio_vm_change_state_handler (void *opaque, bool running, static const VMStateDescription vmstate_audio; -static void audio_state_init (Object *obj) +static void audio_be_init (Object *obj) { -AudioState *s =AUDIO_STATE (obj); +AudioBE *s =AUDIO_BE (obj);QLIST_INIT (&s->hw_head_out);QLIST_INIT (&s->hw_head_in);@@ -1629,9 +1629,9 @@ static void audio_state_init(Object *obj)vmstate_register_any (NULL , &vmstate_audio, s); } -static void audio_state_finalize (Object *obj) +static void audio_be_finalize (Object *obj) { -AudioState *s =AUDIO_STATE (obj); +AudioBE *s =AUDIO_BE (obj);HWVoiceOut *hwo, *hwon;HWVoiceIn *hwi, *hwin;@@ -1692,7 +1692,7 @@ static Object *get_audiodevs_root(void)void audio_cleanup (void ) { - default_audio_state =NULL ; + default_audio_be =NULL ;object_unparent (get_audiodevs_root ()); }@@ -1743,14 +1743,14 @@ void audio_create_default_audiodevs(void)* if dev == NULL => legacy implicit initialization, return the already created
* state or create a new one
*/audio/audio.c +4
-4-static AudioState *audio_init (Audiodev *dev,Error **errp) +static AudioBE *audio_init (Audiodev *dev,Error **errp) {int done =0 ;const char *drvname; -AudioState *s; +AudioBE *s;struct audio_driver *driver; - s =AUDIO_STATE (object_new (TYPE_AUDIO_STATE )); + s =AUDIO_BE (object_new (TYPE_AUDIO_BE ));if (dev) {/* -audiodev option */ @@ -1766,7 +1766,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) goto out; } }else { -assert (!default_audio_state); +assert (!default_audio_be);for (;;) {AudiodevListEntry *e =QSIMPLEQ_FIRST (&default_audiodevs);if (!e) {audio/audio.c +22
-22@@ -1797,11 +1797,11 @@ out:return NULL ; } -AudioState *audio_get_default_audio_state (Error **errp) +AudioBE *audio_get_default_audio_be (Error **errp) { -if (!default_audio_state) { - default_audio_state =audio_init (NULL , errp); -if (!default_audio_state) { +if (!default_audio_be) { + default_audio_be =audio_init (NULL , errp); +if (!default_audio_be) {if (!QSIMPLEQ_EMPTY (&audiodevs)) { error_append_hint(errp, "Perhaps you wanted to use - audio or set audiodev=%s?\n", QSIMPLEQ_FIRST(&audiodevs)->dev->id);@@ -1809,21 +1809,21 @@ AudioState *audio_get_default_audio_state(Error **errp) } } -return default_audio_state; +return default_audio_be; }bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp) { -if (!card->state) { - card->state =audio_get_default_audio_state (errp); -if (!card->state) { +if (!card->be) { + card->be =audio_get_default_audio_be (errp); +if (!card->be) {return false; } } card->name =g_strdup (name);memset (&card->entries,0 ,sizeof (card->entries)); -QLIST_INSERT_HEAD (&card->state->card_head, card, entries); +QLIST_INSERT_HEAD (&card->be->card_head, card, entries);return true; }@@ -1837,7 +1837,7 @@ void AUD_remove_card (QEMUSoundCard *card)static struct audio_pcm_ops capture_pcm_ops;CaptureVoiceOut *AUD_add_capture ( -AudioState *s, +AudioBE *s,struct audsettings *as,struct audio_capture_ops *ops, void *cb_opaque@@ -2220,7 +2220,7 @@ intaudio_buffer_bytes (AudiodevPerDirectionOptions *pdo, audioformat_bytes_per_sample(as->fmt); } -AudioState *audio_state_by_name (const char *name,Error **errp) +AudioBE *audio_be_by_name (const char *name,Error **errp) {Object *obj =object_resolve_path_component (get_audiodevs_root (), name);@@ -2228,15 +2228,15 @@ AudioState *audio_state_by_name(const char *name, Error **errp)error_setg (errp,"audiodev '%s' not found" , name);return NULL ; }else { -return AUDIO_STATE (obj); +return AUDIO_BE (obj); } }const char *audio_get_id (QEMUSoundCard *card) { -if (card->state) { -assert (card->state->dev); -return card->state->dev->id; +if (card->be) { +assert (card->be->dev); +return card->be->dev->id; }else {return "" ; }@@ -2305,19 +2305,19 @@ AudiodevList *qmp_query_audiodevs(Error **errp)return ret; } -static const TypeInfo audio_state_info = { - .name =TYPE_AUDIO_STATE , +static const TypeInfo audio_be_info = { + .name =TYPE_AUDIO_BE , .parent =TYPE_OBJECT , - .instance_size =sizeof (AudioState), - .instance_init = audio_state_init, - .instance_finalize = audio_state_finalize, + .instance_size =sizeof (AudioBE), + .instance_init = audio_be_init, + .instance_finalize = audio_be_finalize, .abstract = false,// todo, subclass and make it abstract - .class_size =sizeof (AudioStateClass), + .class_size =sizeof (AudioBEClass), };static void register_types (void ) { -type_register_static (&audio_state_info); +type_register_static (&audio_be_info); }type_init (register_types);audio/dbusaudio.c +4
-4@@ -458,7 +458,7 @@ listener_in_vanished_cb(GDBusConnection *connection, } static gboolean -dbus_audio_register_listener(AudioState *s, +dbus_audio_register_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,@@ -615,7 +615,7 @@ dbus_audio_register_listener(AudioState *s, } static gboolean -dbus_audio_register_out_listener(AudioState *s, +dbus_audio_register_out_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,@@ -631,7 +631,7 @@ dbus_audio_register_out_listener(AudioState *s, } static gboolean -dbus_audio_register_in_listener(AudioState *s, +dbus_audio_register_in_listener(AudioBE *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list,@@ -646,7 +646,7 @@ dbus_audio_register_in_listener(AudioState *s, }static void -dbus_audio_set_server (AudioState *s,GDBusObjectManagerServer *server, bool p2p) +dbus_audio_set_server(AudioBE *s, GDBusObjectManagerServer *server, bool p2p) { DBusAudio *da = s->drv_opaque;audio/ossaudio.c +2
-2@@ -107,13 +107,13 @@ static void oss_anal_close (int *fdp)static void oss_helper_poll_out (void *opaque) { -AudioState *s = opaque; +AudioBE *s = opaque;audio_run (s,"oss_poll_out" ); }static void oss_helper_poll_in (void *opaque) { -AudioState *s = opaque; +AudioBE *s = opaque;audio_run (s,"oss_poll_in" ); }audio/wavcapture.c +1
-1@@ -103,7 +103,7 @@ static struct capture_ops wav_capture_ops = { .info = wav_capture_info }; -int wav_start_capture (AudioState *state,CaptureState *s,const char *path, +int wav_start_capture (AudioBE *state,CaptureState *s,const char *path,int freq,int bits,int nchannels) {WAVState *wav;hw/audio/pcspk.c +1
-1@@ -188,7 +188,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp) isa_register_ioport(isadev, &s->ioport, s->iobase); - if (s->card.state && AUD_register_card(s_spk, &s->card, errp)) { + if (s->card.be && AUD_register_card(s_spk, &s->card, errp)) {pcspk_audio_init (s); } }hw/core/machine.c +1
-1@@ -763,7 +763,7 @@ static void machine_set_audiodev(Object *obj, const char *value, {MachineState *ms =MACHINE (obj); -if (!audio_state_by_name (value, errp)) { +if (!audio_be_by_name (value, errp)) {return ; }hw/core/qdev- renamed from hw/core/qdev-properties-system.c +0
-0
properties-system.c
index1f810b7ddf..be682895f7100644hw/core/qdev-properties-system.c +3
-3@@ -499,16 +499,16 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, {const Property *prop = opaque;QEMUSoundCard *card =object_field_prop_ptr (obj, prop); -AudioState *state; +AudioBE *state; g_autofree char *str = NULL;if (!visit_type_str (v, name, &str, errp)) {return ; } - state =audio_state_by_name (str, errp); + state =audio_be_by_name (str, errp);if (state) { - card->state = state; + card->be = state; } }ui/dbus.c +4
-4@@ -220,16 +220,16 @@ dbus_display_complete(UserCreatable *uc, Error **errp) }if (dd->audiodev && *dd->audiodev) { -AudioState *audio_state =audio_state_by_name (dd->audiodev, errp); -if (!audio_state) { +AudioBE *audio_be =audio_be_by_name (dd->audiodev, errp); +if (!audio_be) {return ; } -if (!g_str_equal (audio_state->drv->name,"dbus" )) { +if (!g_str_equal (audio_be->drv->name,"dbus" )) {error_setg (errp,"Audiodev '%s' is not compatible with DBus", dd->audiodev);return ; } - audio_state->drv->set_dbus_server (audio_state, dd->server, dd->p2p); + audio_be->drv->set_dbus_server (audio_be, dd->server, dd->p2p);} consoles = g_array_new(FALSE, FALSE, sizeof(guint32));ui/vnc.c +1
-1@@ -1276,7 +1276,7 @@ static void audio_add(VncState *vs) ops.destroy = audio_capture_destroy; ops.capture = audio_capture; - vs->audio_cap =AUD_add_capture (vs->vd->audio_state, &vs->as, &ops, vs); + vs->audio_cap =AUD_add_capture (vs->vd->audio_be, &vs->as, &ops, vs);if (!vs->audio_cap) {error_report ("Failed to add audio capture" );}ui/vnc.c +1
-1@@ -2193,7 +2193,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)send_ext_key_event_ack (vs);break ;case VNC_ENCODING_AUDIO : -if (vs->vd->audio_state) { +if (vs->vd->audio_be) {vnc_set_feature (vs,VNC_FEATURE_AUDIO );send_ext_audio_ack (vs);}ui/vnc.c +3
-3@@ -4236,12 +4236,12 @@ void vnc_display_open(const char *id, Error **errp) audiodev =qemu_opt_get (opts,"audiodev" );if (audiodev) { - vd->audio_state =audio_state_by_name (audiodev, errp); -if (!vd->audio_state) { + vd->audio_be =audio_be_by_name (audiodev, errp); +if (!vd->audio_be) { goto fail; } }else { - vd->audio_state =audio_get_default_audio_state (NULL ); + vd->audio_be =audio_get_default_audio_be (NULL ); } device_id =qemu_opt_get (opts,"display" );
Signature · 1 line
Marc-André Lureau
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
Quoted 6 lines · Marc-André Lureau
Quoted 1 line
Quoted 1 line
BE and FE aren't used in existing code though. Looking at current use:
There is a top-level backends/ though. I meant to say that it's usually clearer for everyone when we talk about "backend" vs "frontend" (or not?), and I wish we would follow that naming more in the code.
Yes, but the front-end should have a *pointer* to a backend.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
- BlockDriverState*/BlockBackend*
I am not very familiar with the block subsystem, but it is seems BlockBackend is actually the backend and BlockDriverState is implementation data detail. Correct me if I'm wrong
Yes, note the "*". What I meant above is "the frontend has a BlockBackend*, which itself has the internal BlockDriverState*". Same for character and NICs below.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
- Chardev*/CharBackend
Those are actually always confusing... and I remember I attempted to rename it in the past... CharBackend is the front-end side..
Yes, they are confusing. I'm not sure why it failed, but s/CharBackend/CharFrontend/ does get my vote.
Quoted 6 lines
Quoted 2 lines
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
For audio, it's pretty obvious that we have "backend" object to implement the host audio subsystem details, while "QEMUSoundCard" is the "frontend", or "client/user" context.
I agree, but unlike character devices, QEMUSoundCard is not needed at all. So you can drop it and only leave Audiodev*, or AudioBackend* (but I prefer Audiodev* which matches both the option name and Chardev*).
Paolo
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
Hi
Quoted 33 lines · Paolo Bonzini
Quoted 6 lines · Marc-André Lureau
Quoted 1 line
Quoted 1 line
BE and FE aren't used in existing code though. Looking at current use:
There is a top-level backends/ though. I meant to say that it's usually clearer for everyone when we talk about "backend" vs "frontend" (or not?), and I wish we would follow that naming more in the code.
Yes, but the front-end should have a *pointer* to a backend.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
- BlockDriverState*/BlockBackend*
I am not very familiar with the block subsystem, but it is seems BlockBackend is actually the backend and BlockDriverState is implementation data detail. Correct me if I'm wrong
Yes, note the "*". What I meant above is "the frontend has a BlockBackend*, which itself has the internal BlockDriverState*". Same for character and NICs below.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
- Chardev*/CharBackend
Those are actually always confusing... and I remember I attempted to rename it in the past... CharBackend is the front-end side..
Yes, they are confusing. I'm not sure why it failed, but s/CharBackend/CharFrontend/ does get my vote.
Quoted 3 lines
Quoted 2 lines
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
Quoted 8 lines
Quoted 3 lines
For audio, it's pretty obvious that we have "backend" object to implement the host audio subsystem details, while "QEMUSoundCard" is the "frontend", or "client/user" context.
I agree, but unlike character devices, QEMUSoundCard is not needed at all. So you can drop it and only leave Audiodev*, or AudioBackend* (but I prefer Audiodev* which matches both the option name and Chardev*).
I see, I'll try to remove QEMUSoundCard.
AudioState can't easily be renamed to "Audiodev" though, since that's the QAPI type name. There are slight typename differences between QAPI types for chardev and audiodev. Is it breaking QMP APIs to change typenames? I guess not, I might be wrong. However, this will likely break external code generators based on QAPI (qapi-rs etc)..
Signature · 1 line
Marc-André Lureau
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
Quoted 43 lines · Marc-André Lureau
Quoted 33 lines · Paolo Bonzini
Quoted 6 lines · Marc-André Lureau
Quoted 1 line
Quoted 1 line
BE and FE aren't used in existing code though. Looking at current use:
There is a top-level backends/ though. I meant to say that it's usually clearer for everyone when we talk about "backend" vs "frontend" (or not?), and I wish we would follow that naming more in the code.
Yes, but the front-end should have a *pointer* to a backend.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
- BlockDriverState*/BlockBackend*
I am not very familiar with the block subsystem, but it is seems BlockBackend is actually the backend and BlockDriverState is implementation data detail. Correct me if I'm wrong
Yes, note the "*". What I meant above is "the frontend has a BlockBackend*, which itself has the internal BlockDriverState*". Same for character and NICs below.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
- Chardev*/CharBackend
Those are actually always confusing... and I remember I attempted to rename it in the past... CharBackend is the front-end side..
Yes, they are confusing. I'm not sure why it failed, but s/CharBackend/CharFrontend/ does get my vote.
Quoted 3 lines
Quoted 2 lines
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
Quoted 8 lines
Quoted 3 lines
For audio, it's pretty obvious that we have "backend" object to implement the host audio subsystem details, while "QEMUSoundCard" is the "frontend", or "client/user" context.
I agree, but unlike character devices, QEMUSoundCard is not needed at all. So you can drop it and only leave Audiodev*, or AudioBackend* (but I prefer Audiodev* which matches both the option name and Chardev*).
Quoted 7 lines
I see, I'll try to remove QEMUSoundCard.
AudioState can't easily be renamed to "Audiodev" though, since that's the QAPI type name. There are slight typename differences between QAPI types for chardev and audiodev. Is it breaking QMP APIs to change typenames? I guess not, I might be wrong. However, this will likely break external code generators based on QAPI (qapi-rs etc)..
I'm getting lost where this is going but keeping AudioState for the QOM type seems better than using another name just to try to be consistent with char backends that was said to have a confusing naming above. So maybe keep the QOM convention for audio and call it AudioState and later try to match Char to this if that needs similar QOM'ification? If this is replacing QEMUSoundCard then maybe AudioCard can also be considered for keeping consistency with local names. But I don't know what I'm talking about so I stop here and let you agree on something.
Regards,
BALATON Zoltan
Re: [PATCH 34/43] audio: rename AudioState -> AudioBE
In reply to Marc-André LureauQuoted 46 lines · Marc-André Lureau
Hi
Quoted 5 lines · Paolo Bonzini
Quoted 3 lines · Paolo Bonzini
Quoted 2 lines · On 10/21/25 11:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Naming is hard. But in general in QEMU, a host "backend" is the term used to fullfill the request made by the device "frontend".
Note that "audiodev" is the corresponding QAPI type name (or configuration).
BE and FE aren't used in existing code though. Looking at current use:
There is a top-level backends/ though. I meant to say that it's usually clearer for everyone when we talk about "backend" vs "frontend" (or not?), and I wish we would follow that naming more in the code.
Quoted 3 lines
Quoted 3 lines
- BlockDriverState*/BlockBackend*
I am not very familiar with the block subsystem, but it is seems BlockBackend is actually the backend and BlockDriverState is implementation data detail. Correct me if I'm wrong
Quoted 2 lines
Quoted 2 lines
- Chardev*/CharBackend
Those are actually always confusing... and I remember I attempted to rename it in the past... CharBackend is the front-end side..
Quoted 10 lines
Quoted 4 lines
- NetClientState*/NICState*
... it's actually quite common for the *frontend* to have a pointer or object of type FooBackend; that would give Audiodev* and AudioBackend*.
Hmm, I have to correct myself.
QEMUSoundCard's name field is basically unused, and QEMUSoundCard should be just an Audiodev*. There's no need for a separate AudioFE struct.
Quoted 8 lines
For audio, it's pretty obvious that we have "backend" object to implement the host audio subsystem details, while "QEMUSoundCard" is the "frontend", or "client/user" context.
Imho, it's clearer to see the relation between the two objects if we name them "backend" and "frontend" accordingly. If the "AudioBE" & "AudioFE" short versions aren't readable enough, I am fine naming "AudioBackend" & "AudioFrontend"
AudioBE is confusing as BE often stands for big endian and no example of using it for Backend. Thus AudioBackend while longer is clearer so gets my vote too (or anthing else less confusing than AudioBE).
Regards,
BALATON Zoltan
PATCH 35/43 audio: rename QEMUSoundCard -> AudioFE
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 20 ++++++++++---------- audio/audio_int.h | 6 +++--- audio/audio_template.h | 4 ++-- hw/audio/lm4549.h | 2 +- include/hw/audio/asc.h | 2 +- include/hw/audio/virtio-snd.h | 2 +- include/hw/display/xlnx_dp.h | 2 +- include/hw/isa/vt82c686.h | 2 +- include/hw/qdev-properties-system.h | 2 +- audio/audio.c | 10 +++++----- hw/audio/ac97.c | 6 +++--- hw/audio/adlib.c | 6 +++--- hw/audio/asc.c | 6 +++--- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 6 +++--- hw/audio/lm4549.c | 2 +- hw/audio/pcspk.c | 4 ++-- hw/audio/sb16.c | 4 ++-- hw/audio/via-ac97.c | 4 ++-- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 6 +++--- hw/core/qdev-properties-system.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 6 +++--- 26 files changed, 64 insertions(+), 64 deletions(-)
audio/audio.h +10 -10
@@ -70,18 +70,18 @@ struct AudioBEClass { };typedef struct AudioBE AudioBE ; -typedef struct QEMUSoundCard { +typedef struct AudioFE {char *name;AudioBE *be; -QLIST_ENTRY (QEMUSoundCard) entries; -}QEMUSoundCard ; +QLIST_ENTRY (AudioFE) entries; +}AudioFE ;typedef struct QEMUAudioTimeStamp {uint64_t old_ts; }QEMUAudioTimeStamp ; -bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp); -void AUD_remove_card (QEMUSoundCard *card); +bool AUD_register_fe (const char *name,AudioFE *fe,Error **errp); +void AUD_unregister_fe (AudioFE *fe); CaptureVoiceOut *AUD_add_capture( AudioBE *s, struct audsettings *as,
@@ -91,7 +91,7 @@ CaptureVoiceOut *AUD_add_capture(void AUD_del_capture (CaptureVoiceOut *cap,void *cb_opaque); SWVoiceOut *AUD_open_out ( - QEMUSoundCard *card, + AudioFE *fe, SWVoiceOut *sw, const char *name, void *callback_opaque,
@@ -99,7 +99,7 @@ SWVoiceOut *AUD_open_out (struct audsettings *settings ); -void AUD_close_out (QEMUSoundCard *card,SWVoiceOut *sw); +void AUD_close_out (AudioFE *fe,SWVoiceOut *sw);size_t AUD_write (SWVoiceOut *sw,void *pcm_buf,size_t size);int AUD_get_buffer_size_out (SWVoiceOut *sw);void AUD_set_active_out (SWVoiceOut *sw,int on);
@@ -122,7 +122,7 @@ void AUD_set_volume_out(SWVoiceOut *sw, Volume *vol);void AUD_set_volume_in (SWVoiceIn *sw,Volume *vol); SWVoiceIn *AUD_open_in ( - QEMUSoundCard *card, + AudioFE *fe, SWVoiceIn *sw, const char *name, void *callback_opaque,
@@ -130,7 +130,7 @@ SWVoiceIn *AUD_open_in (struct audsettings *settings ); -void AUD_close_in (QEMUSoundCard *card,SWVoiceIn *sw); +void AUD_close_in (AudioFE *fe,SWVoiceIn *sw);size_t AUD_read (SWVoiceIn *sw,void *pcm_buf,size_t size);void AUD_set_active_in (SWVoiceIn *sw,int on);int AUD_is_active_in (SWVoiceIn *sw);
@@ -156,7 +156,7 @@ void audio_help(void);AudioBE *audio_be_by_name (const char *name,Error **errp);AudioBE *audio_get_default_audio_be (Error **errp); -const char *audio_get_id (QEMUSoundCard *card); +const char *audio_get_id (AudioFE *fe);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f)
audio/audio_int.h +3 -3
@@ -108,7 +108,7 @@ typedef struct HWVoiceIn { } HWVoiceIn;struct SWVoiceOut { -QEMUSoundCard *card; +AudioFE *card;AudioBE *s;struct audio_pcm_info info;t_sample *conv;
@@ -125,7 +125,7 @@ struct SWVoiceOut { };struct SWVoiceIn { -QEMUSoundCard *card; +AudioFE *card;AudioBE *s;int active;struct audio_pcm_info info;
@@ -246,7 +246,7 @@ typedef struct AudioBE {void *drv_opaque;QEMUTimer *ts; - QLIST_HEAD (card_listhead, QEMUSoundCard) card_head; + QLIST_HEAD (fe_listhead, AudioFE) fe_head; QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in; QLIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out; QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
audio/audio_template.h +2 -2
@@ -473,7 +473,7 @@ static void glue (audio_close_, TYPE) (SW *sw)g_free (sw); } -void glue (AUD_close_ ,TYPE ) (QEMUSoundCard *card,SW *sw) +void glue (AUD_close_ ,TYPE ) (AudioFE *card,SW *sw) {if (sw) {if (audio_bug (__func__, !card)) {
@@ -486,7 +486,7 @@ void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw) } SW *glue (AUD_open_, TYPE) ( - QEMUSoundCard *card, + AudioFE *card, SW *sw, const char *name, void *callback_opaque ,
hw/audio/lm4549.h +1 -1
@@ -21,7 +21,7 @@ typedef void (*lm4549_callback)(void *opaque); typedef struct { - QEMUSoundCard card; + AudioFE card; SWVoiceOut *voice; uint32_t voice_is_active;
include/hw/audio/asc.h +1 -1
@@ -61,7 +61,7 @@ struct ASCState {MemoryRegion mem_regs;MemoryRegion mem_extregs; -QEMUSoundCard card; +AudioFE card;SWVoiceOut *voice;uint8_t *mixbuf;int samples;
include/hw/audio/virtio-snd.h +1 -1
@@ -216,7 +216,7 @@ struct VirtIOSound {VirtQueue *queues[VIRTIO_SND_VQ_MAX ];uint64_t features;VirtIOSoundPCM *pcm; -QEMUSoundCard card; +AudioFE card;VMChangeStateEntry *vmstate;virtio_snd_config snd_conf;QemuMutex cmdq_mutex;
include/hw/display/xlnx_dp.h +1 -1
@@ -84,7 +84,7 @@ struct XlnxDPState {struct PixmanPlane v_plane;struct PixmanPlane bout_plane; -QEMUSoundCard aud_card; +AudioFE aud_card;SWVoiceOut *amixer_output_stream;int16_t audio_buffer_0[AUD_CHBUF_MAX_DEPTH ];int16_t audio_buffer_1[AUD_CHBUF_MAX_DEPTH ];
include/hw/isa/vt82c686.h +1 -1
@@ -24,7 +24,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(ViaAC97State, VIA_AC97);struct ViaAC97State {PCIDevice dev; -QEMUSoundCard card; +AudioFE card;MemoryRegion sgd;MemoryRegion fm;MemoryRegion midi;
include/hw/qdev-properties-system.h +1 -1
@@ -87,7 +87,7 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list; .set_default = true)#define DEFINE_PROP_AUDIODEV (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) + DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, AudioFE)#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID)
audio/audio.c +5 -5
@@ -1620,7 +1620,7 @@ static void audio_be_init(Object *obj)QLIST_INIT (&s->hw_head_out);QLIST_INIT (&s->hw_head_in);QLIST_INIT (&s->cap_head); -QLIST_INIT (&s->card_head); +QLIST_INIT (&s->fe_head); s->ts =timer_new_ns (QEMU_CLOCK_VIRTUAL , audio_timer, s); s->vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
@@ -1812,7 +1812,7 @@ AudioBE *audio_get_default_audio_be(Error **errp)return default_audio_be; } -bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp) +bool AUD_register_fe (const char *name,AudioFE *card,Error **errp) {if (!card->be) { card->be =audio_get_default_audio_be (errp);
@@ -1823,12 +1823,12 @@ bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp) card->name =g_strdup (name);memset (&card->entries,0 ,sizeof (card->entries)); -QLIST_INSERT_HEAD (&card->be->card_head, card, entries); +QLIST_INSERT_HEAD (&card->be->fe_head, card, entries);return true; } -void AUD_remove_card (QEMUSoundCard *card) +void AUD_unregister_fe (AudioFE *card) {QLIST_REMOVE (card, entries);g_free (card->name);
@@ -2232,7 +2232,7 @@ AudioBE *audio_be_by_name(const char *name, Error **errp) } } -const char *audio_get_id (QEMUSoundCard *card) +const char *audio_get_id (AudioFE *card) {if (card->be) {assert (card->be->dev);
hw/audio/ac97.c +3 -3
@@ -120,7 +120,7 @@ typedef struct AC97BusMasterRegs {struct AC97LinkState {PCIDevice dev; -QEMUSoundCard card; +AudioFE card;uint32_t glob_cnt;uint32_t glob_sta;uint32_t cas;
@@ -1271,7 +1271,7 @@ static void ac97_realize(PCIDevice *dev, Error **errp)AC97LinkState *s =AC97 (dev);uint8_t *c = s->dev.config; -if (!AUD_register_card ("ac97" , &s->card, errp)) { +if (!AUD_register_fe ("ac97" , &s->card, errp)) {return ; }
@@ -1319,7 +1319,7 @@ static void ac97_exit(PCIDevice *dev)AUD_close_in (&s->card, s->voice_pi);AUD_close_out (&s->card, s->voice_po);AUD_close_in (&s->card, s->voice_mc); -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card); }static const Property ac97_properties[] = {
hw/audio/adlib.c +3 -3
@@ -53,7 +53,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AdlibState, ADLIB)struct AdlibState {ISADevice parent_obj; -QEMUSoundCard card; +AudioFE card;uint32_t freq;uint32_t port;int ticking[2 ];
@@ -236,7 +236,7 @@ static void Adlib_fini (AdlibState *s) s->active =0 ; s->enabled =0 ; -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card); }static MemoryRegionPortio adlib_portio_list[] = {
@@ -251,7 +251,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp)AdlibState *s =ADLIB (dev);struct audsettings as; -if (!AUD_register_card ("adlib" , &s->card, errp)) { +if (!AUD_register_fe ("adlib" , &s->card, errp)) {return ; }
hw/audio/asc.c +3 -3
@@ -635,7 +635,7 @@ static void asc_unrealize(DeviceState *dev)g_free (s->mixbuf);g_free (s->silentbuf); -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card); }static void asc_realize (DeviceState *dev,Error **errp)
@@ -643,7 +643,7 @@ static void asc_realize(DeviceState *dev, Error **errp)ASCState *s =ASC (dev);struct audsettings as; -if (!AUD_register_card ("Apple Sound Chip" , &s->card, errp)) { +if (!AUD_register_fe ("Apple Sound Chip" , &s->card, errp)) {return ; }
@@ -655,7 +655,7 @@ static void asc_realize(DeviceState *dev, Error **errp) s->voice =AUD_open_out (&s->card, s->voice,"asc.out" , s, asc_out_cb, &as);if (!s->voice) { -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card);error_setg (errp,"Initializing audio stream failed" );return ; }
hw/audio/cs4231a.c +2 -2
@@ -65,7 +65,7 @@ DECLARE_INSTANCE_CHECKER(CSState, CS4231A,struct CSState {ISADevice dev; -QEMUSoundCard card; +AudioFE card;MemoryRegion ioports;qemu_irq pic;uint32_t regs[CS_REGS ];
@@ -674,7 +674,7 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)return ; } -if (!AUD_register_card ("cs4231a" , &s->card, errp)) { +if (!AUD_register_fe ("cs4231a" , &s->card, errp)) {return ; }
hw/audio/es1370.c +3 -3
@@ -258,7 +258,7 @@ struct chan {struct ES1370State {PCIDevice dev; -QEMUSoundCard card; +AudioFE card;MemoryRegion io;struct chan chan[NB_CHANNELS ];SWVoiceOut *dac_voice[2 ];
@@ -833,7 +833,7 @@ static void es1370_realize(PCIDevice *dev, Error **errp)ES1370State *s =ES1370 (dev);uint8_t *c = s->dev.config; -if (!AUD_register_card ("es1370" , &s->card, errp)) { +if (!AUD_register_fe ("es1370" , &s->card, errp)) {return ; }
@@ -865,7 +865,7 @@ static void es1370_exit(PCIDevice *dev) }AUD_close_in (&s->card, s->adc_voice); -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card); }static const Property es1370_properties[] = {
hw/audio/gus.c +3 -3
@@ -45,7 +45,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GUSState, GUS)struct GUSState {ISADevice dev;GUSEmuState emu; -QEMUSoundCard card; +AudioFE card;uint32_t freq;uint32_t port;int pos, left, shift, irqs;
@@ -238,7 +238,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp)IsaDmaClass *k;struct audsettings as; -if (!AUD_register_card ("gus" , &s->card, errp)) { +if (!AUD_register_fe ("gus" , &s->card, errp)) {return ; }
@@ -263,7 +263,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp) );if (!s->voice) { -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card);error_setg (errp,"No voice" );return ; }
hw/audio/hda-codec.c +3 -3
@@ -178,7 +178,7 @@ struct HDAAudioState {HDACodecDevice hda;const char *name; -QEMUSoundCard card; +AudioFE card;const desc_codec *desc;HDAAudioStream st[4 ];bool running_compat[16 ];
@@ -696,7 +696,7 @@ static void hda_audio_init(HDACodecDevice *hda,const desc_param *param;uint32_t i, type; -if (!AUD_register_card ("hda" , &a->card, errp)) { +if (!AUD_register_fe ("hda" , &a->card, errp)) {return ; }
@@ -759,7 +759,7 @@ static void hda_audio_exit(HDACodecDevice *hda)AUD_close_in (&a->card, st->voice.in); } } -AUD_remove_card (&a->card); +AUD_unregister_fe (&a->card); }static int hda_audio_post_load (void *opaque,int version)
hw/audio/lm4549.c +1 -1
@@ -282,7 +282,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_req_cb, void* opaque,struct audsettings as;/* Register an audio card */ -if (!AUD_register_card ("lm4549" , &s->card, errp)) { +if (!AUD_register_fe ("lm4549" , &s->card, errp)) {return ; }
hw/audio/pcspk.c +2 -2
@@ -48,7 +48,7 @@ struct PCSpkState {MemoryRegion ioport;uint32_t iobase;uint8_t sample_buf[PCSPK_BUF_LEN ]; -QEMUSoundCard card; +AudioFE card;SWVoiceOut *voice;PITCommonState *pit;unsigned int pit_count;
@@ -188,7 +188,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &s->ioport, s->iobase); -if (s->card.be &&AUD_register_card (s_spk, &s->card, errp)) { +if (s->card.be &&AUD_register_fe (s_spk, &s->card, errp)) {pcspk_audio_init (s); } }
hw/audio/sb16.c +2 -2
@@ -50,7 +50,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(SB16State, SB16)struct SB16State {ISADevice parent_obj; -QEMUSoundCard card; +AudioFE card;qemu_irq pic;uint32_t irq;uint32_t dma;
@@ -1397,7 +1397,7 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)SB16State *s =SB16 (dev);IsaDmaClass *k; -if (!AUD_register_card ("sb16" , &s->card, errp)) { +if (!AUD_register_fe ("sb16" , &s->card, errp)) {return ; }
hw/audio/via-ac97.c +2 -2
@@ -426,7 +426,7 @@ static void via_ac97_realize(PCIDevice *pci_dev, Error **errp)ViaAC97State *s =VIA_AC97 (pci_dev);Object *o =OBJECT (s); -if (!AUD_register_card ("via-ac97" , &s->card, errp)) { +if (!AUD_register_fe ("via-ac97" , &s->card, errp)) {return ; }
@@ -456,7 +456,7 @@ static void via_ac97_exit(PCIDevice *dev)ViaAC97State *s =VIA_AC97 (dev);AUD_close_out (&s->card, s->vo); -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card); }static const Property via_ac97_properties[] = {
hw/audio/virtio-snd.c +2 -2
@@ -1053,7 +1053,7 @@ static void virtio_snd_realize(DeviceState *dev, Error **errp)return ; } -if (!AUD_register_card ("virtio-sound" , &vsnd->card, errp)) { +if (!AUD_register_fe ("virtio-sound" , &vsnd->card, errp)) {return ; }
@@ -1330,7 +1330,7 @@ static void virtio_snd_unrealize(DeviceState *dev)g_free (vsnd->pcm); vsnd->pcm =NULL ; } -AUD_remove_card (&vsnd->card); +AUD_unregister_fe (&vsnd->card);qemu_mutex_destroy (&vsnd->cmdq_mutex);virtio_delete_queue (vsnd->queues[VIRTIO_SND_VQ_CONTROL ]);virtio_delete_queue (vsnd->queues[VIRTIO_SND_VQ_EVENT ]);
hw/audio/wm8750.c +3 -3
@@ -34,7 +34,7 @@ struct WM8750State {uint8_t i2c_data[2 ];int i2c_len; -QEMUSoundCard card; +AudioFE card;SWVoiceIn *adc_voice[IN_PORT_N ];SWVoiceOut *dac_voice[OUT_PORT_N ];int enable;
@@ -624,7 +624,7 @@ static void wm8750_realize(DeviceState *dev, Error **errp) {WM8750State *s =WM8750 (dev); -if (!AUD_register_card (CODEC , &s->card, errp)) { +if (!AUD_register_fe (CODEC , &s->card, errp)) {return ; }
@@ -637,7 +637,7 @@ static void wm8750_fini(I2CSlave *i2c)WM8750State *s =WM8750 (i2c);wm8750_reset (I2C_SLAVE (s)); -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card); g_free(s); }#endif
hw/core/qdev-properties-system.c +2 -2
@@ -487,7 +487,7 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name, void *opaque, Error **errp) { const Property *prop = opaque; -QEMUSoundCard *card =object_field_prop_ptr (obj, prop); +AudioFE *card =object_field_prop_ptr (obj, prop);char *p =g_strdup (audio_get_id (card));visit_type_str (v, name, &p, errp);
@@ -498,7 +498,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, void *opaque, Error **errp) { const Property *prop = opaque; -QEMUSoundCard *card =object_field_prop_ptr (obj, prop); +AudioFE *card =object_field_prop_ptr (obj, prop);AudioBE *state; g_autofree char *str = NULL;
hw/display/xlnx_dp.c +1 -1
@@ -1306,7 +1306,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp)DisplaySurface *surface;struct audsettings as; -if (!AUD_register_card ("xlnx_dp.audio" , &s->aud_card, errp)) { +if (!AUD_register_fe ("xlnx_dp.audio" , &s->aud_card, errp)) {return ; }
hw/usb/dev-audio.c +3 -3
@@ -635,7 +635,7 @@ static uint8_t *streambuf_get(struct streambuf *buf, size_t *len)struct USBAudioState {/* qemu interfaces */ USBDevice dev; -QEMUSoundCard card; +AudioFE card;/* state */ struct {
@@ -932,7 +932,7 @@ static void usb_audio_unrealize(USBDevice *dev)usb_audio_set_output_altset (s,ALTSET_OFF );AUD_close_out (&s->card, s->out.voice); -AUD_remove_card (&s->card); +AUD_unregister_fe (&s->card);streambuf_fini (&s->out.buf); }
@@ -942,7 +942,7 @@ static void usb_audio_realize(USBDevice *dev, Error **errp)USBAudioState *s =USB_AUDIO (dev);int i; -if (!AUD_register_card (TYPE_USB_AUDIO , &s->card, errp)) { +if (!AUD_register_fe (TYPE_USB_AUDIO , &s->card, errp)) {return ; }
Signature · 1 line
2.51.0
Re: [PATCH 35/43] audio: rename QEMUSoundCard -> AudioFE
Quoted 37 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>---
audio/audio.h | 20 ++++++++++---------- audio/audio_int.h | 6 +++--- audio/audio_template.h | 4 ++-- hw/audio/lm4549.h | 2 +- include/hw/audio/asc.h | 2 +- include/hw/audio/virtio-snd.h | 2 +- include/hw/display/xlnx_dp.h | 2 +- include/hw/isa/vt82c686.h | 2 +- include/hw/qdev-properties-system.h | 2 +- audio/audio.c | 10 +++++----- hw/audio/ac97.c | 6 +++--- hw/audio/adlib.c | 6 +++--- hw/audio/asc.c | 6 +++--- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 6 +++--- hw/audio/lm4549.c | 2 +- hw/audio/pcspk.c | 4 ++-- hw/audio/sb16.c | 4 ++-- hw/audio/via-ac97.c | 4 ++-- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 6 +++--- hw/core/qdev-properties-system.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 6 +++--- 26 files changed, 64 insertions(+), 64 deletions(-)audio/audio.h +0
-0
audio/audio.h struct AudioBEClass { · line 73
Quoted 5 lines
audio/audio.h +1
-1@@ -70,18 +70,18 @@ struct AudioBEClass { };typedef struct AudioBE AudioBE ; -typedef struct QEMUSoundCard { +typedef struct AudioFE {
You could also leave it as it is. While it's a bit odd naming it's clear enough and not at least the local variables now called "card" match the type which would not be the case if you rename it to Audiodev or something else but not rename all the locals. So maybe it does not worth the churn to change this type name.
Regards,
BALATON Zoltan
Re: [PATCH 35/43] audio: rename QEMUSoundCard -> AudioFE
Hi
Quoted 41 lines · BALATON Zoltan
Quoted 39 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>---
audio/audio.h | 20 ++++++++++---------- audio/audio_int.h | 6 +++--- audio/audio_template.h | 4 ++-- hw/audio/lm4549.h | 2 +- include/hw/audio/asc.h | 2 +- include/hw/audio/virtio-snd.h | 2 +- include/hw/display/xlnx_dp.h | 2 +- include/hw/isa/vt82c686.h | 2 +- include/hw/qdev-properties-system.h | 2 +- audio/audio.c | 10 +++++----- hw/audio/ac97.c | 6 +++--- hw/audio/adlib.c | 6 +++--- hw/audio/asc.c | 6 +++--- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 6 +++--- hw/audio/lm4549.c | 2 +- hw/audio/pcspk.c | 4 ++-- hw/audio/sb16.c | 4 ++-- hw/audio/via-ac97.c | 4 ++-- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 6 +++--- hw/core/qdev-properties-system.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 6 +++--- 26 files changed, 64 insertions(+), 64 deletions(-)audio/audio.h +0
-0@@ -70,18 +70,18 @@ struct AudioBEClass { };
Quoted 9 lines
audio/audio.h struct AudioBEClass { · line 73
Quoted 3 lines
audio/audio.h +1
-1typedef struct AudioBE AudioBE ; -typedef struct QEMUSoundCard { +typedef struct AudioFE {You could also leave it as it is. While it's a bit odd naming it's clear enough and not at least the local variables now called "card" match the type which would not be the case if you rename it to Audiodev or something else but not rename all the locals. So maybe it does not worth the churn to change this type name.
I think it's still worth it. Local variables are locals, and usually easy to understand by the context and using their types. It's easy to rename "card" to "audio_fe" or "frontend" though, I can do this in this change too.
Signature · 1 line
Marc-André Lureau
Re: [PATCH 35/43] audio: rename QEMUSoundCard -> AudioFE
Quoted 52 lines · Marc-André Lureau
Quoted 41 lines · BALATON Zoltan
Quoted 39 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>---
audio/audio.h | 20 ++++++++++---------- audio/audio_int.h | 6 +++--- audio/audio_template.h | 4 ++-- hw/audio/lm4549.h | 2 +- include/hw/audio/asc.h | 2 +- include/hw/audio/virtio-snd.h | 2 +- include/hw/display/xlnx_dp.h | 2 +- include/hw/isa/vt82c686.h | 2 +- include/hw/qdev-properties-system.h | 2 +- audio/audio.c | 10 +++++----- hw/audio/ac97.c | 6 +++--- hw/audio/adlib.c | 6 +++--- hw/audio/asc.c | 6 +++--- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 6 +++--- hw/audio/lm4549.c | 2 +- hw/audio/pcspk.c | 4 ++-- hw/audio/sb16.c | 4 ++-- hw/audio/via-ac97.c | 4 ++-- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 6 +++--- hw/core/qdev-properties-system.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 6 +++--- 26 files changed, 64 insertions(+), 64 deletions(-)audio/audio.h +0
-0@@ -70,18 +70,18 @@ struct AudioBEClass { };Quoted 9 lines
audio/audio.h struct AudioBEClass { · line 73
Quoted 3 lines
audio/audio.h +1
-1typedef struct AudioBE AudioBE ; -typedef struct QEMUSoundCard { +typedef struct AudioFE {You could also leave it as it is. While it's a bit odd naming it's clear enough and not at least the local variables now called "card" match the type which would not be the case if you rename it to Audiodev or something else but not rename all the locals. So maybe it does not worth the churn to change this type name.
Quoted 4 lines
I think it's still worth it. Local variables are locals, and usually easy to understand by the context and using their types. It's easy to rename "card" to "
audio_fe" or "frontend" though, I can do this in this change too.
The point is to have less churn not more so renaming locals from card to fe or something (but definitely not to a longer name than currently) would just be more churn for not much more clarity. Therefore I argued that living with QEMUSoundCard type name is better as it keeps consistency with local naming and avoids churn. The current type name does not match anything else in QEMU but it's clear (even more clear than the proposed AudioFE) so I'd accept this small inconsistency in naming for avoiding a lot of churn. If you still want to rename it could we call it AudioCard to keep consistency with locals or Audiodev what Paolo proposed which is still clearer than AudioFE? But I'd just leave it as it is as the simplest solution.
Regards,
BALATON Zoltan
Re: [PATCH 35/43] audio: rename QEMUSoundCard -> AudioFE
Hi
Quoted 54 lines · BALATON Zoltan
Quoted 52 lines · Marc-André Lureau
Quoted 50 lines · BALATON Zoltan
Quoted 37 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>---
audio/audio.h | 20 ++++++++++---------- audio/audio_int.h | 6 +++--- audio/audio_template.h | 4 ++-- hw/audio/lm4549.h | 2 +- include/hw/audio/asc.h | 2 +- include/hw/audio/virtio-snd.h | 2 +- include/hw/display/xlnx_dp.h | 2 +- include/hw/isa/vt82c686.h | 2 +- include/hw/qdev-properties-system.h | 2 +- audio/audio.c | 10 +++++----- hw/audio/ac97.c | 6 +++--- hw/audio/adlib.c | 6 +++--- hw/audio/asc.c | 6 +++--- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 6 +++--- hw/audio/lm4549.c | 2 +- hw/audio/pcspk.c | 4 ++-- hw/audio/sb16.c | 4 ++-- hw/audio/via-ac97.c | 4 ++-- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 6 +++--- hw/core/qdev-properties-system.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 6 +++--- 26 files changed, 64 insertions(+), 64 deletions(-)audio/audio.h +0
-0audio/audio.h struct AudioBEClass { · line 73
Quoted 5 lines
audio/audio.h +1
-1@@ -70,18 +70,18 @@ struct AudioBEClass { };typedef struct AudioBE AudioBE ; -typedef struct QEMUSoundCard { +typedef struct AudioFE {You could also leave it as it is. While it's a bit odd naming it's clear enough and not at least the local variables now called "card" match the type which would not be the case if you rename it to Audiodev or something else but not rename all the locals. So maybe it does not worth the churn to change this type name.
Quoted 8 lines
Quoted 4 lines
I think it's still worth it. Local variables are locals, and usually easy to understand by the context and using their types. It's easy to rename "card" to "
audio_fe" or "frontend" though, I can do this in this change too.The point is to have less churn not more so renaming locals from card to fe or something (but definitely not to a longer name than currently) would just be more churn for not much more clarity. Therefore I argued that
Renaming is making churn, I agree. But if the end result allows more readable code, even slightly, we should consider it.
Imho AudioState and QEMUSoundCard are bad type names that don't help. I value type names a lot more than variable names, especially now that we have LSP, I am probably not the only one.
I proposed AudioBE and AudioFE, for simplicity consistency and to avoid some naming clashes with QAPI types.
Agree, BE and FE are not the most readable, so AudioBackend and AudioFrontend seems agreeable (local variables or in fn_name_for_be use usually a shorter version though).
And Paolo suggested to remove AudioFrontend (QEMUSoundCard) altogether, which I also think makes sense.
Quoted 11 lines
living with QEMUSoundCard type name is better as it keeps consistency with local naming and avoids churn. The current type name does not match anything else in QEMU but it's clear (even more clear than the proposed AudioFE) so I'd accept this small inconsistency in naming for avoiding a lot of churn. If you still want to rename it could we call it AudioCard to keep consistency with locals or Audiodev what Paolo proposed which is still clearer than AudioFE? But I'd just leave it as it is as the simplest solution.
Regards,
BALATON Zoltan
Signature · 1 line
Marc-André Lureau
Re: [PATCH 35/43] audio: rename QEMUSoundCard -> AudioFE
Quoted 73 lines · Marc-André Lureau
Hi
Quoted 54 lines · BALATON Zoltan
Quoted 52 lines · Marc-André Lureau
Quoted 50 lines · BALATON Zoltan
Quoted 37 lines · On Tue, 21 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>---
audio/audio.h | 20 ++++++++++---------- audio/audio_int.h | 6 +++--- audio/audio_template.h | 4 ++-- hw/audio/lm4549.h | 2 +- include/hw/audio/asc.h | 2 +- include/hw/audio/virtio-snd.h | 2 +- include/hw/display/xlnx_dp.h | 2 +- include/hw/isa/vt82c686.h | 2 +- include/hw/qdev-properties-system.h | 2 +- audio/audio.c | 10 +++++----- hw/audio/ac97.c | 6 +++--- hw/audio/adlib.c | 6 +++--- hw/audio/asc.c | 6 +++--- hw/audio/cs4231a.c | 4 ++-- hw/audio/es1370.c | 6 +++--- hw/audio/gus.c | 6 +++--- hw/audio/hda-codec.c | 6 +++--- hw/audio/lm4549.c | 2 +- hw/audio/pcspk.c | 4 ++-- hw/audio/sb16.c | 4 ++-- hw/audio/via-ac97.c | 4 ++-- hw/audio/virtio-snd.c | 4 ++-- hw/audio/wm8750.c | 6 +++--- hw/core/qdev-properties-system.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 6 +++--- 26 files changed, 64 insertions(+), 64 deletions(-)audio/audio.h +0
-0audio/audio.h struct AudioBEClass { · line 73
Quoted 5 lines
audio/audio.h +1
-1@@ -70,18 +70,18 @@ struct AudioBEClass { };typedef struct AudioBE AudioBE ; -typedef struct QEMUSoundCard { +typedef struct AudioFE {You could also leave it as it is. While it's a bit odd naming it's clear enough and not at least the local variables now called "card" match the type which would not be the case if you rename it to Audiodev or something else but not rename all the locals. So maybe it does not worth the churn to change this type name.
Quoted 8 lines
Quoted 4 lines
I think it's still worth it. Local variables are locals, and usually easy to understand by the context and using their types. It's easy to rename "card" to "
audio_fe" or "frontend" though, I can do this in this change too.The point is to have less churn not more so renaming locals from card to fe or something (but definitely not to a longer name than currently) would just be more churn for not much more clarity. Therefore I argued that
Renaming is making churn, I agree. But if the end result allows more readable code, even slightly, we should consider it.
Imho AudioState and QEMUSoundCard are bad type names that don't help. I value type names a lot more than variable names, especially now that we have LSP, I am probably not the only one.
Quoted 6 lines
I proposed AudioBE and AudioFE, for simplicity consistency and to avoid some naming clashes with QAPI types.
Agree, BE and FE are not the most readable, so AudioBackend and AudioFrontend seems agreeable (local variables or in
fn_name_for_beuse usually a shorter version though).
I find both ChardevFrontend and AudioFrontend as somewhat confusing, because the Device is frontend. IIUC ChardevFrontend/AudioFrontend act more like a way to associate a frontend and backend together. Can we call the objects something like a "Connection" / "Attachment" / "Link" ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 36/43 audio: rename audio_get_id()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 2 +- audio/audio.c | 2 +- hw/core/qdev-properties-system.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
audio/audio.h +1 -1
@@ -156,7 +156,7 @@ void audio_help(void);AudioBE *audio_be_by_name (const char *name,Error **errp);AudioBE *audio_get_default_audio_be (Error **errp); -const char *audio_get_id (AudioFE *fe); +const char *audio_fe_get_be_id (AudioFE *fe);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f)
audio/audio.c +1 -1
@@ -2232,7 +2232,7 @@ AudioBE *audio_be_by_name(const char *name, Error **errp) } } -const char *audio_get_id (AudioFE *card) +const char *audio_fe_get_be_id (AudioFE *card) {if (card->be) {assert (card->be->dev);
hw/core/qdev-properties-system.c +1 -1
@@ -488,7 +488,7 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name, {const Property *prop = opaque;AudioFE *card =object_field_prop_ptr (obj, prop); -char *p =g_strdup (audio_get_id (card)); +char *p =g_strdup (audio_fe_get_be_id (card));visit_type_str (v, name, &p, errp);g_free (p);
Signature · 1 line
2.51.0
PATCH 37/43 audio/dbus: use a helper function to set the backend dbus server
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- audio/audio.h | 6 ++++++ audio/audio_int.h | 2 +- audio/audio.c | 14 ++++++++++++++ audio/dbusaudio.c | 6 ++++-- ui/dbus.c | 8 +------- 5 files changed, 26 insertions(+), 10 deletions(-)
audio/audio.h +6 -0
@@ -28,6 +28,9 @@#include "qemu/queue.h" #include "qapi/qapi-types-audio.h" #include "hw/qdev-properties-system.h" +#ifdef CONFIG_GIO +#include "gio/gio.h" +#endif typedef void (*audio_callback_fn ) (void *opaque,int avail);
@@ -157,6 +160,9 @@ void audio_help(void);AudioBE *audio_be_by_name (const char *name,Error **errp);AudioBE *audio_get_default_audio_be (Error **errp);const char *audio_fe_get_be_id (AudioFE *fe); +#ifdef CONFIG_GIO +bool audio_be_set_dbus_server (AudioBE *be,GDBusObjectManagerServer *server,bool p2p,Error **errp); +#endif #define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f)
audio/audio_int.h +1 -1
@@ -147,7 +147,7 @@ struct audio_driver {void *(*init) (Audiodev *,Error **);void (*fini) (void *);#ifdef CONFIG_GIO -void (*set_dbus_server) (AudioBE *s,GDBusObjectManagerServer *manager,bool p2p); +bool (*set_dbus_server) (AudioBE *s,GDBusObjectManagerServer *manager,bool p2p,Error **errp);#endif struct audio_pcm_ops *pcm_ops;int max_voices_out;
audio/audio.c +14 -0
@@ -2232,6 +2232,20 @@ AudioBE *audio_be_by_name(const char *name, Error **errp) } } +#ifdef CONFIG_GIO +bool audio_be_set_dbus_server (AudioBE *be,GDBusObjectManagerServer *server,bool p2p,Error **errp) +{ +assert (be !=NULL ); + +if (!be->drv->set_dbus_server) { +error_setg (errp,"Audiodev '%s' is not compatible with DBus" , be->dev->id); +return false; + } + +return be->drv->set_dbus_server (be, server, p2p, errp); +} +#endif +const char *audio_fe_get_be_id (AudioFE *card) {if (card->be) {
audio/dbusaudio.c +4 -2
@@ -645,8 +645,8 @@ dbus_audio_register_in_listener(AudioBE *s, arg_listener, false); } -static void -dbus_audio_set_server (AudioBE *s,GDBusObjectManagerServer *server,bool p2p) +static bool +dbus_audio_set_server (AudioBE *s,GDBusObjectManagerServer *server,bool p2p,Error **errp) {DBusAudio *da = s->drv_opaque;
@@ -669,6 +669,8 @@ dbus_audio_set_server(AudioBE *s, GDBusObjectManagerServer *server, bool p2p)g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (da->audio),G_DBUS_INTERFACE_SKELETON (da->iface));g_dbus_object_manager_server_export (da->server, da->audio); + +return true; }static struct audio_pcm_ops dbus_pcm_ops = {
ui/dbus.c +1 -7
@@ -221,15 +221,9 @@ dbus_display_complete(UserCreatable *uc, Error **errp)if (dd->audiodev && *dd->audiodev) {AudioBE *audio_be =audio_be_by_name (dd->audiodev, errp); -if (!audio_be) { +if (!audio_be || !audio_be_set_dbus_server (audio_be, dd->server, dd->p2p, errp)) {return ; } -if (!g_str_equal (audio_be->drv->name,"dbus" )) { -error_setg (errp,"Audiodev '%s' is not compatible with DBus" , - dd->audiodev); -return ; - } - audio_be->drv->set_dbus_server (audio_be, dd->server, dd->p2p); } consoles =g_array_new (FALSE, FALSE,sizeof (guint32));
Signature · 1 line
2.51.0
PATCH 38/43 audio: move audio.h under include/qemu/
In reply to [email protected]From: Marc-André Lureau <[email protected]>
---
audio/audio_int.h | 2 +-
hw/audio/lm4549.h | 2 +-
include/hw/audio/asc.h | 2 +-
include/hw/audio/virtio-snd.h | 2 +-
include/hw/display/xlnx_dp.h | 2 +-
include/hw/isa/vt82c686.h | 2 +-
{audio => include/qemu}/audio.h | 0
include/system/replay.h | 2 +-
ui/vnc.h | 2 +-
audio/alsaaudio.c | 2 +-
audio/audio.c | 2 +-
audio/audio_win_int.c | 2 +-
audio/dbusaudio.c | 2 +-
audio/dsoundaudio.c | 2 +-
audio/jackaudio.c | 2 +-
audio/mixeng.c | 2 +-
audio/noaudio.c | 2 +-
audio/ossaudio.c | 2 +-
audio/paaudio.c | 2 +-
audio/pwaudio.c | 2 +-
audio/sdlaudio.c | 2 +-
audio/sndioaudio.c | 2 +-
audio/spiceaudio.c | 2 +-
audio/wavaudio.c | 2 +-
hw/arm/integratorcp.c | 2 +-
hw/arm/musicpal.c | 2 +-
hw/arm/realview.c | 2 +-
hw/arm/versatilepb.c | 2 +-
hw/arm/vexpress.c | 2 +-
hw/arm/xlnx-zcu102.c | 2 +-
hw/audio/ac97.c | 2 +-
hw/audio/adlib.c | 2 +-
hw/audio/asc.c | 2 +-
hw/audio/cs4231a.c | 2 +-
hw/audio/es1370.c | 2 +-
hw/audio/gus.c | 2 +-
hw/audio/hda-codec.c | 2 +-
hw/audio/lm4549.c | 2 +-
hw/audio/marvell_88w8618.c | 2 +-
hw/audio/pcspk.c | 2 +-
hw/audio/sb16.c | 2 +-
hw/audio/wm8750.c | 2 +-
hw/core/machine.c | 2 +-
hw/core/qdev-properties-system.c | 2 +-
hw/ppc/prep.c | 2 +-
hw/usb/dev-audio.c | 2 +-
replay/replay-audio.c | 2 +-
system/runstate.c | 2 +-
system/vl.c | 2 +-
ui/dbus.c | 3 +--
audio/coreaudio.m | 2 +-
scripts/codeconverter/codeconverter/test_regexps.py | 2 +-
52 files changed, 51 insertions(+), 52 deletions(-)
rename {audio => include/qemu}/audio.h (100%)audio/audio_int.h +1 -1
@@ -29,7 +29,7 @@#define FLOAT_MIXENG /* #define RECIPROCAL */ #endif -#include "audio.h" +#include "qemu/audio.h" #include "mixeng.h" #ifdef CONFIG_GIO
hw/audio/lm4549.h +1 -1
@@ -12,7 +12,7 @@#ifndef HW_LM4549_H #define HW_LM4549_H -#include "audio/audio.h" +#include "qemu/audio.h" #include "exec/hwaddr.h" typedef void (*lm4549_callback )(void *opaque);
include/hw/audio/asc.h +1 -1
@@ -14,7 +14,7 @@#define HW_AUDIO_ASC_H #include "hw/sysbus.h" -#include "audio/audio.h" +#include "qemu/audio.h" #define ASC_FREQ 22257
include/hw/audio/virtio-snd.h +1 -1
@@ -17,7 +17,7 @@#define QEMU_VIRTIO_SOUND_H #include "hw/virtio/virtio.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_snd.h"
include/hw/display/xlnx_dp.h +1 -1
@@ -33,7 +33,7 @@#include "qemu/fifo8.h" #include "qemu/units.h" #include "hw/dma/xlnx_dpdma.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qom/object.h" #include "hw/ptimer.h"
include/hw/isa/vt82c686.h +1 -1
@@ -2,7 +2,7 @@#define HW_VT82C686_H #include "hw/pci/pci_device.h" -#include "audio/audio.h" +#include "qemu/audio.h" #define TYPE_VT82C686B_ISA "vt82c686b-isa"#define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci"
include/qemu/audio.h renamed from audio/audio.h +0 -0
include/system/replay.h +1 -1
@@ -16,7 +16,7 @@#include "qapi/qapi-types-run-state.h" #include "qapi/qapi-types-ui.h" #include "block/aio.h" -#include "audio/audio.h" +#include "qemu/audio.h" /* replay clock kinds */ enum ReplayClockKind {
ui/vnc.h +1 -1
@@ -31,7 +31,7 @@#include "qemu/thread.h" #include "ui/clipboard.h" #include "ui/console.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qemu/bitmap.h" #include "crypto/tlssession.h" #include "qemu/buffer.h"
audio/alsaaudio.c +1 -1
@@ -26,7 +26,7 @@#include <alsa/asoundlib.h> #include "qemu/main-loop.h" #include "qemu/module.h" -#include "audio.h" +#include "qemu/audio.h" #include "trace.h" #pragma GCC diagnostic ignored "-Waddress"
audio/audio.c +1 -1
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "audio.h" +#include "qemu/audio.h" #include "migration/vmstate.h" #include "qemu/timer.h" #include "qapi/error.h"
audio/audio_win_int.c +1 -1
@@ -7,7 +7,7 @@#include <mmreg.h> #include <mmsystem.h> -#include "audio.h" +#include "qemu/audio.h" #include "audio_int.h" #include "audio_win_int.h"
audio/dbusaudio.c +1 -1
@@ -35,7 +35,7 @@#include "ui/dbus-display1.h" #define AUDIO_CAP "dbus" -#include "audio.h" +#include "qemu/audio.h" #include "audio_int.h" #include "trace.h"
audio/dsoundaudio.c +1 -1
@@ -27,7 +27,7 @@*/ #include "qemu/osdep.h" -#include "audio.h" +#include "qemu/audio.h" #define AUDIO_CAP "dsound"#include "audio_int.h"
audio/jackaudio.c +1 -1
@@ -26,7 +26,7 @@#include "qemu/module.h" #include "qemu/atomic.h" #include "qemu/main-loop.h" -#include "audio.h" +#include "qemu/audio.h" #define AUDIO_CAP "jack"#include "audio_int.h"
audio/mixeng.c +1 -1
@@ -24,7 +24,7 @@*/ #include "qemu/osdep.h" #include "qemu/bswap.h" -#include "audio.h" +#include "qemu/audio.h" #define AUDIO_CAP "mixeng"#include "audio_int.h"
audio/noaudio.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/osdep.h" #include "qemu/module.h" -#include "audio.h" +#include "qemu/audio.h" #define AUDIO_CAP "noaudio"#include "audio_int.h"
audio/ossaudio.c +1 -1
@@ -29,7 +29,7 @@#include "qemu/module.h" #include "qemu/host-utils.h" #include "qapi/error.h" -#include "audio.h" +#include "qemu/audio.h" #include "trace.h" #define AUDIO_CAP "oss"
audio/paaudio.c +1 -1
@@ -2,7 +2,7 @@#include "qemu/osdep.h" #include "qemu/module.h" -#include "audio.h" +#include "qemu/audio.h" #include "qapi/error.h" #include <pulse/pulseaudio.h>
audio/pwaudio.c +1 -1
@@ -10,7 +10,7 @@#include "qemu/osdep.h" #include "qemu/module.h" -#include "audio.h" +#include "qemu/audio.h" #include "qemu/error-report.h" #include "qapi/error.h" #include <spa/param/audio/format-utils.h>
audio/sdlaudio.c +1 -1
@@ -27,7 +27,7 @@#include <SDL_thread.h> #include "qemu/module.h" #include "qapi/error.h" -#include "audio.h" +#include "qemu/audio.h" #ifndef _WIN32#ifdef __sun__
audio/sndioaudio.c +1 -1
@@ -18,7 +18,7 @@#include <poll.h> #include <sndio.h> #include "qemu/main-loop.h" -#include "audio.h" +#include "qemu/audio.h" #include "trace.h" #define AUDIO_CAP "sndio"
audio/spiceaudio.c +1 -1
@@ -26,7 +26,7 @@#include "ui/qemu-spice.h" #define AUDIO_CAP "spice" -#include "audio.h" +#include "qemu/audio.h" #include "audio_int.h" #if SPICE_INTERFACE_PLAYBACK_MAJOR >1 ||SPICE_INTERFACE_PLAYBACK_MINOR >=3
audio/wavaudio.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/osdep.h" #include "qemu/module.h" -#include "audio.h" +#include "qemu/audio.h" #define AUDIO_CAP "wav"#include "audio_int.h"
hw/arm/integratorcp.c +1 -1
@@ -26,7 +26,7 @@#include "hw/irq.h" #include "hw/sd/sd.h" #include "qom/object.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "target/arm/cpu-qom.h" #define TYPE_INTEGRATOR_CM "integrator_core"
hw/arm/musicpal.c +1 -1
@@ -36,7 +36,7 @@#include "qemu/cutils.h" #include "qom/object.h" #include "hw/net/mv88w8618_eth.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qemu/error-report.h" #include "target/arm/cpu-qom.h"
hw/arm/realview.c +1 -1
@@ -29,7 +29,7 @@#include "hw/irq.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/sd/sd.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "target/arm/cpu-qom.h" #define SMP_BOOT_ADDR 0xe0000000
hw/arm/versatilepb.c +1 -1
@@ -25,7 +25,7 @@#include "hw/char/pl011.h" #include "hw/sd/sd.h" #include "qom/object.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "target/arm/cpu-qom.h" #include "qemu/log.h"
hw/arm/vexpress.c +1 -1
@@ -44,7 +44,7 @@#include "hw/sd/sd.h" #include "qobject/qlist.h" #include "qom/object.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "target/arm/cpu-qom.h" #define VEXPRESS_BOARD_ID 0x8e0
hw/arm/xlnx-zcu102.c +1 -1
@@ -25,7 +25,7 @@#include "system/device_tree.h" #include "qom/object.h" #include "net/can_emu.h" -#include "audio/audio.h" +#include "qemu/audio.h" struct XlnxZCU102 {MachineState parent_obj;
hw/audio/ac97.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/pci/pci_device.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h"
hw/audio/adlib.c +1 -1
@@ -26,7 +26,7 @@#include "qapi/error.h" #include "qemu/module.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" #include "qemu/error-report.h"
hw/audio/asc.c +1 -1
@@ -15,7 +15,7 @@#include "qapi/error.h" #include "hw/sysbus.h" #include "hw/irq.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/audio/asc.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h"
hw/audio/cs4231a.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/osdep.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h"
hw/audio/es1370.c +1 -1
@@ -27,7 +27,7 @@#include "qemu/osdep.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/pci/pci_device.h" #include "migration/vmstate.h" #include "qemu/cutils.h"
hw/audio/gus.c +1 -1
@@ -26,7 +26,7 @@#include "qapi/error.h" #include "qemu/module.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h"
hw/audio/hda-codec.c +1 -1
@@ -25,7 +25,7 @@#include "qemu/host-utils.h" #include "qemu/module.h" #include "intel-hda-defs.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "trace.h" #include "qom/object.h"
hw/audio/lm4549.c +1 -1
@@ -15,7 +15,7 @@#include "qemu/osdep.h" #include "hw/hw.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "lm4549.h" #include "migration/vmstate.h"
hw/audio/marvell_88w8618.c +1 -1
@@ -16,7 +16,7 @@#include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/audio/wm8750.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qapi/error.h" #include "qemu/module.h" #include "qom/object.h"
hw/audio/pcspk.c +1 -1
@@ -25,7 +25,7 @@#include "qemu/osdep.h" #include "hw/isa/isa.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qemu/module.h" #include "qemu/timer.h" #include "qemu/error-report.h"
hw/audio/sb16.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/osdep.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h"
hw/audio/wm8750.c +1 -1
@@ -12,7 +12,7 @@#include "migration/vmstate.h" #include "qemu/module.h" #include "hw/audio/wm8750.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qom/object.h" #define IN_PORT_N 3
hw/core/machine.c +1 -1
@@ -36,7 +36,7 @@#include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-iommu.h" #include "hw/acpi/generic_event_device.h" -#include "audio/audio.h" +#include "qemu/audio.h" GlobalProperty hw_compat_10_1[] = { {TYPE_ACPI_GED ,"x-has-hest-addr" ,"false" },
hw/core/qdev-properties-system.c +1 -1
@@ -27,7 +27,7 @@#include "qemu/error-report.h" #include "qdev-prop-internal.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "chardev/char-fe.h" #include "system/block-backend.h" #include "system/blockdev.h"
hw/ppc/prep.c +1 -1
@@ -46,7 +46,7 @@#include "trace.h" #include "elf.h" #include "qemu/units.h" -#include "audio/audio.h" +#include "qemu/audio.h" /* SMP is not enabled, for now */ #define MAX_CPUS 1
hw/usb/dev-audio.c +1 -1
@@ -35,7 +35,7 @@#include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "qom/object.h" static void usb_audio_reinit (USBDevice *dev,unsigned channels);
replay/replay-audio.c +1 -1
@@ -13,7 +13,7 @@#include "qemu/error-report.h" #include "system/replay.h" #include "replay-internal.h" -#include "audio/audio.h" +#include "qemu/audio.h" void replay_audio_out (size_t *played) {
system/runstate.c +1 -1
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "block/block.h" #include "block/export.h" #include "chardev/char.h"
system/vl.c +1 -1
@@ -87,7 +87,7 @@#include "system/tpm.h" #include "system/dma.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "system/cpus.h" #include "system/cpu-timers.h" #include "exec/icount.h"
ui/dbus.c +1 -2
@@ -34,8 +34,7 @@#include "ui/egl-helpers.h" #include "ui/egl-context.h" #endif -#include "audio/audio.h" -#include "audio/audio_int.h" +#include "qemu/audio.h" #include "qapi/error.h" #include "trace.h"
audio/coreaudio.m +1 -1
@@ -28,7 +28,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" -#include "audio.h" +#include "qemu/audio.h" #define AUDIO_CAP "coreaudio" #include "audio_int.h"
scripts/codeconverter/codeconverter/test_regexps.py +1 -1
@@ -265,7 +265,7 @@ def test_initial_includes(): #include "qemu/osdep.h" #include "hw/audio/model.h" -#include "audio/audio.h" +#include "qemu/audio.h" #include "hw/pci/pci.h" #include "migration/vmstate.h" #include "qemu/module.h"
Signature · 1 line
2.51.0
Re: [PATCH 38/43] audio: move audio.h under include/qemu/
Quoted 3 lines · On 2025/10/21 18:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>
PATCH 39/43 audio: remove dependency on spice header
In reply to [email protected]From: Marc-André Lureau <[email protected]>
It is no longer required.
--- audio/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/meson.build +1 -1
@@ -1,5 +1,5 @@ -system_ss.add([spice_headers, files('audio.c')]) system_ss.add(files( + 'audio.c', 'audio-hmp-cmds.c', 'mixeng.c', 'noaudio.c',
Signature · 1 line
2.51.0
PATCH 40/43 audio: cleanup, use bool for booleans
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Use slightly better types for the job.
--- audio/audio_int.h | 12 ++++++------ audio/audio_template.h | 6 +++--- include/qemu/audio.h | 8 ++++---- audio/audio.c | 30 +++++++++++++++--------------- 4 files changed, 28 insertions(+), 28 deletions(-)
audio/audio_int.h +6 -6
@@ -67,9 +67,9 @@ typedef struct STSampleBuffer { typedef struct HWVoiceOut { AudioBE *s; - int enabled; + bool enabled; int poll_mode; - int pending_disable; + bool pending_disable; struct audio_pcm_info info; f_sample *clip;
@@ -88,7 +88,7 @@ typedef struct HWVoiceOut { typedef struct HWVoiceIn { AudioBE *s; - int enabled; + bool enabled; int poll_mode; struct audio_pcm_info info;
@@ -115,8 +115,8 @@ struct SWVoiceOut {STSampleBuffer resample_buf;void *rate;size_t total_hw_samples_mixed; -int active; -int empty; +bool active; +bool empty;HWVoiceOut *hw;char *name;struct mixeng_volume vol;
@@ -127,7 +127,7 @@ struct SWVoiceOut {struct SWVoiceIn {AudioFE *card;AudioBE *s; -int active; +bool active;struct audio_pcm_info info;void *rate;size_t total_hw_samples_acquired;
audio/audio_template.h +3 -3
@@ -166,10 +166,10 @@ static int glue (audio_pcm_sw_init_, TYPE) (audio_pcm_init_info (&sw->info, as); sw->hw = hw; - sw->active =0 ; + sw->active = false;#ifdef DAC sw->total_hw_samples_mixed =0 ; - sw->empty =1 ; + sw->empty = true;#endif if (sw->info.is_float) {
@@ -566,7 +566,7 @@ SW *glue (AUD_open_, TYPE) (return NULL ; } -int glue (AUD_is_active_ ,TYPE ) (SW *sw) +bool glue (AUD_is_active_ ,TYPE ) (SW *sw) {return sw ? sw->active :0 ; }
include/qemu/audio.h +4 -4
@@ -105,8 +105,8 @@ SWVoiceOut *AUD_open_out (void AUD_close_out (AudioFE *fe,SWVoiceOut *sw);size_t AUD_write (SWVoiceOut *sw,void *pcm_buf,size_t size);int AUD_get_buffer_size_out (SWVoiceOut *sw); -void AUD_set_active_out (SWVoiceOut *sw,int on); -int AUD_is_active_out (SWVoiceOut *sw); +void AUD_set_active_out (SWVoiceOut *sw,bool on); +bool AUD_is_active_out (SWVoiceOut *sw);void AUD_init_time_stamp_out (SWVoiceOut *sw,QEMUAudioTimeStamp *ts);uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw,QEMUAudioTimeStamp *ts);
@@ -135,8 +135,8 @@ SWVoiceIn *AUD_open_in (void AUD_close_in (AudioFE *fe,SWVoiceIn *sw);size_t AUD_read (SWVoiceIn *sw,void *pcm_buf,size_t size); -void AUD_set_active_in (SWVoiceIn *sw,int on); -int AUD_is_active_in (SWVoiceIn *sw); +void AUD_set_active_in (SWVoiceIn *sw,bool on); +bool AUD_is_active_in (SWVoiceIn *sw);void AUD_init_time_stamp_in (SWVoiceIn *sw,QEMUAudioTimeStamp *ts);uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw,QEMUAudioTimeStamp *ts);
audio/audio.c +15 -15
@@ -405,7 +405,7 @@ static void audio_notify_capture (CaptureVoiceOut *cap, audcnotification_e cmd) } } -static void audio_capture_maybe_changed (CaptureVoiceOut *cap,int enabled) +static void audio_capture_maybe_changed (CaptureVoiceOut *cap,bool enabled) {if (cap->hw.enabled != enabled) {audcnotification_e cmd;
@@ -419,11 +419,11 @@ static void audio_recalc_and_notify_capture (CaptureVoiceOut *cap) {HWVoiceOut *hw = &cap->hw;SWVoiceOut *sw; -int enabled =0 ; +bool enabled = false;for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {if (sw->active) { - enabled =1 ; + enabled = true;break ; } }
@@ -475,7 +475,7 @@ static int audio_attach_capture (HWVoiceOut *hw) sw = &sc->sw; sw->hw = hw_cap; sw->info = hw->info; - sw->empty =1 ; + sw->empty = true; sw->active = hw->enabled; sw->vol = nominal_volume; sw->rate =st_rate_start (sw->info.freq, hw_cap->info.freq);
@@ -911,7 +911,7 @@ int AUD_get_buffer_size_out(SWVoiceOut *sw)return sw->hw->samples * sw->hw->info.bytes_per_frame; } -void AUD_set_active_out (SWVoiceOut *sw,int on) +void AUD_set_active_out (SWVoiceOut *sw,bool on) {HWVoiceOut *hw;
@@ -928,7 +928,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on)if (on) { hw->pending_disable =0 ;if (!hw->enabled) { - hw->enabled =1 ; + hw->enabled = true;if (s->vm_running) {if (hw->pcm_ops->enable_out) { hw->pcm_ops->enable_out (hw, true);
@@ -959,7 +959,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) } } -void AUD_set_active_in (SWVoiceIn *sw,int on) +void AUD_set_active_in (SWVoiceIn *sw,bool on) {HWVoiceIn *hw;
@@ -974,7 +974,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on)if (on) {if (!hw->enabled) { - hw->enabled =1 ; + hw->enabled = true;if (s->vm_running) {if (hw->pcm_ops->enable_in) { hw->pcm_ops->enable_in (hw, true);
@@ -993,7 +993,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) }if (nb_active ==1 ) { - hw->enabled =0 ; + hw->enabled = false;if (hw->pcm_ops->enable_in) { hw->pcm_ops->enable_in (hw, false); }
@@ -1152,8 +1152,8 @@ static void audio_run_out (AudioBE *s) sw = hw->sw_head.lh_first;if (hw->pending_disable) { - hw->enabled =0 ; - hw->pending_disable =0 ; + hw->enabled = false; + hw->pending_disable = false;if (hw->pcm_ops->enable_out) { hw->pcm_ops->enable_out (hw, false); }
@@ -1206,13 +1206,13 @@ static void audio_run_out (AudioBE *s)#ifdef DEBUG_OUT dolog ("Disabling voice\n" );#endif - hw->enabled =0 ; - hw->pending_disable =0 ; + hw->enabled = false; + hw->pending_disable = false;if (hw->pcm_ops->enable_out) { hw->pcm_ops->enable_out (hw, false); }for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) { - sc->sw.active =0 ; + sc->sw.active = false;audio_recalc_and_notify_capture (sc->cap); }continue ;
@@ -1257,7 +1257,7 @@ static void audio_run_out (AudioBE *s) sw->total_hw_samples_mixed -= played;if (!sw->total_hw_samples_mixed) { - sw->empty =1 ; + sw->empty = true; } } }
Signature · 1 line
2.51.0
PATCH 41/43 audio: drop needless list of FE
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Apparently, it was never used.
--- audio/audio_int.h | 1 - include/qemu/audio.h | 1 - audio/audio.c | 4 ---- 3 files changed, 6 deletions(-)
audio/audio_int.h +0 -1
@@ -246,7 +246,6 @@ typedef struct AudioBE {void *drv_opaque;QEMUTimer *ts; - QLIST_HEAD (fe_listhead, AudioFE) fe_head; QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in; QLIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out; QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
include/qemu/audio.h +0 -1
@@ -76,7 +76,6 @@ typedef struct AudioBE AudioBE;typedef struct AudioFE {char *name;AudioBE *be; -QLIST_ENTRY (AudioFE) entries; }AudioFE ; typedef struct QEMUAudioTimeStamp {
audio/audio.c +0 -4
@@ -1620,7 +1620,6 @@ static void audio_be_init(Object *obj)QLIST_INIT (&s->hw_head_out);QLIST_INIT (&s->hw_head_in);QLIST_INIT (&s->cap_head); -QLIST_INIT (&s->fe_head); s->ts =timer_new_ns (QEMU_CLOCK_VIRTUAL , audio_timer, s); s->vmse =qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
@@ -1822,15 +1821,12 @@ bool AUD_register_fe (const char *name, AudioFE *card, Error **errp) } card->name =g_strdup (name); -memset (&card->entries,0 ,sizeof (card->entries)); -QLIST_INSERT_HEAD (&card->be->fe_head, card, entries);return true; }void AUD_unregister_fe (AudioFE *card) { -QLIST_REMOVE (card, entries);g_free (card->name); }
Signature · 1 line
2.51.0
PATCH 42/43 audio: move capture API to own header
In reply to [email protected]From: Marc-André Lureau <[email protected]>
For modularity/clarity reasons, move the capture API in a specific header.
--- audio/audio_int.h | 1 + include/qemu/audio-capture.h | 43 ++++++++++++++++++++++++++++++++++++ include/qemu/audio.h | 30 ------------------------- ui/vnc.h | 2 +- 4 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 include/qemu/audio-capture.h
audio/audio_int.h +1 -0
@@ -30,6 +30,7 @@/* #define RECIPROCAL */ #endif #include "qemu/audio.h" +#include "qemu/audio-capture.h" #include "mixeng.h" #ifdef CONFIG_GIO
include/qemu/audio-capture.h new file +43 -0
43 lines not on this page · raw message
include/qemu/audio.h +0 -30
@@ -41,30 +41,7 @@ typedef struct audsettings {int endianness; } audsettings; -typedef enum { -AUD_CNOTIFY_ENABLE , -AUD_CNOTIFY_DISABLE -}audcnotification_e ; - -struct audio_capture_ops { -void (*notify) (void *opaque,audcnotification_e cmd); -void (*capture) (void *opaque,const void *buf,int size); -void (*destroy) (void *opaque); -}; - -struct capture_ops { -void (*info) (void *opaque); -void (*destroy) (void *opaque); -}; - -typedef struct CaptureState { -void *opaque; -struct capture_ops ops; -QLIST_ENTRY (CaptureState) entries; -}CaptureState ; -typedef struct SWVoiceOut SWVoiceOut ; -typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ;typedef struct AudioBEClass AudioBEClass ;
@@ -84,13 +61,6 @@ typedef struct QEMUAudioTimeStamp {bool AUD_register_fe (const char *name,AudioFE *fe,Error **errp);void AUD_unregister_fe (AudioFE *fe); -CaptureVoiceOut *AUD_add_capture ( -AudioBE *s, -struct audsettings *as, -struct audio_capture_ops *ops, -void *opaque - ); -void AUD_del_capture (CaptureVoiceOut *cap,void *cb_opaque); SWVoiceOut *AUD_open_out ( AudioFE *fe,
ui/vnc.h +1 -1
@@ -31,7 +31,7 @@#include "qemu/thread.h" #include "ui/clipboard.h" #include "ui/console.h" -#include "qemu/audio.h" +#include "qemu/audio-capture.h" #include "qemu/bitmap.h" #include "crypto/tlssession.h" #include "qemu/buffer.h"
Signature · 1 line
2.51.0
PATCH 43/43 audio: drop needless audio_driver "descr" field
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Was it ever used?
--- audio/audio_int.h | 1 - audio/alsaaudio.c | 1 - audio/dbusaudio.c | 1 - audio/dsoundaudio.c | 1 - audio/jackaudio.c | 1 - audio/noaudio.c | 1 - audio/ossaudio.c | 1 - audio/paaudio.c | 1 - audio/pwaudio.c | 1 - audio/sdlaudio.c | 1 - audio/sndioaudio.c | 1 - audio/spiceaudio.c | 1 - audio/wavaudio.c | 1 - audio/coreaudio.m | 1 - 14 files changed, 14 deletions(-)
audio/audio_int.h +0 -1
@@ -144,7 +144,6 @@ struct SWVoiceIn {typedef struct audio_driver audio_driver ;struct audio_driver {const char *name; -const char *descr;void *(*init) (Audiodev *,Error **);void (*fini) (void *);#ifdef CONFIG_GIO
audio/alsaaudio.c +0 -1
@@ -956,7 +956,6 @@ static struct audio_pcm_ops alsa_pcm_ops = {static struct audio_driver alsa_audio_driver = { .name ="alsa" , - .descr ="ALSA http://www.alsa-project.org" , .init = alsa_audio_init, .fini = alsa_audio_fini, .pcm_ops = &alsa_pcm_ops,
audio/dbusaudio.c +0 -1
@@ -692,7 +692,6 @@ static struct audio_pcm_ops dbus_pcm_ops = {static struct audio_driver dbus_audio_driver = { .name ="dbus" , - .descr ="Timer based audio exposed with DBus interface" , .init = dbus_audio_init, .fini = dbus_audio_fini, .set_dbus_server = dbus_audio_set_server,
audio/dsoundaudio.c +0 -1
@@ -685,7 +685,6 @@ static struct audio_pcm_ops dsound_pcm_ops = {static struct audio_driver dsound_audio_driver = { .name ="dsound" , - .descr ="DirectSound http://wikipedia.org/wiki/DirectSound" , .init = dsound_audio_init, .fini = dsound_audio_fini, .pcm_ops = &dsound_pcm_ops,
audio/jackaudio.c +0 -1
@@ -672,7 +672,6 @@ static struct audio_pcm_ops jack_pcm_ops = {static struct audio_driver jack_driver = { .name ="jack" , - .descr ="JACK Audio Connection Kit Client" , .init = qjack_init, .fini = qjack_fini, .pcm_ops = &jack_pcm_ops,
audio/noaudio.c +0 -1
@@ -129,7 +129,6 @@ static struct audio_pcm_ops no_pcm_ops = {static struct audio_driver no_audio_driver = { .name ="none" , - .descr ="Timer based audio emulation" , .init = no_audio_init, .fini = no_audio_fini, .pcm_ops = &no_pcm_ops,
audio/ossaudio.c +0 -1
@@ -779,7 +779,6 @@ static struct audio_pcm_ops oss_pcm_ops = {static struct audio_driver oss_audio_driver = { .name ="oss" , - .descr ="OSS http://www.opensound.com" , .init = oss_audio_init, .fini = oss_audio_fini, .pcm_ops = &oss_pcm_ops,
audio/paaudio.c +0 -1
@@ -922,7 +922,6 @@ static struct audio_pcm_ops qpa_pcm_ops = {static struct audio_driver pa_audio_driver = { .name ="pa" , - .descr ="http://www.pulseaudio.org/" , .init = qpa_audio_init, .fini = qpa_audio_fini, .pcm_ops = &qpa_pcm_ops,
audio/pwaudio.c +0 -1
@@ -838,7 +838,6 @@ static struct audio_pcm_ops qpw_pcm_ops = {static struct audio_driver pw_audio_driver = { .name ="pipewire" , - .descr ="http://www.pipewire.org/" , .init = qpw_audio_init, .fini = qpw_audio_fini, .pcm_ops = &qpw_pcm_ops,
audio/sdlaudio.c +0 -1
@@ -490,7 +490,6 @@ static struct audio_pcm_ops sdl_pcm_ops = {static struct audio_driver sdl_audio_driver = { .name ="sdl" , - .descr ="SDL http://www.libsdl.org" , .init = sdl_audio_init, .fini = sdl_audio_fini, .pcm_ops = &sdl_pcm_ops,
audio/sndioaudio.c +0 -1
@@ -546,7 +546,6 @@ static struct audio_pcm_ops sndio_pcm_ops = {static struct audio_driver sndio_audio_driver = { .name ="sndio" , - .descr ="sndio https://sndio.org" , .init = sndio_audio_init, .fini = sndio_audio_fini, .pcm_ops = &sndio_pcm_ops,
audio/spiceaudio.c +0 -1
@@ -316,7 +316,6 @@ static struct audio_pcm_ops audio_callbacks = {static struct audio_driver spice_audio_driver = { .name ="spice" , - .descr ="spice audio driver" , .init = spice_audio_init, .fini = spice_audio_fini, .pcm_ops = &audio_callbacks,
audio/wavaudio.c +0 -1
@@ -205,7 +205,6 @@ static struct audio_pcm_ops wav_pcm_ops = {static struct audio_driver wav_audio_driver = { .name ="wav" , - .descr ="WAV renderer http://wikipedia.org/wiki/WAV" , .init = wav_audio_init, .fini = wav_audio_fini, .pcm_ops = &wav_pcm_ops,
audio/coreaudio.m +0 -1
@@ -664,7 +664,6 @@ static void coreaudio_audio_fini (void *opaque) static struct audio_driver coreaudio_audio_driver = { .name = "coreaudio", - .descr = "CoreAudio http://developer.apple.com/audio/coreaudio.html", .init = coreaudio_audio_init, .fini = coreaudio_audio_fini, .pcm_ops = &coreaudio_pcm_ops,
Signature · 1 line
2.51.0
Re: [PATCH 43/43] audio: drop needless audio_driver "descr" field
Quoted 5 lines · On 2025/10/21 18:03, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Was it ever used?
Signed-off-by Marc-André Lureau <[email protected]>
This kind of description can be written in qemu-options.hx and there is no need to duplicate it.