Audio clean-ups
Subsystems (2)
v2 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)
v2:
- renamed AudioBE AudioBackend
- "qdev: add qdev_find_default_bus()" report different error for full bus
- added "remove QEMUSoundCard" & drop AudioFE renaming patch
- added "docs: Update mentions of removed '-soundhw' command line option" patch from philmd
- added r-b tags
thanks
Marc-André Lureau (41):
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 -> AudioBackend
audio: remove QEMUSoundCard
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: move capture API to own header
audio: drop needless audio_driver "descr" field
Philippe Mathieu-Daudé (1):
docs: Update mentions of removed '-soundhw' command line option
docs/qdev-device-use.txt | 10 +-
audio/audio_int.h | 62 ++--
audio/audio_template.h | 44 ++-
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 | 121 ++-----
include/system/replay.h | 3 +-
ui/vnc.h | 4 +-
audio/alsaaudio.c | 5 +-
audio/audio-hmp-cmds.c | 4 +-
audio/audio.c | 310 +++++++++---------
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 | 156 +++++----
hw/audio/adlib.c | 37 +--
hw/audio/asc.c | 15 +-
hw/audio/cs4231a.c | 56 ++--
hw/audio/es1370.c | 54 ++-
hw/audio/gus.c | 38 +--
hw/audio/hda-codec.c | 21 +-
hw/audio/intel-hda.c | 20 +-
hw/audio/lm4549.c | 12 +-
hw/audio/marvell_88w8618.c | 2 +-
hw/audio/model.c | 121 +++++++
hw/audio/pcspk.c | 32 +-
hw/audio/pl041.c | 2 +-
hw/audio/sb16.c | 116 ++++---
hw/audio/soundhw.c | 143 --------
hw/audio/via-ac97.c | 11 +-
hw/audio/virtio-snd-pci.c | 18 +-
hw/audio/virtio-snd.c | 17 +-
hw/audio/wm8750.c | 37 +--
hw/core/machine.c | 4 +-
hw/core/qdev-properties-system.c | 17 +-
hw/display/xlnx_dp.c | 8 +-
hw/ppc/prep.c | 2 +-
hw/timer/i8254_common.c | 6 +-
hw/usb/dev-audio.c | 17 +-
qom/object.c | 1 +
replay/replay-audio.c | 4 +-
replay/stubs-system.c | 2 +-
system/qdev-monitor.c | 29 +-
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 +-
78 files changed, 968 insertions(+), 1058 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 v2 1/42 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
PATCH v2 2/42 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
PATCH v2 3/42 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
PATCH v2 4/42 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
PATCH v2 5/42 hw/pcspk: make 'pit' a class property
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- 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
PATCH v2 6/42 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
PATCH v2 7/42 docs: update -soundhw -> -device list
In reply to [email protected]From: Marc-André Lureau <[email protected]>
(note: it's unclear whether -soundhw pcspk was working as expected, 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
PATCH v2 8/42 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 | 25 +++++++++++++++++++++---- 2 files changed, 24 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 +21 -4
@@ -621,6 +621,25 @@ 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) { +error_setg (errp,"No '%s' bus found for device '%s'" , + dc->bus_type,object_class_get_name (OBJECT_CLASS (dc))); +return NULL ; + } +if (qbus_is_full (bus)) { +error_setg (errp,"A '%s' bus was found but is full" , dc->bus_type); +return NULL ; + } + +return bus; +} +DeviceState *qdev_device_add_from_qdict (const QDict *opts,bool from_json,Error **errp) {
@@ -657,10 +676,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
PATCH v2 9/42 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 v2 10/42 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
PATCH v2 11/42 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
Re: [PATCH v2 11/42] hw/audio: use better naming for -audio model handling code
Quoted 36 lines · On 22/10/25 08:56, [email protected] wrote:
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.Signed-off-by Marc-André Lureau <[email protected]>--- 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 100644include/hw/audio/soundhw.h
renamehw/audio/{soundhw.c=>model.c} (68%)include/hw/audio/model.h new file +0
-0
include/hw/audio/model.h line 2
Quoted 2 lines
include/hw/audio/model.h new file +2
-0@@ -0,0 +1,13 @@ +#ifndef HW_AUDIO_MODEL_H +#define HW_AUDIO_MODEL_H
Pre-existing, but add missing license tag?
Quoted 17 lines
include/hw/audio/model.h new file +11
-0+ +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
-0
include/hw/audio/soundhw.h line 7
Quoted 7 lines
include/hw/audio/soundhw.h deleted +0
-7@@ -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);
Please mention in patch description why this interface is not anymore deprecated.
Otherwise,
Quoted 6 lines
include/hw/audio/soundhw.h deleted +0
-6- -void soundhw_init (void ); -void audio_print_available_models (void ); -void select_soundhw (const char *name,const char *audiodev); - -#endif
PATCH v2 12/42 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 v2 13/42 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
Re: [PATCH v2 13/42] hw/audio: simplify 'hda' audio init code
Quoted 5 lines · On Wed, 22 Oct 2025, [email protected] wrote:
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...
Maybe this needs a better commit message. My first question was how is this simpler when it's 6 lines more and at least to me less obvious what it does. The real goal may be to make it independent from PCI for the next patch so maybe that's what the commit message should also say.
Regards,
BALATON Zoltan
Quoted 50 lines
Signed-off-by Marc-André Lureau <[email protected]>---
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 ; }
Re: [PATCH v2 13/42] hw/audio: simplify 'hda' audio init code
Hi
Quoted 4 lines · BALATON Zoltan
Quoted 2 lines · On Wed, 22 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Quoted 8 lines
Quoted 3 lines
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...Maybe this needs a better commit message. My first question was how is this simpler when it's 6 lines more and at least to me less obvious what it does. The real goal may be to make it independent from PCI for the next patch so maybe that's what the commit message should also say.
I agree it's not as simple and generalized as I wish it would have ended.
But this allows to make init() callback bus-agnostic though. I will add this to the commit message.
There might be other ways to do that.
Quoted 53 lines
Regards,
BALATON ZoltanQuoted 50 lines
Signed-off-by Marc-André Lureau <[email protected]>---
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
Marc-André Lureau
PATCH v2 14/42 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 v2 15/42 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
PATCH v2 16/42 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 | 7 +++++++ audio/audio_int.h | 2 ++ audio/audio.c | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 11 deletions(-)
audio/audio.h +7 -0
@@ -80,6 +80,10 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; +struct AudioStateClass { +ObjectClass parent_class; +}; +typedef struct AudioState AudioState ; typedef struct QEMUSoundCard { char *name;
@@ -182,4 +186,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
PATCH v2 17/42 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
@@ -1676,6 +1676,11 @@ static void audio_state_finalize(Object *obj) } } +static Object *get_audiodevs_root (void ) +{ +return object_get_container ("audiodevs" ); +} +void audio_cleanup (void ) { default_audio_state =NULL ;
@@ -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
PATCH v2 18/42 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 | 38 +++++++++++++------------------------- 2 files changed, 13 insertions(+), 27 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 +13 -25
@@ -102,8 +102,6 @@ static audio_driver *audio_driver_lookup(const char *name)return NULL ; } -static QTAILQ_HEAD(AudioStateHead, AudioState) audio_states = -QTAILQ_HEAD_INITIALIZER (audio_states);static AudioState *default_audio_state;const struct mixeng_volume nominal_volume = {
@@ -1684,11 +1682,8 @@ static Object *get_audiodevs_root(void)void audio_cleanup (void ) { default_audio_state =NULL ; -while (!QTAILQ_EMPTY (&audio_states)) { -AudioState *s =QTAILQ_FIRST (&audio_states); -QTAILQ_REMOVE (&audio_states, s, list); -object_unref (s); - } + +object_unparent (get_audiodevs_root ()); }static bool vmstate_audio_needed (void *opaque)
@@ -1739,7 +1734,6 @@ void audio_create_default_audiodevs(void)*/ static AudioState *audio_init (Audiodev *dev,Error **errp) { -static bool atexit_registered;int done =0 ;const char *drvname;VMChangeStateEntry *vmse;
@@ -1747,14 +1741,6 @@ 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); - atexit_registered = true; - }if (dev) {/* -audiodev option */
@@ -1802,7 +1788,10 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) "(Audio can continue looping even after stopping the VM)\n"); } -QTAILQ_INSERT_TAIL (&audio_states, s, list); +if (!object_property_try_add_child (get_audiodevs_root (), dev->id,OBJECT (s), errp)) { + goto out; + } +object_unref (s);QLIST_INIT (&s->card_head);vmstate_register_any (NULL , &vmstate_audio, s);return s;
@@ -2249,15 +2238,14 @@ int audio_buffer_bytes(AudiodevPerDirectionOptions *pdo,AudioState *audio_state_by_name (const char *name,Error **errp) { -AudioState *s; - QTAILQ_FOREACH(s, &audio_states, list) { -assert (s->dev); -if (strcmp (name, s->dev->id) ==0 ) { -return s; - } +Object *obj =object_resolve_path_component (get_audiodevs_root (), name); + +if (!obj) { +error_setg (errp,"audiodev '%s' not found" , name); +return NULL ; + }else { +return AUDIO_STATE (obj); } -error_setg (errp,"audiodev '%s' not found" , name); -return NULL ; }const char *audio_get_id (QEMUSoundCard *card)
Signature · 1 line
2.51.0
PATCH v2 19/42 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
PATCH v2 20/42 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 v2 21/42 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 v2 22/42 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 v2 23/42 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 v2 24/42 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 v2 25/42 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 v2 26/42 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 v2 27/42 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 v2 28/42 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 v2 29/42 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
Re: [PATCH v2 29/42] audio: remove AUDIO_HOST_ENDIANNESS
Quoted 53 lines · On 22/10/25 08:56, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by 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 +2
-2@@ -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)
audio/audio.c audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) · line 2184
Quoted 7 lines
audio/audio.c +1
-1@@ -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, }; }
Nice. Even better would be to use QAPI EndianMode.
PATCH v2 30/42 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
@@ -119,8 +119,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 {
@@ -129,8 +129,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 v2 31/42 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
PATCH v2 32/42 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
@@ -160,9 +160,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 v2 33/42 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
@@ -88,9 +79,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(
@@ -149,15 +137,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
Re: [PATCH v2 33/42] audio: move internal APIs to audio_int.h
Quoted 40 lines · On 22/10/25 08:56, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by 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_int.h +8
-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);
audio/audio_int.h struct audio_pcm_ops { · line 207
Quoted 10 lines
audio/audio_int.h +10
-0+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); +}
Modulo checkpatch.pl errors,
PATCH v2 34/42 audio: rename AudioState -> AudioBackend
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 or frontend.
AudioBackend will become an abstract base class in a follow-up series.
Currently the frontend is QEMUSoundCard, we are going to drop that next.
Note that "audiodev" is the corresponding QAPI type name (or configuration).
--- audio/audio.h | 16 +++--- 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, 97 insertions(+), 97 deletions(-)
audio/audio.h +8 -8
@@ -64,14 +64,14 @@ typedef struct SWVoiceOut SWVoiceOut;typedef struct CaptureVoiceOut CaptureVoiceOut ;typedef struct SWVoiceIn SWVoiceIn ; -struct AudioStateClass { +struct AudioBackendClass {ObjectClass parent_class; }; -typedef struct AudioState AudioState ; +typedef struct AudioBackend AudioBackend ;typedef struct QEMUSoundCard {char *name; -AudioState *state; +AudioBackend *be;QLIST_ENTRY (QEMUSoundCard) entries; }QEMUSoundCard ;
@@ -82,7 +82,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, +AudioBackend *s,struct audsettings *as,struct audio_capture_ops *ops, void *opaque
@@ -153,14 +153,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); +AudioBackend *audio_be_by_name (const char *name,Error **errp); +AudioBackend *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_BACKEND "audio-backend" +OBJECT_DECLARE_TYPE(AudioBackend, AudioBackendClass, AUDIO_BACKEND)#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 AudioBackend AudioBackend ;typedef struct SWVoiceCap SWVoiceCap ; typedef struct STSampleBuffer {
@@ -66,7 +66,7 @@ typedef struct STSampleBuffer { } STSampleBuffer; typedef struct HWVoiceOut { - AudioState *s; + AudioBackend *s; int enabled; int poll_mode; int pending_disable;
@@ -87,7 +87,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; typedef struct HWVoiceIn { - AudioState *s; + AudioBackend *s; int enabled; int poll_mode; struct audio_pcm_info info;
@@ -109,7 +109,7 @@ typedef struct HWVoiceIn {struct SWVoiceOut {QEMUSoundCard *card; -AudioState *s; +AudioBackend *s;struct audio_pcm_info info;t_sample *conv;STSampleBuffer resample_buf;
@@ -126,7 +126,7 @@ struct SWVoiceOut {struct SWVoiceIn {QEMUSoundCard *card; -AudioState *s; +AudioBackend *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) (AudioBackend *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 (AudioBackend *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 AudioBackend { Object parent; struct audio_driver *drv;
@@ -258,7 +258,7 @@ typedef struct AudioState {bool timer_running;uint64_t timer_last;VMChangeStateEntry *vmse; -} AudioState; +} AudioBackend;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 (AudioBackend *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 )(AudioBackend *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; +AudioBackend *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 )(AudioBackend *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 )(AudioBackend *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 )(AudioBackend *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 )(AudioBackend *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 )(AudioBackend *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, +AudioBackend *s,const char *sw_name,struct audsettings *as )
@@ -494,7 +494,7 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as ) { -AudioState *s; +AudioBackend *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; +AudioBackend *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; +AudioBackend *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); +AudioBackend *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(AudioBackend *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(AudioBackend *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(AudioBackend *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 (AudioBackend *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; +AudioBackend *s = opaque;audio_run (s,"oss_poll_out" ); }static void oss_helper_poll_in (void *opaque) { -AudioState *s = opaque; +AudioBackend *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 (AudioBackend *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; +AudioBackend *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) { +AudioBackend *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
PATCH v2 35/42 audio: remove QEMUSoundCard
In reply to [email protected]From: Marc-André Lureau <[email protected]>
There is no clear need for this extra intermediary structure between the audio backend and its user.
--- audio/audio.h | 18 ++++++------------ audio/audio_int.h | 3 --- audio/audio_template.h | 22 ++++++++++------------ 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 | 29 ++++++++++------------------- hw/audio/ac97.c | 25 ++++++++++++------------- hw/audio/adlib.c | 9 ++++----- hw/audio/asc.c | 9 +++------ hw/audio/cs4231a.c | 8 ++++---- hw/audio/es1370.c | 23 +++++++++++------------ hw/audio/gus.c | 9 ++++----- hw/audio/hda-codec.c | 15 +++++++-------- hw/audio/lm4549.c | 8 ++++---- hw/audio/pcspk.c | 9 +++++---- hw/audio/pl041.c | 2 +- hw/audio/sb16.c | 16 ++++++++-------- hw/audio/via-ac97.c | 9 ++++----- hw/audio/virtio-snd.c | 13 ++++++------- hw/audio/wm8750.c | 23 +++++++++++------------ hw/core/qdev-properties-system.c | 11 +++++------ hw/display/xlnx_dp.c | 6 +++--- hw/usb/dev-audio.c | 11 +++++------ 27 files changed, 129 insertions(+), 161 deletions(-)
audio/audio.h +6 -12
@@ -69,18 +69,12 @@ struct AudioBackendClass { };typedef struct AudioBackend AudioBackend ; -typedef struct QEMUSoundCard { -char *name; -AudioBackend *be; -QLIST_ENTRY (QEMUSoundCard) entries; -}QEMUSoundCard ;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_backend_check (AudioBackend **be,Error **errp); CaptureVoiceOut *AUD_add_capture( AudioBackend *s, struct audsettings *as,
@@ -90,7 +84,7 @@ CaptureVoiceOut *AUD_add_capture(void AUD_del_capture (CaptureVoiceOut *cap,void *cb_opaque); SWVoiceOut *AUD_open_out ( - QEMUSoundCard *card, + AudioBackend *be, SWVoiceOut *sw, const char *name, void *callback_opaque,
@@ -98,7 +92,7 @@ SWVoiceOut *AUD_open_out (struct audsettings *settings ); -void AUD_close_out (QEMUSoundCard *card,SWVoiceOut *sw); +void AUD_close_out (AudioBackend *be,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);
@@ -121,7 +115,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, + AudioBackend *be, SWVoiceIn *sw, const char *name, void *callback_opaque,
@@ -129,7 +123,7 @@ SWVoiceIn *AUD_open_in (struct audsettings *settings ); -void AUD_close_in (QEMUSoundCard *card,SWVoiceIn *sw); +void AUD_close_in (AudioBackend *be,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);
@@ -155,7 +149,7 @@ void audio_help(void);AudioBackend *audio_be_by_name (const char *name,Error **errp);AudioBackend *audio_get_default_audio_be (Error **errp); -const char *audio_get_id (QEMUSoundCard *card); +const char *audio_be_get_id (AudioBackend *be);#define DEFINE_AUDIO_PROPERTIES (_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f)
audio/audio_int.h +0 -3
@@ -108,7 +108,6 @@ typedef struct HWVoiceIn { } HWVoiceIn;struct SWVoiceOut { -QEMUSoundCard *card;AudioBackend *s;struct audio_pcm_info info;t_sample *conv;
@@ -125,7 +124,6 @@ struct SWVoiceOut { };struct SWVoiceIn { -QEMUSoundCard *card;AudioBackend *s;int active;struct audio_pcm_info info;
@@ -246,7 +244,6 @@ typedef struct AudioBackend {void *drv_opaque;QEMUTimer *ts; - QLIST_HEAD (card_listhead, QEMUSoundCard) card_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 +10 -12
@@ -473,11 +473,11 @@ 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 ) (AudioBackend *be,SW *sw) {if (sw) { -if (audio_bug (__func__, !card)) { -dolog ("card=%p\n" , card); +if (audio_bug (__func__, !be)) { +dolog ("backend=%p\n" , be);return ; }
@@ -486,7 +486,7 @@ void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw) } SW *glue (AUD_open_, TYPE) ( - QEMUSoundCard *card, + AudioBackend *be, SW *sw, const char *name, void *callback_opaque ,
@@ -494,16 +494,15 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as ) { -AudioBackend *s; +AudioBackend *s = be;AudiodevPerDirectionOptions *pdo; -if (audio_bug (__func__, !card || !name || !callback_fn || !as)) { -dolog ("card=%p name=%p callback_fn=%p as=%p\n" , - card, name, callback_fn, as); +if (audio_bug (__func__, !be || !name || !callback_fn || !as)) { +dolog ("backend=%p name=%p callback_fn=%p as=%p\n" , + be, name, callback_fn, as); goto fail; } - s = card->be; pdo =glue (audio_get_pdo_,TYPE )(s->dev); ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",
@@ -524,7 +523,7 @@ SW *glue (AUD_open_, TYPE) ( }if (!pdo->fixed_settings && sw) { -glue (AUD_close_,TYPE ) (card, sw); +glue (AUD_close_,TYPE ) (be, sw); sw =NULL ; }
@@ -548,7 +547,6 @@ SW *glue (AUD_open_, TYPE) ( } } - sw->card = card; sw->vol = nominal_volume; sw->callback.fn = callback_fn; sw->callback.opaque = callback_opaque;
@@ -562,7 +560,7 @@ SW *glue (AUD_open_, TYPE) (return sw; fail: -glue (AUD_close_,TYPE ) (card, sw); +glue (AUD_close_,TYPE ) (be, sw);return NULL ; }
hw/audio/lm4549.h +1 -1
@@ -21,7 +21,7 @@ typedef void (*lm4549_callback)(void *opaque); typedef struct { - QEMUSoundCard card; + AudioBackend *audio_be; 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; +AudioBackend *audio_be;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; +AudioBackend *audio_be;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; +AudioBackend *audio_be;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; +AudioBackend *audio_be;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, AudioBackend *)#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID)
audio/audio.c +10 -19
@@ -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->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);
@@ -1812,28 +1811,20 @@ AudioBackend *audio_get_default_audio_be(Error **errp)return default_audio_be; } -bool AUD_register_card (const char *name,QEMUSoundCard *card,Error **errp) +bool AUD_backend_check (AudioBackend **be,Error **errp) { -if (!card->be) { - card->be =audio_get_default_audio_be (errp); -if (!card->be) { +assert (be !=NULL ); + +if (!*be) { + *be =audio_get_default_audio_be (errp); +if (!*be) {return false; } } - card->name =g_strdup (name); -memset (&card->entries,0 ,sizeof (card->entries)); -QLIST_INSERT_HEAD (&card->be->card_head, card, entries); -return true; } -void AUD_remove_card (QEMUSoundCard *card) -{ -QLIST_REMOVE (card, entries); -g_free (card->name); -} -static struct audio_pcm_ops capture_pcm_ops; CaptureVoiceOut *AUD_add_capture(
@@ -2232,11 +2223,11 @@ AudioBackend *audio_be_by_name(const char *name, Error **errp) } } -const char *audio_get_id (QEMUSoundCard *card) +const char *audio_be_get_id (AudioBackend *be) { -if (card->be) { -assert (card->be->dev); -return card->be->dev->id; +if (be) { +assert (be->dev); +return be->dev->id; }else {return "" ; }
hw/audio/ac97.c +12 -13
@@ -120,7 +120,7 @@ typedef struct AC97BusMasterRegs {struct AC97LinkState {PCIDevice dev; -QEMUSoundCard card; +AudioBackend *audio_be;uint32_t glob_cnt;uint32_t glob_sta;uint32_t cas;
@@ -316,7 +316,7 @@ static void open_voice(AC97LinkState *s, int index, int freq)switch (index) {case PI_INDEX : s->voice_pi = AUD_open_in( - &s->card, + s->audio_be, s->voice_pi, "ac97.pi", s,
@@ -327,7 +327,7 @@ static void open_voice(AC97LinkState *s, int index, int freq)case PO_INDEX : s->voice_po = AUD_open_out( - &s->card, + s->audio_be, s->voice_po, "ac97.po", s,
@@ -338,7 +338,7 @@ static void open_voice(AC97LinkState *s, int index, int freq)case MC_INDEX : s->voice_mc = AUD_open_in( - &s->card, + s->audio_be, s->voice_mc, "ac97.mc", s,
@@ -351,17 +351,17 @@ static void open_voice(AC97LinkState *s, int index, int freq) s->invalid_freq[index] = freq;switch (index) {case PI_INDEX : -AUD_close_in (&s->card, s->voice_pi); +AUD_close_in (s->audio_be, s->voice_pi); s->voice_pi =NULL ;break ;case PO_INDEX : -AUD_close_out (&s->card, s->voice_po); +AUD_close_out (s->audio_be, s->voice_po); s->voice_po =NULL ;break ;case MC_INDEX : -AUD_close_in (&s->card, s->voice_mc); +AUD_close_in (s->audio_be, s->voice_mc); s->voice_mc =NULL ;break ; }
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -1316,14 +1316,13 @@ static void ac97_exit(PCIDevice *dev) {AC97LinkState *s =AC97 (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_close_in (s->audio_be, s->voice_pi); +AUD_close_out (s->audio_be, s->voice_po); +AUD_close_in (s->audio_be, s->voice_mc); }static const Property ac97_properties[] = { -DEFINE_AUDIO_PROPERTIES (AC97LinkState, card), +DEFINE_AUDIO_PROPERTIES (AC97LinkState, audio_be), };static void ac97_class_init (ObjectClass *klass,const void *data)
hw/audio/adlib.c +4 -5
@@ -53,7 +53,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AdlibState, ADLIB)struct AdlibState {ISADevice parent_obj; -QEMUSoundCard card; +AudioBackend *audio_be;uint32_t freq;uint32_t port;int ticking[2 ];
@@ -236,7 +236,6 @@ static void Adlib_fini (AdlibState *s) s->active =0 ; s->enabled =0 ; -AUD_remove_card (&s->card); }static MemoryRegionPortio adlib_portio_list[] = {
@@ -251,7 +250,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_backend_check (&s->audio_be, errp)) {return ; }
@@ -271,7 +270,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp) as.endianness =HOST_BIG_ENDIAN ; s->voice = AUD_open_out ( - &s->card, + s->audio_be, s->voice, "adlib", s,
@@ -294,7 +293,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp) }static const Property adlib_properties[] = { -DEFINE_AUDIO_PROPERTIES (AdlibState, card), +DEFINE_AUDIO_PROPERTIES (AdlibState, audio_be),DEFINE_PROP_UINT32 ("iobase" , AdlibState, port,0x220 ),DEFINE_PROP_UINT32 ("freq" , AdlibState, freq,44100 ), };
hw/audio/asc.c +3 -6
@@ -634,8 +634,6 @@ static void asc_unrealize(DeviceState *dev)g_free (s->mixbuf);g_free (s->silentbuf); - -AUD_remove_card (&s->card); }static void asc_realize (DeviceState *dev,Error **errp)
@@ -643,7 +641,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_backend_check (&s->audio_be, errp)) {return ; }
@@ -652,10 +650,9 @@ static void asc_realize(DeviceState *dev, Error **errp) as.fmt =AUDIO_FORMAT_U8 ; as.endianness =HOST_BIG_ENDIAN ; - s->voice =AUD_open_out (&s->card, s->voice,"asc.out" , s, asc_out_cb, + s->voice =AUD_open_out (s->audio_be, s->voice,"asc.out" , s, asc_out_cb, &as);if (!s->voice) { -AUD_remove_card (&s->card);error_setg (errp,"Initializing audio stream failed" );return ; }
@@ -702,7 +699,7 @@ static void asc_init(Object *obj) }static const Property asc_properties[] = { -DEFINE_AUDIO_PROPERTIES (ASCState, card), +DEFINE_AUDIO_PROPERTIES (ASCState, audio_be),DEFINE_PROP_UINT8 ("asctype" , ASCState, type,ASC_TYPE_ASC ), };
hw/audio/cs4231a.c +4 -4
@@ -65,7 +65,7 @@ DECLARE_INSTANCE_CHECKER(CSState, CS4231A,struct CSState {ISADevice dev; -QEMUSoundCard card; +AudioBackend *audio_be;MemoryRegion ioports;qemu_irq pic;uint32_t regs[CS_REGS ];
@@ -324,7 +324,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) } s->voice = AUD_open_out ( - &s->card, + s->audio_be, s->voice, "cs4231a", s,
@@ -674,7 +674,7 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)return ; } -if (!AUD_register_card ("cs4231a" , &s->card, errp)) { +if (!AUD_backend_check (&s->audio_be, errp)) {return ; }
@@ -690,7 +690,7 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp) }static const Property cs4231a_properties[] = { -DEFINE_AUDIO_PROPERTIES (CSState, card), +DEFINE_AUDIO_PROPERTIES (CSState, audio_be),DEFINE_PROP_UINT32 ("iobase" , CSState, port,0x534 ),DEFINE_PROP_UINT32 ("irq" , CSState, irq,9 ),DEFINE_PROP_UINT32 ("dma" , CSState, dma,3 ),
hw/audio/es1370.c +11 -12
@@ -258,7 +258,7 @@ struct chan {struct ES1370State {PCIDevice dev; -QEMUSoundCard card; +AudioBackend *audio_be;MemoryRegion io;struct chan chan[NB_CHANNELS ];SWVoiceOut *dac_voice[2 ];
@@ -330,10 +330,10 @@ static void es1370_reset (ES1370State *s) d->scount =0 ; d->leftover =0 ;if (i ==ADC_CHANNEL ) { -AUD_close_in (&s->card, s->adc_voice); +AUD_close_in (s->audio_be, s->adc_voice); s->adc_voice =NULL ; }else { -AUD_close_out (&s->card, s->dac_voice[i]); +AUD_close_out (s->audio_be, s->dac_voice[i]); s->dac_voice[i] =NULL ; } }
@@ -412,7 +412,7 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl)if (i ==ADC_CHANNEL ) { s->adc_voice = AUD_open_in ( - &s->card, + s->audio_be, s->adc_voice, "es1370.adc", s,
@@ -422,7 +422,7 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl) }else { s->dac_voice[i] = AUD_open_out ( - &s->card, + s->audio_be, s->dac_voice[i], i ? "es1370.dac2" : "es1370.dac1", s,
@@ -784,12 +784,12 @@ static int es1370_post_load (void *opaque, int version_id)for (i =0 ; i <NB_CHANNELS ; ++i) {if (i ==ADC_CHANNEL ) {if (s->adc_voice) { -AUD_close_in (&s->card, s->adc_voice); +AUD_close_in (s->audio_be, s->adc_voice); s->adc_voice =NULL ; } }else {if (s->dac_voice[i]) { -AUD_close_out (&s->card, s->dac_voice[i]); +AUD_close_out (s->audio_be, s->dac_voice[i]); s->dac_voice[i] =NULL ; } }
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -861,15 +861,14 @@ static void es1370_exit(PCIDevice *dev)int i;for (i =0 ; i <2 ; ++i) { -AUD_close_out (&s->card, s->dac_voice[i]); +AUD_close_out (s->audio_be, s->dac_voice[i]); } -AUD_close_in (&s->card, s->adc_voice); -AUD_remove_card (&s->card); +AUD_close_in (s->audio_be, s->adc_voice); }static const Property es1370_properties[] = { -DEFINE_AUDIO_PROPERTIES (ES1370State, card), +DEFINE_AUDIO_PROPERTIES (ES1370State, audio_be), };static void es1370_class_init (ObjectClass *klass,const void *data)
hw/audio/gus.c +4 -5
@@ -45,7 +45,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GUSState, GUS)struct GUSState {ISADevice dev;GUSEmuState emu; -QEMUSoundCard card; +AudioBackend *audio_be;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_backend_check (&s->audio_be, errp)) {return ; }
@@ -254,7 +254,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp) as.endianness =HOST_BIG_ENDIAN ; s->voice = AUD_open_out ( - &s->card, + s->audio_be, NULL, "gus", s,
@@ -263,7 +263,6 @@ static void gus_realizefn (DeviceState *dev, Error **errp) );if (!s->voice) { -AUD_remove_card (&s->card);error_setg (errp,"No voice" );return ; }
@@ -288,7 +287,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp) }static const Property gus_properties[] = { -DEFINE_AUDIO_PROPERTIES (GUSState, card), +DEFINE_AUDIO_PROPERTIES (GUSState, audio_be),DEFINE_PROP_UINT32 ("freq" , GUSState, freq,44100 ),DEFINE_PROP_UINT32 ("iobase" , GUSState, port,0x240 ),DEFINE_PROP_UINT32 ("irq" , GUSState, emu.gusirq,7 ),
hw/audio/hda-codec.c +7 -8
@@ -178,7 +178,7 @@ struct HDAAudioState {HDACodecDevice hda;const char *name; -QEMUSoundCard card; +AudioBackend *audio_be;const desc_codec *desc;HDAAudioStream st[4 ];bool running_compat[16 ];
@@ -491,7 +491,7 @@ static void hda_audio_setup(HDAAudioStream *st) }else { cb = hda_audio_compat_output_cb; } - st->voice.out =AUD_open_out (&st->state->card, st->voice.out, + st->voice.out =AUD_open_out (st->state->audio_be, st->voice.out, st->node->name, st, cb, &st->as); }else {if (use_timer) {
@@ -500,7 +500,7 @@ static void hda_audio_setup(HDAAudioStream *st) }else { cb = hda_audio_compat_input_cb; } - st->voice.in =AUD_open_in (&st->state->card, st->voice.in, + st->voice.in =AUD_open_in (st->state->audio_be, st->voice.in, st->node->name, st, cb, &st->as); } }
@@ -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_backend_check (&a->audio_be, errp)) {return ; }
@@ -754,12 +754,11 @@ static void hda_audio_exit(HDACodecDevice *hda) }timer_free (st->buft);if (st->output) { -AUD_close_out (&a->card, st->voice.out); +AUD_close_out (a->audio_be, st->voice.out); }else { -AUD_close_in (&a->card, st->voice.in); +AUD_close_in (a->audio_be, st->voice.in); } } -AUD_remove_card (&a->card); }static int hda_audio_post_load (void *opaque,int version)
@@ -858,7 +857,7 @@ static const VMStateDescription vmstate_hda_audio = { };static const Property hda_audio_properties[] = { -DEFINE_AUDIO_PROPERTIES (HDAAudioState, card), +DEFINE_AUDIO_PROPERTIES (HDAAudioState, audio_be),DEFINE_PROP_UINT32 ("debug" , HDAAudioState, debug,0 ),DEFINE_PROP_BOOL ("mixer" , HDAAudioState, mixer, true),DEFINE_PROP_BOOL ("use-timer" , HDAAudioState, use_timer, true),
hw/audio/lm4549.c +4 -4
@@ -190,7 +190,7 @@ void lm4549_write(lm4549_state *s, as.endianness =0 ; s->voice = AUD_open_out( - &s->card, + s->audio_be, s->voice, "lm4549.out", s,
@@ -260,7 +260,7 @@ static int lm4549_post_load(void *opaque, int version_id) as.endianness =0 ; s->voice = AUD_open_out( - &s->card, + s->audio_be, s->voice, "lm4549.out", s,
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -300,7 +300,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_req_cb, void* opaque, as.endianness =0 ; s->voice = AUD_open_out( - &s->card, + s->audio_be, s->voice, "lm4549.out", s,
hw/audio/pcspk.c +5 -4
@@ -48,7 +48,7 @@ struct PCSpkState {MemoryRegion ioport;uint32_t iobase;uint8_t sample_buf[PCSPK_BUF_LEN ]; -QEMUSoundCard card; +AudioBackend *audio_be;SWVoiceOut *voice;PITCommonState *pit;unsigned int pit_count;
@@ -122,7 +122,7 @@ static int pcspk_audio_init(PCSpkState *s)return 0 ; } - s->voice =AUD_open_out (&s->card, s->voice, s_spk, s, pcspk_callback, &as); + s->voice =AUD_open_out (s->audio_be, s->voice, s_spk, s, pcspk_callback, &as);if (!s->voice) {error_report ("pcspk: Could not open voice" );return -1 ;
@@ -188,8 +188,9 @@ 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->audio_be &&AUD_backend_check (&s->audio_be, errp)) {pcspk_audio_init (s); +return ; } }
@@ -213,7 +214,7 @@ static const VMStateDescription vmstate_spk = { };static const Property pcspk_properties[] = { -DEFINE_AUDIO_PROPERTIES (PCSpkState, card), +DEFINE_AUDIO_PROPERTIES (PCSpkState, audio_be),DEFINE_PROP_UINT32 ("iobase" , PCSpkState, iobase,0x61 ),DEFINE_PROP_BOOL ("migrate" , PCSpkState, migrate, true), DEFINE_PROP_LINK("pit", PCSpkState, pit, TYPE_PIT_COMMON, PITCommonState *),
hw/audio/pl041.c +1 -1
@@ -626,7 +626,7 @@ static const VMStateDescription vmstate_pl041 = { };static const Property pl041_device_properties[] = { -DEFINE_AUDIO_PROPERTIES (PL041State, codec.card), +DEFINE_AUDIO_PROPERTIES (PL041State, codec.audio_be),/* Non-compact FIFO depth property */ DEFINE_PROP_UINT32 ("nc_fifo_depth" , PL041State, fifo_depth,DEFAULT_FIFO_DEPTH ),
hw/audio/sb16.c +8 -8
@@ -50,7 +50,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(SB16State, SB16)struct SB16State {ISADevice parent_obj; -QEMUSoundCard card; +AudioBackend *audio_be;qemu_irq pic;uint32_t irq;uint32_t dma;
@@ -212,7 +212,7 @@ static void continue_dma8 (SB16State *s) as.endianness =0 ; s->voice = AUD_open_out ( - &s->card, + s->audio_be, s->voice, "sb16", s,
@@ -375,7 +375,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, int dma_len) as.endianness =0 ; s->voice = AUD_open_out ( - &s->card, + s->audio_be, s->voice, "sb16", s,
@@ -876,7 +876,7 @@ static void legacy_reset (SB16State *s) as.endianness =0 ; s->voice = AUD_open_out ( - &s->card, + s->audio_be, s->voice, "sb16", s,
@@ -1283,7 +1283,7 @@ static int sb16_post_load (void *opaque, int version_id)SB16State *s = opaque;if (s->voice) { -AUD_close_out (&s->card, s->voice); +AUD_close_out (s->audio_be, s->voice); s->voice =NULL ; }
@@ -1299,7 +1299,7 @@ static int sb16_post_load (void *opaque, int version_id) as.endianness =0 ; s->voice = AUD_open_out ( - &s->card, + s->audio_be, s->voice, "sb16", s,
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -1436,7 +1436,7 @@ static void sb16_realizefn (DeviceState *dev, Error **errp) }static const Property sb16_properties[] = { -DEFINE_AUDIO_PROPERTIES (SB16State, card), +DEFINE_AUDIO_PROPERTIES (SB16State, audio_be),DEFINE_PROP_UINT32 ("version" , SB16State, ver,0x0405 ),/* 4.5 */ DEFINE_PROP_UINT32 ("iobase" , SB16State, port,0x220 ),DEFINE_PROP_UINT32 ("irq" , SB16State, irq,5 ),
hw/audio/via-ac97.c +4 -5
@@ -239,7 +239,7 @@ static void open_voice_out(ViaAC97State *s) .fmt = s->aur.type & BIT(5) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_S8, .endianness = 0, }; - s->vo =AUD_open_out (&s->card, s->vo,"via-ac97.out" , s, out_cb, &as); + s->vo =AUD_open_out (s->audio_be, s->vo,"via-ac97.out" , s, out_cb, &as); }static uint64_t sgd_read (void *opaque,hwaddr addr,unsigned size)
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -455,12 +455,11 @@ 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_close_out (s->audio_be, s->vo); }static const Property via_ac97_properties[] = { -DEFINE_AUDIO_PROPERTIES (ViaAC97State, card), +DEFINE_AUDIO_PROPERTIES (ViaAC97State, audio_be), };static void via_ac97_class_init (ObjectClass *klass,const void *data)
hw/audio/virtio-snd.c +6 -7
@@ -78,7 +78,7 @@ static const VMStateDescription vmstate_virtio_snd = { };static const Property virtio_snd_properties[] = { -DEFINE_AUDIO_PROPERTIES (VirtIOSound, card), +DEFINE_AUDIO_PROPERTIES (VirtIOSound, audio_be),DEFINE_PROP_UINT32 ("jacks" , VirtIOSound, snd_conf.jacks,VIRTIO_SOUND_JACK_DEFAULT ), DEFINE_PROP_UINT32("streams", VirtIOSound, snd_conf.streams,
@@ -391,10 +391,10 @@ static void virtio_snd_pcm_close(VirtIOSoundPCMStream *stream)if (stream) {virtio_snd_pcm_flush (stream);if (stream->info.direction ==VIRTIO_SND_D_OUTPUT ) { -AUD_close_out (&stream->pcm->snd->card, stream->voice.out); +AUD_close_out (stream->pcm->snd->audio_be, stream->voice.out); stream->voice.out =NULL ; }else if (stream->info.direction ==VIRTIO_SND_D_INPUT ) { -AUD_close_in (&stream->pcm->snd->card, stream->voice.in); +AUD_close_in (stream->pcm->snd->audio_be, stream->voice.in); stream->voice.in =NULL ; } }
@@ -457,7 +457,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id) stream->as = as;if (stream->info.direction ==VIRTIO_SND_D_OUTPUT ) { - stream->voice.out = AUD_open_out(&s->card, + stream->voice.out = AUD_open_out(s->audio_be, stream->voice.out, "virtio-sound.out", stream,
@@ -465,7 +465,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id) &as);AUD_set_volume_out_lr (stream->voice.out,0 ,255 ,255 ); }else { - stream->voice.in = AUD_open_in(&s->card, + stream->voice.in = AUD_open_in(s->audio_be, stream->voice.in, "virtio-sound.in", stream,
@@ -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_backend_check (&vsnd->audio_be, errp)) {return ; }
@@ -1330,7 +1330,6 @@ static void virtio_snd_unrealize(DeviceState *dev)g_free (vsnd->pcm); vsnd->pcm =NULL ; } -AUD_remove_card (&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 +11 -12
@@ -34,7 +34,7 @@ struct WM8750State {uint8_t i2c_data[2 ];int i2c_len; -QEMUSoundCard card; +AudioBackend *audio_be;SWVoiceIn *adc_voice[IN_PORT_N ];SWVoiceOut *dac_voice[OUT_PORT_N ];int enable;
@@ -188,12 +188,12 @@ static void wm8750_set_format(WM8750State *s)for (i =0 ; i <IN_PORT_N ; i ++)if (s->adc_voice[i]) { -AUD_close_in (&s->card, s->adc_voice[i]); +AUD_close_in (s->audio_be, s->adc_voice[i]); s->adc_voice[i] =NULL ; }for (i =0 ; i <OUT_PORT_N ; i ++)if (s->dac_voice[i]) { -AUD_close_out (&s->card, s->dac_voice[i]); +AUD_close_out (s->audio_be, s->dac_voice[i]); s->dac_voice[i] =NULL ; }
@@ -206,11 +206,11 @@ static void wm8750_set_format(WM8750State *s) in_fmt.freq = s->adc_hz; in_fmt.fmt =AUDIO_FORMAT_S16 ; - s->adc_voice[0 ] =AUD_open_in (&s->card, s->adc_voice[0 ], + s->adc_voice[0 ] =AUD_open_in (s->audio_be, s->adc_voice[0 ],CODEC ".input1" , s, wm8750_audio_in_cb, &in_fmt); - s->adc_voice[1 ] =AUD_open_in (&s->card, s->adc_voice[1 ], + s->adc_voice[1 ] =AUD_open_in (s->audio_be, s->adc_voice[1 ],CODEC ".input2" , s, wm8750_audio_in_cb, &in_fmt); - s->adc_voice[2 ] =AUD_open_in (&s->card, s->adc_voice[2 ], + s->adc_voice[2 ] =AUD_open_in (s->audio_be, s->adc_voice[2 ],CODEC ".input3" , s, wm8750_audio_in_cb, &in_fmt);/* Setup output */
@@ -219,12 +219,12 @@ static void wm8750_set_format(WM8750State *s) out_fmt.freq = s->dac_hz; out_fmt.fmt =AUDIO_FORMAT_S16 ; - s->dac_voice[0 ] =AUD_open_out (&s->card, s->dac_voice[0 ], + s->dac_voice[0 ] =AUD_open_out (s->audio_be, s->dac_voice[0 ],CODEC ".speaker" , s, wm8750_audio_out_cb, &out_fmt); - s->dac_voice[1 ] =AUD_open_out (&s->card, s->dac_voice[1 ], + s->dac_voice[1 ] =AUD_open_out (s->audio_be, s->dac_voice[1 ],CODEC ".headphone" , s, wm8750_audio_out_cb, &out_fmt);/* MONOMIX is also in stereo for simplicity */ - s->dac_voice[2 ] =AUD_open_out (&s->card, s->dac_voice[2 ], + s->dac_voice[2 ] =AUD_open_out (s->audio_be, s->dac_voice[2 ],CODEC ".monomix" , s, wm8750_audio_out_cb, &out_fmt);/* no sense emulating OUT3 which is a mix of other outputs */
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -637,7 +637,6 @@ static void wm8750_fini(I2CSlave *i2c)WM8750State *s =WM8750 (i2c);wm8750_reset (I2C_SLAVE (s)); -AUD_remove_card (&s->card); g_free(s); }#endif
@@ -707,7 +706,7 @@ void wm8750_set_bclk_in(void *opaque, int new_hz) }static const Property wm8750_properties[] = { -DEFINE_AUDIO_PROPERTIES (WM8750State, card), +DEFINE_AUDIO_PROPERTIES (WM8750State, audio_be), };static void wm8750_class_init (ObjectClass *klass,const void *data)
hw/core/qdev-properties-system.c +5 -6
@@ -487,18 +487,17 @@ 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); -char *p =g_strdup (audio_get_id (card)); +AudioBackend **be =object_field_prop_ptr (obj, prop); + g_autofree char *id = g_strdup(audio_be_get_id(*be)); -visit_type_str (v, name, &p, errp); -g_free (p); +visit_type_str (v, name, (char **)&id, errp); }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); +AudioBackend **be =object_field_prop_ptr (obj, prop);AudioBackend *state; g_autofree char *str = NULL;
@@ -508,7 +507,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, state =audio_be_by_name (str, errp);if (state) { - card->be = state; + *be = state; } }
hw/display/xlnx_dp.c +3 -3
@@ -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_backend_check (&s->audio_be, errp)) {return ; }
@@ -1328,7 +1328,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp) as.fmt =AUDIO_FORMAT_S16 ; as.endianness =0 ; - s->amixer_output_stream = AUD_open_out(&s->aud_card, + s->amixer_output_stream = AUD_open_out(s->audio_be, s->amixer_output_stream, "xlnx_dp.audio.out", s,
@@ -1392,7 +1392,7 @@ static void xlnx_dp_reset(DeviceState *dev) }static const Property xlnx_dp_device_properties[] = { -DEFINE_AUDIO_PROPERTIES (XlnxDPState, aud_card), +DEFINE_AUDIO_PROPERTIES (XlnxDPState, audio_be), };static void xlnx_dp_class_init (ObjectClass *oc,const void *data)
hw/usb/dev-audio.c +5 -6
@@ -635,7 +635,7 @@ static uint8_t *streambuf_get(struct streambuf *buf, size_t *len)struct USBAudioState {/* qemu interfaces */ USBDevice dev; -QEMUSoundCard card; +AudioBackend *audio_be;/* state */ struct {
@@ -931,8 +931,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_close_out (s->audio_be, s->out.voice);streambuf_fini (&s->out.buf); }
@@ -942,7 +941,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_backend_check (&s->audio_be, errp)) {return ; }
@@ -979,7 +978,7 @@ static void usb_audio_reinit(USBDevice *dev, unsigned channels) s->out.as.endianness =0 ;streambuf_init (&s->out.buf, s->buffer, s->out.channels); - s->out.voice =AUD_open_out (&s->card, s->out.voice,TYPE_USB_AUDIO , + s->out.voice =AUD_open_out (s->audio_be, s->out.voice,TYPE_USB_AUDIO , s, output_callback, &s->out.as);AUD_set_volume_out (s->out.voice, &s->out.vol);AUD_set_active_out (s->out.voice,0 );
@@ -991,7 +990,7 @@ static const VMStateDescription vmstate_usb_audio = { };static const Property usb_audio_properties[] = { -DEFINE_AUDIO_PROPERTIES (USBAudioState, card), +DEFINE_AUDIO_PROPERTIES (USBAudioState, audio_be),DEFINE_PROP_UINT32 ("debug" , USBAudioState, debug,0 ),DEFINE_PROP_UINT32 ("buffer" , USBAudioState, buffer_user,0 ),DEFINE_PROP_BOOL ("multi" , USBAudioState, multi, false),
Signature · 1 line
2.51.0
PATCH v2 36/42 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);
@@ -150,6 +153,9 @@ void audio_help(void);AudioBackend *audio_be_by_name (const char *name,Error **errp);AudioBackend *audio_get_default_audio_be (Error **errp);const char *audio_be_get_id (AudioBackend *be); +#ifdef CONFIG_GIO +bool audio_be_set_dbus_server (AudioBackend *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
@@ -145,7 +145,7 @@ struct audio_driver {void *(*init) (Audiodev *,Error **);void (*fini) (void *);#ifdef CONFIG_GIO -void (*set_dbus_server) (AudioBackend *s,GDBusObjectManagerServer *manager,bool p2p); +bool (*set_dbus_server) (AudioBackend *be,GDBusObjectManagerServer *manager,bool p2p,Error **errp);#endif struct audio_pcm_ops *pcm_ops;int max_voices_out;
audio/audio.c +14 -0
@@ -2223,6 +2223,20 @@ AudioBackend *audio_be_by_name(const char *name, Error **errp) } } +#ifdef CONFIG_GIO +bool audio_be_set_dbus_server (AudioBackend *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_be_get_id (AudioBackend *be) {if (be) {
audio/dbusaudio.c +4 -2
@@ -645,8 +645,8 @@ dbus_audio_register_in_listener(AudioBackend *s, arg_listener, false); } -static void -dbus_audio_set_server (AudioBackend *s,GDBusObjectManagerServer *server,bool p2p) +static bool +dbus_audio_set_server (AudioBackend *s,GDBusObjectManagerServer *server,bool p2p,Error **errp) {DBusAudio *da = s->drv_opaque;
@@ -669,6 +669,8 @@ dbus_audio_set_server(AudioBackend *s, GDBusObjectManagerServer *server, bool p2g_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) {AudioBackend *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 v2 37/42 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
PATCH v2 38/42 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 v2 39/42 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 { AudioBackend *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 { AudioBackend *s; - int enabled; + bool enabled; int poll_mode; struct audio_pcm_info info;
@@ -114,8 +114,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;
@@ -125,7 +125,7 @@ struct SWVoiceOut {struct SWVoiceIn {AudioBackend *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) {
@@ -564,7 +564,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
@@ -98,8 +98,8 @@ SWVoiceOut *AUD_open_out (void AUD_close_out (AudioBackend *be,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);
@@ -128,8 +128,8 @@ SWVoiceIn *AUD_open_in (void AUD_close_in (AudioBackend *be,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 (AudioBackend *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 (AudioBackend *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 (AudioBackend *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
Re: [PATCH v2 39/42] audio: cleanup, use bool for booleans
Quoted 44 lines · On 22/10/25 08:56, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Use slightly better types for the job.
Signed-off-by Marc-André Lureau <[email protected]>--- 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(-)include/qemu/audio.h +4
-4@@ -98,8 +98,8 @@ SWVoiceOut *AUD_open_out (void AUD_close_out (AudioBackend *be,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);@@ -128,8 +128,8 @@ SWVoiceIn *AUD_open_in (void AUD_close_in (AudioBackend *be,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 +0
-0
audio/audio.c static void audio_notify_capture (CaptureVoiceOut *cap, audcnotification_e cmd) · line 408
Quoted 5 lines
audio/audio.c +1
-1@@ -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)
Please fix checkpatch.pl errors while modifying these lines, otherwise:
Re: [PATCH v2 39/42] audio: cleanup, use bool for booleans
In reply to [email protected]Quoted 17 lines · On Wed, 22 Oct 2025, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Use slightly better types for the job.
Signed-off-by Marc-André Lureau <[email protected]>---
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 +0
-0
audio/audio_int.h typedef struct STSampleBuffer { · line 72
Quoted 8 lines
audio/audio_int.h +2
-2@@ -67,9 +67,9 @@ typedef struct STSampleBuffer { typedef struct HWVoiceOut { AudioBackend *s; - int enabled; + bool enabled; int poll_mode; - int pending_disable; + bool pending_disable;
I don't know if this is part of a state for migration but if not maybe it's better to also move pending_disable up before poll_mode to group the bools that enable/disable something together (and the struct may need less padding that way depending on what type by the compiler uses for bool).
Regards,
BALATON Zoltan
PATCH v2 40/42 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 ;struct AudioBackendClass {
@@ -78,13 +55,6 @@ typedef struct QEMUAudioTimeStamp { } QEMUAudioTimeStamp;bool AUD_backend_check (AudioBackend **be,Error **errp); -CaptureVoiceOut *AUD_add_capture ( -AudioBackend *s, -struct audsettings *as, -struct audio_capture_ops *ops, -void *opaque - ); -void AUD_del_capture (CaptureVoiceOut *cap,void *cb_opaque); SWVoiceOut *AUD_open_out ( AudioBackend *be,
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 v2 41/42 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
@@ -142,7 +142,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
PATCH v2 42/42 docs: Update mentions of removed '-soundhw' command line option
In reply to [email protected]From: Philippe Mathieu-Daudé <[email protected]>
The -soundhw CLI was removed in commit 039a68373c4 ("introduce -audio as a replacement for -soundhw"). Remove outdated comments and update the document mentioning the old usage.
--- docs/qdev-device-use.txt | 4 ++-- system/qdev-monitor.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
docs/qdev-device-use.txt +2 -2
@@ -311,9 +311,9 @@ constraints. Host and guest part of audio devices have always been separate. -The old way to define guest audio devices is -soundhw C1,... +The old way to define guest audio devices was -soundhw C1,... -The new way is to define each guest audio device separately with +The current way is to define each guest audio device separately with -device. Map from -soundhw sound card name to -device:
system/qdev-monitor.c +2 -2
@@ -73,9 +73,9 @@ typedef struct QDevAlias/* Please keep this table sorted by typename. */ static const QDevAlias qdev_alias_table[] = { - {"AC97" ,"ac97" },/* -soundhw name */ + {"AC97" ,"ac97" }, {"e1000" ,"e1000-82540em" }, - {"ES1370" ,"es1370" },/* -soundhw name */ + {"ES1370" ,"es1370" }, {"ich9-ahci" ,"ahci" }, {"lsi53c895a" ,"lsi" }, {"virtio-9p-device" ,"virtio-9p" ,QEMU_ARCH_VIRTIO_MMIO },
Signature · 1 line
2.51.0
[PATCH v2 43/42] audio: Remove pointless local variables
In reply to [email protected]--- audio/ossaudio.c | 12 ++---------- audio/sdlaudio.c | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-)
audio/ossaudio.c +2 -10
@@ -493,10 +493,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, {OSSVoiceOut *oss = (OSSVoiceOut *) hw;struct oss_params req, obt; -int endianness;int err;int fd; -AudioFormat effective_fmt;struct audsettings obt_as;Audiodev *dev = drv_opaque;AudiodevOssOptions *oopts = &dev->u.oss;
@@ -511,7 +509,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,return -1 ; } - err =oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); + err =oss_to_audfmt (obt.fmt, &obt_as.fmt, &obt_as.endianness);if (err) {oss_anal_close (&fd);return -1 ;
@@ -519,8 +517,6 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as); oss->nfrags = obt.nfrags;
@@ -628,10 +624,8 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) {OSSVoiceIn *oss = (OSSVoiceIn *) hw;struct oss_params req, obt; -int endianness;int err;int fd; -AudioFormat effective_fmt;struct audsettings obt_as;Audiodev *dev = drv_opaque;
@@ -644,7 +638,7 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)return -1 ; } - err =oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); + err =oss_to_audfmt (obt.fmt, &obt_as.fmt, &obt_as.endianness);if (err) {oss_anal_close (&fd);return -1 ;
@@ -652,8 +646,6 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as); oss->nfrags = obt.nfrags;
audio/sdlaudio.c +2 -10
@@ -338,9 +338,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, {SDLVoiceOut *sdl = (SDLVoiceOut *)hw;SDL_AudioSpec req, obt; -int endianness;int err; -AudioFormat effective_fmt;Audiodev *dev = drv_opaque;AudiodevSdlPerDirectionOptions *spdo = dev->u.sdl.out;struct audsettings obt_as;
@@ -360,7 +358,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,return -1 ; } - err =sdl_to_audfmt (obt.format, &effective_fmt, &endianness); + err =sdl_to_audfmt (obt.format, &obt_as.fmt, &obt_as.endianness);if (err) {sdl_close_out (sdl);return -1 ;
@@ -368,8 +366,6 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as); hw->samples = (spdo->has_buffer_count ? spdo->buffer_count : 4) *
@@ -398,9 +394,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque) {SDLVoiceIn *sdl = (SDLVoiceIn *)hw;SDL_AudioSpec req, obt; -int endianness;int err; -AudioFormat effective_fmt;Audiodev *dev = drv_opaque;AudiodevSdlPerDirectionOptions *spdo = dev->u.sdl.in;struct audsettings obt_as;
@@ -420,7 +414,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque)return -1 ; } - err =sdl_to_audfmt (obt.format, &effective_fmt, &endianness); + err =sdl_to_audfmt (obt.format, &obt_as.fmt, &obt_as.endianness);if (err) {sdl_close_in (sdl);return -1 ;
@@ -428,8 +422,6 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque) obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as); hw->samples = (spdo->has_buffer_count ? spdo->buffer_count : 4) *
Signature · 1 line
2.51.0
Marc-André Lureau
Reviewed-byRe: [PATCH v2 43/42] audio: Remove pointless local variables
Quoted 2 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 143 lines
--- audio/ossaudio.c | 12 ++---------- audio/sdlaudio.c | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-)audio/ossaudio.c +0
-2@@ -493,10 +493,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, {OSSVoiceOut *oss = (OSSVoiceOut *) hw;struct oss_params req, obt; -int endianness;int err;int fd; -AudioFormat effective_fmt;struct audsettings obt_as;Audiodev *dev = drv_opaque;AudiodevOssOptions *oopts = &dev->u.oss;audio/ossaudio.c +1
-1@@ -511,7 +509,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, return -1 ; } - err =oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); + err =oss_to_audfmt (obt.fmt, &obt_as.fmt, &obt_as.endianness);if (err) {oss_anal_close (&fd);return -1;audio/ossaudio.c +0
-2@@ -519,8 +517,6 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as);oss->nfrags = obt.nfrags;audio/ossaudio.c +1
-3@@ -628,10 +624,8 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) {OSSVoiceIn *oss = (OSSVoiceIn *) hw;struct oss_params req, obt; -int endianness;int err;int fd; -AudioFormat effective_fmt;struct audsettings obt_as;Audiodev *dev = drv_opaque;@@ -644,7 +638,7 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)return -1 ; } - err =oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); + err =oss_to_audfmt (obt.fmt, &obt_as.fmt, &obt_as.endianness);if (err) {oss_anal_close (&fd);return -1;audio/ossaudio.c +0
-2@@ -652,8 +646,6 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as);oss->nfrags = obt.nfrags;audio/sdlaudio.c +0
-2@@ -338,9 +338,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, {SDLVoiceOut *sdl = (SDLVoiceOut *)hw;SDL_AudioSpec req, obt; -int endianness;int err; -AudioFormat effective_fmt;Audiodev *dev = drv_opaque;AudiodevSdlPerDirectionOptions *spdo = dev->u.sdl.out;struct audsettings obt_as;audio/sdlaudio.c +1
-1@@ -360,7 +358,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, return -1 ; } - err =sdl_to_audfmt (obt.format, &effective_fmt, &endianness); + err =sdl_to_audfmt (obt.format, &obt_as.fmt, &obt_as.endianness);if (err) {sdl_close_out (sdl);return -1;audio/sdlaudio.c +0
-2@@ -368,8 +366,6 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as);hw->samples = (spdo->has_buffer_count ? spdo->buffer_count : 4) *audio/sdlaudio.c +0
-2@@ -398,9 +394,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque) {SDLVoiceIn *sdl = (SDLVoiceIn *)hw;SDL_AudioSpec req, obt; -int endianness;int err; -AudioFormat effective_fmt;Audiodev *dev = drv_opaque;AudiodevSdlPerDirectionOptions *spdo = dev->u.sdl.in;struct audsettings obt_as;audio/sdlaudio.c +1
-1@@ -420,7 +414,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque)return -1 ; } - err =sdl_to_audfmt (obt.format, &effective_fmt, &endianness); + err =sdl_to_audfmt (obt.format, &obt_as.fmt, &obt_as.endianness);if (err) {sdl_close_in (sdl);return -1;audio/sdlaudio.c +0
-2@@ -428,8 +422,6 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque) obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; - obt_as.fmt = effective_fmt; - obt_as.endianness = endianness;audio_pcm_init_info (&hw->info, &obt_as);hw->samples = (spdo->has_buffer_count ? spdo->buffer_count : 4) *--
2.51.0
[PATCH v2 44/42] audio: Rename @endianness argument as @big_endian for clarity
In reply to [email protected]@endianness is used as a boolean, rename for clarity.
--- audio/alsaaudio.c | 32 ++++++-------------------------- audio/ossaudio.c | 14 +++----------- audio/paaudio.c | 8 ++++---- audio/pwaudio.c | 12 ++++++------ 4 files changed, 19 insertions(+), 47 deletions(-)
audio/alsaaudio.c +6 -26
@@ -264,7 +264,7 @@ static int alsa_poll_in (HWVoiceIn *hw)return alsa_poll_helper (alsa->handle, &alsa->pollhlp,POLLIN ); } -static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt,int endianness) +static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt,bool big_endian) {switch (fmt) {case AUDIO_FORMAT_S8 :
@@ -274,39 +274,19 @@ static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness)return SND_PCM_FORMAT_U8 ;case AUDIO_FORMAT_S16 : -if (endianness) { -return SND_PCM_FORMAT_S16_BE ; - }else { -return SND_PCM_FORMAT_S16_LE ; - } +return big_endian ?SND_PCM_FORMAT_S16_BE :SND_PCM_FORMAT_S16_LE ;case AUDIO_FORMAT_U16 : -if (endianness) { -return SND_PCM_FORMAT_U16_BE ; - }else { -return SND_PCM_FORMAT_U16_LE ; - } +return big_endian ?SND_PCM_FORMAT_U16_BE :SND_PCM_FORMAT_U16_LE ;case AUDIO_FORMAT_S32 : -if (endianness) { -return SND_PCM_FORMAT_S32_BE ; - }else { -return SND_PCM_FORMAT_S32_LE ; - } +return big_endian ?SND_PCM_FORMAT_S32_BE :SND_PCM_FORMAT_S32_LE ;case AUDIO_FORMAT_U32 : -if (endianness) { -return SND_PCM_FORMAT_U32_BE ; - }else { -return SND_PCM_FORMAT_U32_LE ; - } +return big_endian ?SND_PCM_FORMAT_U32_BE :SND_PCM_FORMAT_U32_LE ;case AUDIO_FORMAT_F32 : -if (endianness) { -return SND_PCM_FORMAT_FLOAT_BE ; - }else { -return SND_PCM_FORMAT_FLOAT_LE ; - } +return big_endian ?SND_PCM_FORMAT_FLOAT_BE :SND_PCM_FORMAT_FLOAT_LE ;default :dolog ("Internal logic error: Bad audio format %d\n" , fmt);
audio/ossaudio.c +3 -11
@@ -131,7 +131,7 @@ static void oss_poll_in (HWVoiceIn *hw)qemu_set_fd_handler (oss->fd, oss_helper_poll_in,NULL , hw->s); } -static int aud_to_ossfmt (AudioFormat fmt,int endianness) +static int aud_to_ossfmt (AudioFormat fmt,bool big_endian) {switch (fmt) {case AUDIO_FORMAT_S8 :
@@ -141,18 +141,10 @@ static int aud_to_ossfmt (AudioFormat fmt, int endianness)return AFMT_U8 ;case AUDIO_FORMAT_S16 : -if (endianness) { -return AFMT_S16_BE ; - }else { -return AFMT_S16_LE ; - } +return big_endian ?AFMT_S16_BE :AFMT_S16_LE ;case AUDIO_FORMAT_U16 : -if (endianness) { -return AFMT_U16_BE ; - }else { -return AFMT_U16_LE ; - } +return big_endian ?AFMT_U16_BE :AFMT_U16_LE ;default :dolog ("Internal logic error: Bad audio format %d\n" , fmt);
audio/paaudio.c +4 -4
@@ -316,7 +316,7 @@ unlock_and_fail:return 0 ; } -static pa_sample_format_t audfmt_to_pa (AudioFormat afmt,int endianness) +static pa_sample_format_t audfmt_to_pa (AudioFormat afmt,bool big_endian) {int format;
@@ -327,14 +327,14 @@ static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness)break ;case AUDIO_FORMAT_S16 :case AUDIO_FORMAT_U16 : - format = endianness ?PA_SAMPLE_S16BE :PA_SAMPLE_S16LE ; + format = big_endian ?PA_SAMPLE_S16BE :PA_SAMPLE_S16LE ;break ;case AUDIO_FORMAT_S32 :case AUDIO_FORMAT_U32 : - format = endianness ?PA_SAMPLE_S32BE :PA_SAMPLE_S32LE ; + format = big_endian ?PA_SAMPLE_S32BE :PA_SAMPLE_S32LE ;break ;case AUDIO_FORMAT_F32 : - format = endianness ?PA_SAMPLE_FLOAT32BE :PA_SAMPLE_FLOAT32LE ; + format = big_endian ?PA_SAMPLE_FLOAT32BE :PA_SAMPLE_FLOAT32LE ;break ;default :dolog ("Internal logic error: Bad audio format %d\n" , afmt);
audio/pwaudio.c +6 -6
@@ -324,7 +324,7 @@ done_unlock: }static int -audfmt_to_pw (AudioFormat fmt,int endianness) +audfmt_to_pw (AudioFormat fmt,bool big_endian) {int format;
@@ -336,19 +336,19 @@ audfmt_to_pw(AudioFormat fmt, int endianness) format =SPA_AUDIO_FORMAT_U8 ;break ;case AUDIO_FORMAT_S16 : - format = endianness ?SPA_AUDIO_FORMAT_S16_BE :SPA_AUDIO_FORMAT_S16_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_S16_BE :SPA_AUDIO_FORMAT_S16_LE ;break ;case AUDIO_FORMAT_U16 : - format = endianness ?SPA_AUDIO_FORMAT_U16_BE :SPA_AUDIO_FORMAT_U16_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_U16_BE :SPA_AUDIO_FORMAT_U16_LE ;break ;case AUDIO_FORMAT_S32 : - format = endianness ?SPA_AUDIO_FORMAT_S32_BE :SPA_AUDIO_FORMAT_S32_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_S32_BE :SPA_AUDIO_FORMAT_S32_LE ;break ;case AUDIO_FORMAT_U32 : - format = endianness ?SPA_AUDIO_FORMAT_U32_BE :SPA_AUDIO_FORMAT_U32_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_U32_BE :SPA_AUDIO_FORMAT_U32_LE ;break ;case AUDIO_FORMAT_F32 : - format = endianness ?SPA_AUDIO_FORMAT_F32_BE :SPA_AUDIO_FORMAT_F32_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_F32_BE :SPA_AUDIO_FORMAT_F32_LE ;break ;default :dolog ("Internal logic error: Bad audio format %d\n" , fmt);
Signature · 1 line
2.51.0
Marc-André Lureau
Reviewed-byRe: [PATCH v2 44/42] audio: Rename @endianness argument as @big_endian for clarity
Quoted 4 lines · Philippe Mathieu-Daudé
@endianness is used as a boolean, rename for clarity.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 172 lines
--- audio/alsaaudio.c | 32 ++++++-------------------------- audio/ossaudio.c | 14 +++----------- audio/paaudio.c | 8 ++++---- audio/pwaudio.c | 12 ++++++------ 4 files changed, 19 insertions(+), 47 deletions(-)audio/alsaaudio.c +6
-26@@ -264,7 +264,7 @@ static int alsa_poll_in (HWVoiceIn *hw)return alsa_poll_helper (alsa->handle, &alsa->pollhlp,POLLIN ); } -static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt,int endianness) +static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt,bool big_endian) {switch (fmt) {case AUDIO_FORMAT_S8 :@@ -274,39 +274,19 @@ static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness)return SND_PCM_FORMAT_U8 ;case AUDIO_FORMAT_S16 : -if (endianness) { -return SND_PCM_FORMAT_S16_BE ; - }else { -return SND_PCM_FORMAT_S16_LE ; - } +return big_endian ?SND_PCM_FORMAT_S16_BE :SND_PCM_FORMAT_S16_LE ;case AUDIO_FORMAT_U16 : -if (endianness) { -return SND_PCM_FORMAT_U16_BE ; - }else { -return SND_PCM_FORMAT_U16_LE ; - } +return big_endian ?SND_PCM_FORMAT_U16_BE :SND_PCM_FORMAT_U16_LE ;case AUDIO_FORMAT_S32 : -if (endianness) { -return SND_PCM_FORMAT_S32_BE ; - }else { -return SND_PCM_FORMAT_S32_LE ; - } +return big_endian ?SND_PCM_FORMAT_S32_BE :SND_PCM_FORMAT_S32_LE ;case AUDIO_FORMAT_U32 : -if (endianness) { -return SND_PCM_FORMAT_U32_BE ; - }else { -return SND_PCM_FORMAT_U32_LE ; - } +return big_endian ?SND_PCM_FORMAT_U32_BE :SND_PCM_FORMAT_U32_LE ;case AUDIO_FORMAT_F32 : -if (endianness) { -return SND_PCM_FORMAT_FLOAT_BE ; - }else { -return SND_PCM_FORMAT_FLOAT_LE ; - } +return big_endian ?SND_PCM_FORMAT_FLOAT_BE :SND_PCM_FORMAT_FLOAT_LE ;default :dolog ("Internal logic error: Bad audio format %d\n" , fmt);audio/ossaudio.c +3
-11@@ -131,7 +131,7 @@ static void oss_poll_in (HWVoiceIn *hw)qemu_set_fd_handler (oss->fd, oss_helper_poll_in,NULL , hw->s); } -static int aud_to_ossfmt (AudioFormat fmt,int endianness) +static int aud_to_ossfmt (AudioFormat fmt,bool big_endian) {switch (fmt) {case AUDIO_FORMAT_S8 :@@ -141,18 +141,10 @@ static int aud_to_ossfmt (AudioFormat fmt, int endianness)return AFMT_U8 ;case AUDIO_FORMAT_S16 : -if (endianness) { -return AFMT_S16_BE ; - }else { -return AFMT_S16_LE ; - } +return big_endian ?AFMT_S16_BE :AFMT_S16_LE ;case AUDIO_FORMAT_U16 : -if (endianness) { -return AFMT_U16_BE ; - }else { -return AFMT_U16_LE ; - } +return big_endian ?AFMT_U16_BE :AFMT_U16_LE ;default :dolog ("Internal logic error: Bad audio format %d\n" , fmt);audio/paaudio.c +4
-4@@ -316,7 +316,7 @@ unlock_and_fail:return 0 ; } -static pa_sample_format_t audfmt_to_pa (AudioFormat afmt,int endianness) +static pa_sample_format_t audfmt_to_pa (AudioFormat afmt,bool big_endian) {int format;@@ -327,14 +327,14 @@ static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness)break ;case AUDIO_FORMAT_S16 :case AUDIO_FORMAT_U16 : - format = endianness ?PA_SAMPLE_S16BE :PA_SAMPLE_S16LE ; + format = big_endian ?PA_SAMPLE_S16BE :PA_SAMPLE_S16LE ;break ;case AUDIO_FORMAT_S32 :case AUDIO_FORMAT_U32 : - format = endianness ?PA_SAMPLE_S32BE :PA_SAMPLE_S32LE ; + format = big_endian ?PA_SAMPLE_S32BE :PA_SAMPLE_S32LE ;break ;case AUDIO_FORMAT_F32 : - format = endianness ?PA_SAMPLE_FLOAT32BE :PA_SAMPLE_FLOAT32LE ; + format = big_endian ?PA_SAMPLE_FLOAT32BE :PA_SAMPLE_FLOAT32LE ;break ;default :dolog ("Internal logic error: Bad audio format %d\n" , afmt);audio/pwaudio.c +6
-7@@ -324,7 +324,7 @@ done_unlock: }static int -audfmt_to_pw (AudioFormat fmt,int endianness) +audfmt_to_pw (AudioFormat fmt,bool big_endian) {int format;@@ -336,19 +336,19 @@ audfmt_to_pw(AudioFormat fmt, int endianness) format =SPA_AUDIO_FORMAT_U8 ;break ;case AUDIO_FORMAT_S16 : - format = endianness ?SPA_AUDIO_FORMAT_S16_BE :SPA_AUDIO_FORMAT_S16_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_S16_BE :SPA_AUDIO_FORMAT_S16_LE ;break ;case AUDIO_FORMAT_U16 : - format = endianness ?SPA_AUDIO_FORMAT_U16_BE :SPA_AUDIO_FORMAT_U16_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_U16_BE :SPA_AUDIO_FORMAT_U16_LE ;break ;case AUDIO_FORMAT_S32 : - format = endianness ?SPA_AUDIO_FORMAT_S32_BE :SPA_AUDIO_FORMAT_S32_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_S32_BE :SPA_AUDIO_FORMAT_S32_LE ;break ;case AUDIO_FORMAT_U32 : - format = endianness ?SPA_AUDIO_FORMAT_U32_BE :SPA_AUDIO_FORMAT_U32_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_U32_BE :SPA_AUDIO_FORMAT_U32_LE ;break ;case AUDIO_FORMAT_F32 : - format = endianness ?SPA_AUDIO_FORMAT_F32_BE :SPA_AUDIO_FORMAT_F32_LE ; + format = big_endian ?SPA_AUDIO_FORMAT_F32_BE :SPA_AUDIO_FORMAT_F32_LE ;break ;default :dolog ("Internal logic error: Bad audio format %d\n" , fmt); --2.51.0
Signature · 1 line
Marc-André Lureau