Hi
On Fri, Jan 23, 2026 at 6:24 PM BALATON Zoltan <[email protected]> wrote:
>
> On Fri, 23 Jan 2026, [email protected] wrote:
> > From: Marc-André Lureau <[email protected]>
> >
> > This will allow to use QOM and the dynamic object module loading.
> >
> > Signed-off-by: Marc-André Lureau <[email protected]>
> > ---
> > audio/audio_int.h | 2 ++
> > audio/alsaaudio.c | 27 +++++++++++++++++++++++++++
> > audio/dbusaudio.c | 26 ++++++++++++++++++++++++++
> > audio/dsoundaudio.c | 26 ++++++++++++++++++++++++++
> > audio/jackaudio.c | 26 ++++++++++++++++++++++++++
> > audio/noaudio.c | 26 ++++++++++++++++++++++++++
> > audio/ossaudio.c | 26 ++++++++++++++++++++++++++
> > audio/paaudio.c | 26 ++++++++++++++++++++++++++
> > audio/pwaudio.c | 26 ++++++++++++++++++++++++++
> > audio/sdlaudio.c | 26 ++++++++++++++++++++++++++
> > audio/sndioaudio.c | 26 ++++++++++++++++++++++++++
> > audio/spiceaudio.c | 26 ++++++++++++++++++++++++++
> > audio/wavaudio.c | 26 ++++++++++++++++++++++++++
> > audio/coreaudio.m | 26 ++++++++++++++++++++++++++
> > 14 files changed, 341 insertions(+)
> >
> > diff --git a/audio/audio_int.h b/audio/audio_int.h
> > index 06f5160e8df..29f5864be69 100644
> > --- a/audio/audio_int.h
> > +++ b/audio/audio_int.h
> > @@ -241,6 +241,8 @@ struct SWVoiceCap {
> >
> > struct AudioMixengBackendClass {
> > AudioBackendClass parent_class;
> > +
> > + audio_driver *driver;
> > };
> >
> > struct AudioMixengBackend {
> > diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
> > index 814820e2864..881f3d0349d 100644
> > --- a/audio/alsaaudio.c
> > +++ b/audio/alsaaudio.c
> > @@ -27,6 +27,7 @@
> > #include "qemu/main-loop.h"
> > #include "qemu/module.h"
> > #include "qemu/audio.h"
> > +#include "qom/object.h"
> > #include "trace.h"
> >
> > #pragma GCC diagnostic ignored "-Waddress"
> > @@ -36,6 +37,22 @@
> >
> > #define DEBUG_ALSA 0
> >
> > +#define TYPE_AUDIO_ALSA "audio-alsa"
> > +OBJECT_DECLARE_SIMPLE_TYPE(AudioALSA, AUDIO_ALSA)
> > +
> > +struct AudioALSA {
> > + AudioMixengBackend parent;
> > +};
>
> If you have nothing to put here only the parent you don't need to declare
> the state struct...
>
> > +
> > +static struct audio_driver alsa_audio_driver;
> > +
> > +static void audio_alsa_class_init(ObjectClass *klass, const void *data)
> > +{
> > + AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
> > +
> > + k->driver = &alsa_audio_driver;
> > +}
> > +
> > struct pollhlp {
> > snd_pcm_t *handle;
> > struct pollfd *pfds;
> > @@ -945,8 +962,18 @@ static struct audio_driver alsa_audio_driver = {
> > .voice_size_in = sizeof (ALSAVoiceIn)
> > };
> >
> > +static const TypeInfo audio_alsa_info = {
> > + .name = TYPE_AUDIO_ALSA,
> > + .parent = TYPE_AUDIO_MIXENG_BACKEND,
> > + .instance_size = sizeof(AudioALSA),
>
> ...and can set instance_size of the parent so I think you can drop the
> struct above everywhere where no other fields are needed other than the
> parent. (See e.g. via_mc97_info)
True, although the pending patches to finish the conversion to QOM will
add fields there. This is an intermediary step, but yes, I can drop
the "empty" structs for now.
>
> Regards,
> BALATON Zoltan
>
> > + .class_init = audio_alsa_class_init,
> > +};
> > +
> > +
> > static void register_audio_alsa(void)
> > {
> > audio_driver_register(&alsa_audio_driver);
> > + type_register_static(&audio_alsa_info);
> > }
> > type_init(register_audio_alsa);
> > +module_obj(TYPE_AUDIO_ALSA);
--
Marc-André Lureau