audio: Make the AudiodevDriver enum conditional
RFC PATCH 1/1 audio: Make the AudiodevDriver enum conditional
This way, the upper layers like libvirt could have the possibility to use QAPI to find out which audio drivers have been enabled during compile-time of QEMU.
---
Note: Marked as RFC since it's quite a lot of ifdef'ing here...
not sure whether I really like it...
audio/audio.c | 16 +++++++++++++++ audio/audio_legacy.c | 45 +++++++++++++++++++++++++++++------------- audio/audio_template.h | 16 +++++++++++++++ qapi/audio.json | 37 ++++++++++++++++++++++++---------- 4 files changed, 90 insertions(+), 24 deletions(-)
audio/audio.c +16 -0
@@ -1988,14 +1988,30 @@ void audio_create_pdos(Audiodev *dev) break CASE(NONE, none, ); +#if defined(CONFIG_AUDIO_ALSA )CASE (ALSA , alsa, Alsa); +#endif +#if defined(CONFIG_AUDIO_COREAUDIO )CASE (COREAUDIO , coreaudio, Coreaudio); +#endif +#if defined(CONFIG_AUDIO_DSOUND ) CASE(DSOUND, dsound, ); +#endif +#if defined(CONFIG_AUDIO_JACK )CASE (JACK , jack, Jack); +#endif +#if defined(CONFIG_AUDIO_OSS )CASE (OSS , oss, Oss); +#endif +#if defined(CONFIG_AUDIO_PA )CASE (PA , pa, Pa); +#endif +#if defined(CONFIG_AUDIO_SDL )CASE (SDL , sdl, Sdl); +#endif +#if defined(CONFIG_SPICE ) CASE(SPICE, spice, ); +#endif CASE(WAV, wav, );case AUDIODEV_DRIVER__MAX :
audio/audio_legacy.c +31 -14
158 lines not on this page · raw message
audio/audio_template.h +16 -0
@@ -322,23 +322,39 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)switch (dev->driver) {case AUDIODEV_DRIVER_NONE :return dev->u.none.TYPE; +#if defined(CONFIG_AUDIO_ALSA )case AUDIODEV_DRIVER_ALSA :return qapi_AudiodevAlsaPerDirectionOptions_base (dev->u.alsa.TYPE); +#endif +#if defined(CONFIG_AUDIO_COREAUDIO )case AUDIODEV_DRIVER_COREAUDIO :return qapi_AudiodevCoreaudioPerDirectionOptions_base ( dev->u.coreaudio.TYPE); +#endif +#if defined(CONFIG_AUDIO_DSOUND )case AUDIODEV_DRIVER_DSOUND :return dev->u.dsound.TYPE; +#endif +#if defined(CONFIG_AUDIO_JACK )case AUDIODEV_DRIVER_JACK :return qapi_AudiodevJackPerDirectionOptions_base (dev->u.jack.TYPE); +#endif +#if defined(CONFIG_AUDIO_OSS )case AUDIODEV_DRIVER_OSS :return qapi_AudiodevOssPerDirectionOptions_base (dev->u.oss.TYPE); +#endif +#if defined(CONFIG_AUDIO_PA )case AUDIODEV_DRIVER_PA :return qapi_AudiodevPaPerDirectionOptions_base (dev->u.pa.TYPE); +#endif +#if defined(CONFIG_AUDIO_SDL )case AUDIODEV_DRIVER_SDL :return qapi_AudiodevSdlPerDirectionOptions_base (dev->u.sdl.TYPE); +#endif +#if defined(CONFIG_SPICE )case AUDIODEV_DRIVER_SPICE :return dev->u.spice.TYPE; +#endif case AUDIODEV_DRIVER_WAV :return dev->u.wav.TYPE;
qapi/audio.json +27 -10
@@ -386,8 +386,17 @@ # Since: 4.0 ## { 'enum': 'AudiodevDriver', - 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa', - 'sdl', 'spice', 'wav' ] } + 'data': [ + { 'name': 'none' }, + { 'name': 'alsa', 'if': 'defined(CONFIG_AUDIO_ALSA)' }, + { 'name': 'coreaudio', 'if': 'defined(CONFIG_AUDIO_COREAUDIO)' }, + { 'name': 'dsound', 'if': 'defined(CONFIG_AUDIO_DSOUND)' }, + { 'name': 'jack', 'if': 'defined(CONFIG_AUDIO_JACK)' }, + { 'name': 'oss', 'if': 'defined(CONFIG_AUDIO_OSS)' }, + { 'name': 'pa', 'if': 'defined(CONFIG_AUDIO_PA)' }, + { 'name': 'sdl', 'if': 'defined(CONFIG_AUDIO_SDL)' }, + { 'name': 'spice', 'if': 'defined(CONFIG_SPICE)' }, + { 'name': 'wav' } ] } ## # @Audiodev:
@@ -410,12 +419,20 @@ 'discriminator': 'driver', 'data': { 'none': 'AudiodevGenericOptions', - 'alsa': 'AudiodevAlsaOptions', - 'coreaudio': 'AudiodevCoreaudioOptions', - 'dsound': 'AudiodevDsoundOptions', - 'jack': 'AudiodevJackOptions', - 'oss': 'AudiodevOssOptions', - 'pa': 'AudiodevPaOptions', - 'sdl': 'AudiodevSdlOptions', - 'spice': 'AudiodevGenericOptions', + 'alsa': { 'type': 'AudiodevAlsaOptions', + 'if': 'defined(CONFIG_AUDIO_ALSA)' }, + 'coreaudio': { 'type': 'AudiodevCoreaudioOptions', + 'if': 'defined(CONFIG_AUDIO_COREAUDIO)' }, + 'dsound': { 'type': 'AudiodevDsoundOptions', + 'if': 'defined(CONFIG_AUDIO_DSOUND)' }, + 'jack': { 'type': 'AudiodevJackOptions', + 'if': 'defined(CONFIG_AUDIO_JACK)' }, + 'oss': { 'type': 'AudiodevOssOptions', + 'if': 'defined(CONFIG_AUDIO_OSS)' }, + 'pa': { 'type': 'AudiodevPaOptions', + 'if': 'defined(CONFIG_AUDIO_PA)' }, + 'sdl': { 'type': 'AudiodevSdlOptions', + 'if': 'defined(CONFIG_AUDIO_SDL)' }, + 'spice': { 'type': 'AudiodevGenericOptions', + 'if': 'defined(CONFIG_SPICE)' }, 'wav': 'AudiodevWavOptions' } }
Signature · 1 line
2.27.0
Quoted 8 lines · Thomas Huth
This way, the upper layers like libvirt could have the possibility to use QAPI to find out which audio drivers have been enabled during compile-time of QEMU.
Signed-off-by Thomas Huth <[email protected]>---
Note: Marked as RFC since it's quite a lot of ifdef'ing here...
not sure whether I really like it...
Same as my patch here:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg00654.html
Quoted 320 lines
audio/audio.c | 16 +++++++++++++++ audio/audio_legacy.c | 45 +++++++++++++++++++++++++++++------------- audio/audio_template.h | 16 +++++++++++++++ qapi/audio.json | 37 ++++++++++++++++++++++++---------- 4 files changed, 90 insertions(+), 24 deletions(-)audio/audio.c +16
-0@@ -1988,14 +1988,30 @@ void audio_create_pdos(Audiodev *dev) break CASE(NONE, none, ); +#if defined(CONFIG_AUDIO_ALSA )CASE (ALSA , alsa, Alsa); +#endif +#if defined(CONFIG_AUDIO_COREAUDIO )CASE (COREAUDIO , coreaudio, Coreaudio); +#endif +#if defined(CONFIG_AUDIO_DSOUND ) CASE(DSOUND, dsound, ); +#endif +#if defined(CONFIG_AUDIO_JACK )CASE (JACK , jack, Jack); +#endif +#if defined(CONFIG_AUDIO_OSS )CASE (OSS , oss, Oss); +#endif +#if defined(CONFIG_AUDIO_PA )CASE (PA , pa, Pa); +#endif +#if defined(CONFIG_AUDIO_SDL )CASE (SDL , sdl, Sdl); +#endif +#if defined(CONFIG_SPICE ) CASE(SPICE, spice, ); +#endif CASE(WAV, wav, );case AUDIODEV_DRIVER__MAX :audio/audio_legacy.c +31
-14@@ -92,7 +92,7 @@ static void get_fmt(const char *env, AudioFormat *dst, bool *has_dst) } } - +#if defined(CONFIG_AUDIO_ALSA ) || defined(CONFIG_AUDIO_DSOUND )static void get_millis_to_usecs (const char *env,uint32_t *dst,bool *has_dst) {const char *val =getenv (env);@@ -101,6 +101,7 @@ static void get_millis_to_usecs(const char *env, uint32_t *dst, bool *has_dst) *has_dst = true; } } +#endif static uint32_t frames_to_usecs (uint32_t frames,AudiodevPerDirectionOptions *pdo)@@ -109,7 +110,7 @@ static uint32_t frames_to_usecs(uint32_t frames,return (frames *1000000 + freq /2 ) / freq; } - +#if defined(CONFIG_AUDIO_COREAUDIO )static void get_frames_to_usecs (const char *env,uint32_t *dst,bool *has_dst,AudiodevPerDirectionOptions *pdo) {@@ -119,6 +120,7 @@ static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_dst, *has_dst = true; } } +#endif static uint32_t samples_to_usecs (uint32_t samples,AudiodevPerDirectionOptions *pdo)@@ -127,6 +129,7 @@ static uint32_t samples_to_usecs(uint32_t samples,return frames_to_usecs (samples / channels, pdo); } +#if defined(CONFIG_AUDIO_PA ) || defined(CONFIG_AUDIO_SDL )static void get_samples_to_usecs (const char *env,uint32_t *dst,bool *has_dst,AudiodevPerDirectionOptions *pdo) {@@ -136,6 +139,7 @@ static void get_samples_to_usecs(const char *env, uint32_t *dst, bool *has_dst, *has_dst = true; } } +#endif static uint32_t bytes_to_usecs (uint32_t bytes,AudiodevPerDirectionOptions *pdo) {@@ -144,6 +148,7 @@ static uint32_t bytes_to_usecs(uint32_t bytes, AudiodevPerDirectionOptions *pdo)return samples_to_usecs (bytes / bytes_per_sample, pdo); } +__attribute__((unused))static void get_bytes_to_usecs (const char *env,uint32_t *dst,bool *has_dst,AudiodevPerDirectionOptions *pdo) {@@ -155,7 +160,7 @@ static void get_bytes_to_usecs(const char *env, uint32_t *dst, bool *has_dst, }/* backend specific functions */ -/* ALSA */ +#if defined(CONFIG_AUDIO_ALSA )static void handle_alsa_per_direction (AudiodevAlsaPerDirectionOptions *apdo,const char *prefix) {@@ -200,8 +205,9 @@ static void handle_alsa(Audiodev *dev)get_millis_to_usecs ("QEMU_ALSA_THRESHOLD" , &aopt->threshold, &aopt->has_threshold); } +#endif -/* coreaudio */ +#if defined(CONFIG_AUDIO_COREAUDIO )static void handle_coreaudio (Audiodev *dev) { get_frames_to_usecs(@@ -213,8 +219,9 @@ static void handle_coreaudio(Audiodev *dev) &dev->u.coreaudio.out->buffer_count, &dev->u.coreaudio.out->has_buffer_count); } +#endif -/* dsound */ +#if defined(CONFIG_AUDIO_DSOUND )static void handle_dsound (Audiodev *dev) { get_millis_to_usecs("QEMU_DSOUND_LATENCY_MILLIS",@@ -228,8 +235,9 @@ static void handle_dsound(Audiodev *dev) &dev->u.dsound.in->has_buffer_length, dev->u.dsound.in); } +#endif -/* OSS */ +#if defined(CONFIG_AUDIO_OSS )static void handle_oss_per_direction (AudiodevOssPerDirectionOptions *opdo,const char *try_poll_env,const char *dev_env)@@ -256,8 +264,9 @@ static void handle_oss(Audiodev *dev)get_bool ("QEMU_OSS_EXCLUSIVE" , &oopt->exclusive, &oopt->has_exclusive);get_int ("QEMU_OSS_POLICY" , &oopt->dsp_policy, &oopt->has_dsp_policy); } +#endif -/* pulseaudio */ +#if defined(CONFIG_AUDIO_PA )static void handle_pa_per_direction (AudiodevPaPerDirectionOptions *ppdo,const char *env) {@@ -280,8 +289,9 @@ static void handle_pa(Audiodev *dev)get_str ("QEMU_PA_SERVER" , &dev->u.pa.server, &dev->u.pa.has_server); } +#endif -/* SDL */ +#if defined(CONFIG_AUDIO_SDL )static void handle_sdl (Audiodev *dev) {/* SDL is output only */ @@ -289,6 +299,7 @@ static void handle_sdl(Audiodev *dev) &dev->u.sdl.out->has_buffer_length, qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.out)); } +#endif /* wav */ static void handle_wav (Audiodev *dev)@@ -348,30 +359,36 @@ static AudiodevListEntry *legacy_opt(const char *drvname) }switch (e->dev->driver) { +#if defined(CONFIG_AUDIO_ALSA )case AUDIODEV_DRIVER_ALSA :handle_alsa (e->dev);break ; - +#endif +#if defined(CONFIG_AUDIO_COREAUDIO )case AUDIODEV_DRIVER_COREAUDIO :handle_coreaudio (e->dev);break ; - +#endif +#if defined(CONFIG_AUDIO_DSOUND )case AUDIODEV_DRIVER_DSOUND :handle_dsound (e->dev);break ; - +#endif +#if defined(CONFIG_AUDIO_OSS )case AUDIODEV_DRIVER_OSS :handle_oss (e->dev);break ; - +#endif +#if defined(CONFIG_AUDIO_PA )case AUDIODEV_DRIVER_PA :handle_pa (e->dev);break ; - +#endif +#if defined(CONFIG_AUDIO_SDL )case AUDIODEV_DRIVER_SDL :handle_sdl (e->dev);break ; - +#endif case AUDIODEV_DRIVER_WAV :handle_wav (e->dev);break ;audio/audio_template.h +16
-0@@ -322,23 +322,39 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)switch (dev->driver) {case AUDIODEV_DRIVER_NONE :return dev->u.none.TYPE; +#if defined(CONFIG_AUDIO_ALSA )case AUDIODEV_DRIVER_ALSA :return qapi_AudiodevAlsaPerDirectionOptions_base (dev->u.alsa.TYPE); +#endif +#if defined(CONFIG_AUDIO_COREAUDIO )case AUDIODEV_DRIVER_COREAUDIO :return qapi_AudiodevCoreaudioPerDirectionOptions_base ( dev->u.coreaudio.TYPE); +#endif +#if defined(CONFIG_AUDIO_DSOUND )case AUDIODEV_DRIVER_DSOUND :return dev->u.dsound.TYPE; +#endif +#if defined(CONFIG_AUDIO_JACK )case AUDIODEV_DRIVER_JACK :return qapi_AudiodevJackPerDirectionOptions_base (dev->u.jack.TYPE); +#endif +#if defined(CONFIG_AUDIO_OSS )case AUDIODEV_DRIVER_OSS :return qapi_AudiodevOssPerDirectionOptions_base (dev->u.oss.TYPE); +#endif +#if defined(CONFIG_AUDIO_PA )case AUDIODEV_DRIVER_PA :return qapi_AudiodevPaPerDirectionOptions_base (dev->u.pa.TYPE); +#endif +#if defined(CONFIG_AUDIO_SDL )case AUDIODEV_DRIVER_SDL :return qapi_AudiodevSdlPerDirectionOptions_base (dev->u.sdl.TYPE); +#endif +#if defined(CONFIG_SPICE )case AUDIODEV_DRIVER_SPICE :return dev->u.spice.TYPE; +#endif case AUDIODEV_DRIVER_WAV :return dev->u.wav.TYPE;qapi/audio.json +27
-10@@ -386,8 +386,17 @@ # Since: 4.0 ## { 'enum': 'AudiodevDriver', - 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa', - 'sdl', 'spice', 'wav' ] } + 'data': [ + { 'name': 'none' }, + { 'name': 'alsa', 'if': 'defined(CONFIG_AUDIO_ALSA)' }, + { 'name': 'coreaudio', 'if': 'defined(CONFIG_AUDIO_COREAUDIO)' }, + { 'name': 'dsound', 'if': 'defined(CONFIG_AUDIO_DSOUND)' }, + { 'name': 'jack', 'if': 'defined(CONFIG_AUDIO_JACK)' }, + { 'name': 'oss', 'if': 'defined(CONFIG_AUDIO_OSS)' }, + { 'name': 'pa', 'if': 'defined(CONFIG_AUDIO_PA)' }, + { 'name': 'sdl', 'if': 'defined(CONFIG_AUDIO_SDL)' }, + { 'name': 'spice', 'if': 'defined(CONFIG_SPICE)' }, + { 'name': 'wav' } ] } ## # @Audiodev:@@ -410,12 +419,20 @@ 'discriminator': 'driver', 'data': { 'none': 'AudiodevGenericOptions', - 'alsa': 'AudiodevAlsaOptions', - 'coreaudio': 'AudiodevCoreaudioOptions', - 'dsound': 'AudiodevDsoundOptions', - 'jack': 'AudiodevJackOptions', - 'oss': 'AudiodevOssOptions', - 'pa': 'AudiodevPaOptions', - 'sdl': 'AudiodevSdlOptions', - 'spice': 'AudiodevGenericOptions', + 'alsa': { 'type': 'AudiodevAlsaOptions', + 'if': 'defined(CONFIG_AUDIO_ALSA)' }, + 'coreaudio': { 'type': 'AudiodevCoreaudioOptions', + 'if': 'defined(CONFIG_AUDIO_COREAUDIO)' }, + 'dsound': { 'type': 'AudiodevDsoundOptions', + 'if': 'defined(CONFIG_AUDIO_DSOUND)' }, + 'jack': { 'type': 'AudiodevJackOptions', + 'if': 'defined(CONFIG_AUDIO_JACK)' }, + 'oss': { 'type': 'AudiodevOssOptions', + 'if': 'defined(CONFIG_AUDIO_OSS)' }, + 'pa': { 'type': 'AudiodevPaOptions', + 'if': 'defined(CONFIG_AUDIO_PA)' }, + 'sdl': { 'type': 'AudiodevSdlOptions', + 'if': 'defined(CONFIG_AUDIO_SDL)' }, + 'spice': { 'type': 'AudiodevGenericOptions', + 'if': 'defined(CONFIG_SPICE)' }, 'wav': 'AudiodevWavOptions' } }Signature · 1 line
2.27.0
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Thomas Huth
This way, the upper layers like libvirt could have the possibility to use QAPI to find out which audio drivers have been enabled during compile-time of QEMU.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Thomas Huth <[email protected]>---
Note: Marked as RFC since it's quite a lot of ifdef'ing here...
not sure whether I really like it...Same as my patch here:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg00654.html
Oh, nice, I guess it means that it's not such a bad idea to introduce all those #ifdefs here :-)
Anyway, looks like my patch was incomplete anyway (I just hacked it together after my corresponding DisplayType patch - see https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg06529.html), since it lacks the wiring via a qapi command, so please disregard this RFC PATCH. Are you going to respin your series from March, Daniel?
Thomas
Quoted 13 lines · Thomas Huth
Quoted 11 lines · Daniel P. Berrangé
Quoted 8 lines · Thomas Huth
This way, the upper layers like libvirt could have the possibility to use QAPI to find out which audio drivers have been enabled during compile-time of QEMU.
Signed-off-by Thomas Huth <[email protected]>---
Note: Marked as RFC since it's quite a lot of ifdef'ing here...
not sure whether I really like it...Same as my patch here:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg00654.html
Quoted 8 lines
Oh, nice, I guess it means that it's not such a bad idea to introduce all those #ifdefs here :-)
Anyway, looks like my patch was incomplete anyway (I just hacked it together after my corresponding DisplayType patch - see
https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg06529.html),
since it lacks the wiring via a qapi command, so please disregard this RFC PATCH. Are you going to respin your series from March, Daniel?
I reviewed Daniel's series back then, and pointed out a few minor issues, mostly in commit messages. I hope that wasn't the reason for it getting stuck :)
Quoted 24 lines · Markus Armbruster
Quoted 13 lines · Thomas Huth
Quoted 11 lines · Daniel P. Berrangé
Quoted 8 lines · Thomas Huth
This way, the upper layers like libvirt could have the possibility to use QAPI to find out which audio drivers have been enabled during compile-time of QEMU.
Signed-off-by Thomas Huth <[email protected]>---
Note: Marked as RFC since it's quite a lot of ifdef'ing here...
not sure whether I really like it...Same as my patch here:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg00654.htmlQuoted 8 lines
Oh, nice, I guess it means that it's not such a bad idea to introduce all those #ifdefs here :-)
Anyway, looks like my patch was incomplete anyway (I just hacked it together after my corresponding DisplayType patch - see
https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg06529.html),
since it lacks the wiring via a qapi command, so please disregard this RFC PATCH. Are you going to respin your series from March, Daniel?
Quoted 3 lines
I reviewed Daniel's series back then, and pointed out a few minor issues, mostly in commit messages. I hope that wasn't the reason for it getting stuck :)
No, I'm mostly just side-tracked on other work I'm afraid.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|