* [Qemu-devel] [PATCH 0/7] audio: modularize
@ 2018-03-06 7:40 Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 1/7] audio: add driver registry Gerd Hoffmann
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Add audio driver (host backend) registry. Add audio module support.
Enable module builds for alsa, oss, pulse and sdl.
Gerd Hoffmann (7):
audio: add driver registry
audio: add module loading support
build: enable audio modules
audio/alsa: build as module
audio/oss: build as module
audio/pulseaudio: build as module
audio/sdl: build as module
configure | 7 ++++-
Makefile | 4 +++
Makefile.objs | 1 +
audio/audio_int.h | 14 ++++-----
include/qemu/module.h | 1 +
audio/alsaaudio.c | 8 ++++-
audio/audio.c | 83 +++++++++++++++++++++++++++++++++++----------------
audio/coreaudio.c | 8 ++++-
audio/dsoundaudio.c | 8 ++++-
audio/noaudio.c | 8 ++++-
audio/ossaudio.c | 8 ++++-
audio/paaudio.c | 8 ++++-
audio/sdlaudio.c | 8 ++++-
audio/spiceaudio.c | 8 ++++-
audio/wavaudio.c | 8 ++++-
audio/Makefile.objs | 30 +++++++++++++------
scripts/create_config | 2 +-
17 files changed, 159 insertions(+), 55 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 1/7] audio: add driver registry
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 10:58 ` Marc-André Lureau
2018-03-06 7:40 ` [Qemu-devel] [PATCH 2/7] audio: add module loading support Gerd Hoffmann
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Add registry for audio drivers, using the existing audio_driver struct.
Make all drivers register themself. The old list of audio_driver struct
pointers is now a list of audio driver names, specifying the priority
(aka probe order) in case no driver is explicitly asked for.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
audio/audio_int.h | 14 ++++--------
audio/alsaaudio.c | 8 ++++++-
audio/audio.c | 63 ++++++++++++++++++++++++++++++---------------------
audio/coreaudio.c | 8 ++++++-
audio/dsoundaudio.c | 8 ++++++-
audio/noaudio.c | 8 ++++++-
audio/ossaudio.c | 8 ++++++-
audio/paaudio.c | 8 ++++++-
audio/sdlaudio.c | 8 ++++++-
audio/spiceaudio.c | 8 ++++++-
audio/wavaudio.c | 8 ++++++-
scripts/create_config | 2 +-
12 files changed, 106 insertions(+), 45 deletions(-)
diff --git a/audio/audio_int.h b/audio/audio_int.h
index 700bd43143..244b454012 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -141,6 +141,7 @@ struct SWVoiceIn {
QLIST_ENTRY (SWVoiceIn) entries;
};
+typedef struct audio_driver audio_driver;
struct audio_driver {
const char *name;
const char *descr;
@@ -154,6 +155,7 @@ struct audio_driver {
int voice_size_out;
int voice_size_in;
int ctl_caps;
+ QLIST_ENTRY(audio_driver) next;
};
struct audio_pcm_ops {
@@ -203,17 +205,11 @@ struct AudioState {
int vm_running;
};
-extern struct audio_driver no_audio_driver;
-extern struct audio_driver oss_audio_driver;
-extern struct audio_driver sdl_audio_driver;
-extern struct audio_driver wav_audio_driver;
-extern struct audio_driver alsa_audio_driver;
-extern struct audio_driver coreaudio_audio_driver;
-extern struct audio_driver dsound_audio_driver;
-extern struct audio_driver pa_audio_driver;
-extern struct audio_driver spice_audio_driver;
extern const struct mixeng_volume nominal_volume;
+void audio_driver_register(audio_driver *drv);
+audio_driver *audio_driver_lookup(const char *name);
+
void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 92a96f8b2b..362a2276fd 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -1213,7 +1213,7 @@ static struct audio_pcm_ops alsa_pcm_ops = {
.ctl_in = alsa_ctl_in,
};
-struct audio_driver alsa_audio_driver = {
+static struct audio_driver alsa_audio_driver = {
.name = "alsa",
.descr = "ALSA http://www.alsa-project.org",
.options = alsa_options,
@@ -1226,3 +1226,9 @@ struct audio_driver alsa_audio_driver = {
.voice_size_out = sizeof (ALSAVoiceOut),
.voice_size_in = sizeof (ALSAVoiceIn)
};
+
+static void register_audio_alsa(void)
+{
+ audio_driver_register(&alsa_audio_driver);
+}
+type_init(register_audio_alsa);
diff --git a/audio/audio.c b/audio/audio.c
index 7658d2af66..2384612b87 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -45,15 +45,32 @@
The 1st one is the one used by default, that is the reason
that we generate the list.
*/
-static struct audio_driver *drvtab[] = {
-#ifdef CONFIG_SPICE
- &spice_audio_driver,
-#endif
+static const char *audio_prio_list[] = {
+ "spice",
CONFIG_AUDIO_DRIVERS
- &no_audio_driver,
- &wav_audio_driver
+ "none",
+ "wav",
};
+static QLIST_HEAD(, audio_driver) audio_drivers;
+
+void audio_driver_register(audio_driver *drv)
+{
+ QLIST_INSERT_HEAD(&audio_drivers, drv, next);
+}
+
+audio_driver *audio_driver_lookup(const char *name)
+{
+ struct audio_driver *d;
+
+ QLIST_FOREACH(d, &audio_drivers, next) {
+ if (strcmp(name, d->name) == 0) {
+ return d;
+ }
+ }
+ return NULL;
+}
+
struct fixed_settings {
int enabled;
int nb_voices;
@@ -1656,11 +1673,10 @@ static void audio_pp_nb_voices (const char *typ, int nb)
void AUD_help (void)
{
- size_t i;
+ struct audio_driver *d;
audio_process_options ("AUDIO", audio_options);
- for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
- struct audio_driver *d = drvtab[i];
+ QLIST_FOREACH(d, &audio_drivers, next) {
if (d->options) {
audio_process_options (d->name, d->options);
}
@@ -1672,8 +1688,7 @@ void AUD_help (void)
printf ("Available drivers:\n");
- for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
- struct audio_driver *d = drvtab[i];
+ QLIST_FOREACH(d, &audio_drivers, next) {
printf ("Name: %s\n", d->name);
printf ("Description: %s\n", d->descr);
@@ -1807,6 +1822,7 @@ static void audio_init (void)
const char *drvname;
VMChangeStateEntry *e;
AudioState *s = &glob_audio_state;
+ struct audio_driver *driver;
if (s->drv) {
return;
@@ -1842,32 +1858,27 @@ static void audio_init (void)
}
if (drvname) {
- int found = 0;
-
- for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
- if (!strcmp (drvname, drvtab[i]->name)) {
- done = !audio_driver_init (s, drvtab[i]);
- found = 1;
- break;
- }
- }
-
- if (!found) {
+ driver = audio_driver_lookup(drvname);
+ if (driver) {
+ done = !audio_driver_init(s, driver);
+ } else {
dolog ("Unknown audio driver `%s'\n", drvname);
dolog ("Run with -audio-help to list available drivers\n");
}
}
if (!done) {
- for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) {
- if (drvtab[i]->can_be_default) {
- done = !audio_driver_init (s, drvtab[i]);
+ for (i = 0; !done && i < ARRAY_SIZE(audio_prio_list); i++) {
+ driver = audio_driver_lookup(audio_prio_list[i]);
+ if (driver && driver->can_be_default) {
+ done = !audio_driver_init(s, driver);
}
}
}
if (!done) {
- done = !audio_driver_init (s, &no_audio_driver);
+ driver = audio_driver_lookup("none");
+ done = !audio_driver_init(s, driver);
assert(done);
dolog("warning: Using timer based audio emulation\n");
}
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index c75142084f..638c60b300 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -722,7 +722,7 @@ static struct audio_pcm_ops coreaudio_pcm_ops = {
.ctl_out = coreaudio_ctl_out
};
-struct audio_driver coreaudio_audio_driver = {
+static struct audio_driver coreaudio_audio_driver = {
.name = "coreaudio",
.descr = "CoreAudio http://developer.apple.com/audio/coreaudio.html",
.options = coreaudio_options,
@@ -735,3 +735,9 @@ struct audio_driver coreaudio_audio_driver = {
.voice_size_out = sizeof (coreaudioVoiceOut),
.voice_size_in = 0
};
+
+static void register_audio_coreaudio(void)
+{
+ audio_driver_register(&coreaudio_audio_driver);
+}
+type_init(register_audio_coreaudio);
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index bc39cb9b4d..3ed73a30d1 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -890,7 +890,7 @@ static struct audio_pcm_ops dsound_pcm_ops = {
.ctl_in = dsound_ctl_in
};
-struct audio_driver dsound_audio_driver = {
+static struct audio_driver dsound_audio_driver = {
.name = "dsound",
.descr = "DirectSound http://wikipedia.org/wiki/DirectSound",
.options = dsound_options,
@@ -903,3 +903,9 @@ struct audio_driver dsound_audio_driver = {
.voice_size_out = sizeof (DSoundVoiceOut),
.voice_size_in = sizeof (DSoundVoiceIn)
};
+
+static void register_audio_dsound(void)
+{
+ audio_driver_register(&dsound_audio_driver);
+}
+type_init(register_audio_dsound);
diff --git a/audio/noaudio.c b/audio/noaudio.c
index 9ca9eaf01f..1bfebeca7d 100644
--- a/audio/noaudio.c
+++ b/audio/noaudio.c
@@ -160,7 +160,7 @@ static struct audio_pcm_ops no_pcm_ops = {
.ctl_in = no_ctl_in
};
-struct audio_driver no_audio_driver = {
+static struct audio_driver no_audio_driver = {
.name = "none",
.descr = "Timer based audio emulation",
.options = NULL,
@@ -173,3 +173,9 @@ struct audio_driver no_audio_driver = {
.voice_size_out = sizeof (NoVoiceOut),
.voice_size_in = sizeof (NoVoiceIn)
};
+
+static void register_audio_none(void)
+{
+ audio_driver_register(&no_audio_driver);
+}
+type_init(register_audio_none);
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index a0428881c2..6c69622b4c 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -922,7 +922,7 @@ static struct audio_pcm_ops oss_pcm_ops = {
.ctl_in = oss_ctl_in
};
-struct audio_driver oss_audio_driver = {
+static struct audio_driver oss_audio_driver = {
.name = "oss",
.descr = "OSS http://www.opensound.com",
.options = oss_options,
@@ -935,3 +935,9 @@ struct audio_driver oss_audio_driver = {
.voice_size_out = sizeof (OSSVoiceOut),
.voice_size_in = sizeof (OSSVoiceIn)
};
+
+static void register_audio_oss(void)
+{
+ audio_driver_register(&oss_audio_driver);
+}
+type_init(register_audio_oss);
diff --git a/audio/paaudio.c b/audio/paaudio.c
index aa0a7477d3..949769774d 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -937,7 +937,7 @@ static struct audio_pcm_ops qpa_pcm_ops = {
.ctl_in = qpa_ctl_in
};
-struct audio_driver pa_audio_driver = {
+static struct audio_driver pa_audio_driver = {
.name = "pa",
.descr = "http://www.pulseaudio.org/",
.options = qpa_options,
@@ -951,3 +951,9 @@ struct audio_driver pa_audio_driver = {
.voice_size_in = sizeof (PAVoiceIn),
.ctl_caps = VOICE_VOLUME_CAP
};
+
+static void register_audio_pa(void)
+{
+ audio_driver_register(&pa_audio_driver);
+}
+type_init(register_audio_pa);
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index e92135bd2f..9db5ac92bc 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -500,7 +500,7 @@ static struct audio_pcm_ops sdl_pcm_ops = {
.ctl_out = sdl_ctl_out,
};
-struct audio_driver sdl_audio_driver = {
+static struct audio_driver sdl_audio_driver = {
.name = "sdl",
.descr = "SDL http://www.libsdl.org",
.options = sdl_options,
@@ -513,3 +513,9 @@ struct audio_driver sdl_audio_driver = {
.voice_size_out = sizeof (SDLVoiceOut),
.voice_size_in = 0
};
+
+static void register_audio_sdl(void)
+{
+ audio_driver_register(&sdl_audio_driver);
+}
+type_init(register_audio_sdl);
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index 5580e76307..6ad0eafbc6 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -391,7 +391,7 @@ static struct audio_pcm_ops audio_callbacks = {
.ctl_in = line_in_ctl,
};
-struct audio_driver spice_audio_driver = {
+static struct audio_driver spice_audio_driver = {
.name = "spice",
.descr = "spice audio driver",
.options = audio_options,
@@ -411,3 +411,9 @@ void qemu_spice_audio_init (void)
{
spice_audio_driver.can_be_default = 1;
}
+
+static void register_audio_spice(void)
+{
+ audio_driver_register(&spice_audio_driver);
+}
+type_init(register_audio_spice);
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 068a595732..40adfa30c3 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -278,7 +278,7 @@ static struct audio_pcm_ops wav_pcm_ops = {
.ctl_out = wav_ctl_out,
};
-struct audio_driver wav_audio_driver = {
+static struct audio_driver wav_audio_driver = {
.name = "wav",
.descr = "WAV renderer http://wikipedia.org/wiki/WAV",
.options = wav_options,
@@ -291,3 +291,9 @@ struct audio_driver wav_audio_driver = {
.voice_size_out = sizeof (WAVVoiceOut),
.voice_size_in = 0
};
+
+static void register_audio_wav(void)
+{
+ audio_driver_register(&wav_audio_driver);
+}
+type_init(register_audio_wav);
diff --git a/scripts/create_config b/scripts/create_config
index 603b826886..d727e5e36e 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -36,7 +36,7 @@ case $line in
drivers=${line#*=}
echo "#define CONFIG_AUDIO_DRIVERS \\"
for drv in $drivers; do
- echo " &${drv}_audio_driver,\\"
+ echo " \"${drv}\",\\"
done
echo ""
;;
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 2/7] audio: add module loading support
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 1/7] audio: add driver registry Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 10:59 ` Marc-André Lureau
2018-03-06 7:40 ` [Qemu-devel] [PATCH 3/7] build: enable audio modules Gerd Hoffmann
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Make audio_driver_lookup() try load the module in case it doesn't find
the driver in the registry. Also load all modules for -audio-help, so
the help output includes the help text for modular audio drivers.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/qemu/module.h | 1 +
audio/audio.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 9fea75aaeb..54300ab6e5 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -54,6 +54,7 @@ typedef enum {
#define block_module_load_one(lib) module_load_one("block-", lib)
#define ui_module_load_one(lib) module_load_one("ui-", lib)
+#define audio_module_load_one(lib) module_load_one("audio-", lib)
void register_module_init(void (*fn)(void), module_init_type type);
void register_dso_module_init(void (*fn)(void), module_init_type type);
diff --git a/audio/audio.c b/audio/audio.c
index 2384612b87..6eccdb17ee 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -68,9 +68,26 @@ audio_driver *audio_driver_lookup(const char *name)
return d;
}
}
+
+ audio_module_load_one(name);
+ QLIST_FOREACH(d, &audio_drivers, next) {
+ if (strcmp(name, d->name) == 0) {
+ return d;
+ }
+ }
+
return NULL;
}
+static void audio_module_load_all(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(audio_prio_list); i++) {
+ audio_driver_lookup(audio_prio_list[i]);
+ }
+}
+
struct fixed_settings {
int enabled;
int nb_voices;
@@ -1675,6 +1692,9 @@ void AUD_help (void)
{
struct audio_driver *d;
+ /* make sure we print the help text for modular drivers too */
+ audio_module_load_all();
+
audio_process_options ("AUDIO", audio_options);
QLIST_FOREACH(d, &audio_drivers, next) {
if (d->options) {
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 3/7] build: enable audio modules
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 1/7] audio: add driver registry Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 2/7] audio: add module loading support Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 4/7] audio/alsa: build as module Gerd Hoffmann
` (4 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Add audio/ to common-obj-m variable.
Also run both audio and ui variables through unnest-vars.
This avoids sdl.mo (exists in both audio/ and ui/) name clashes.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
Makefile | 4 ++++
Makefile.objs | 1 +
2 files changed, 5 insertions(+)
diff --git a/Makefile b/Makefile
index 4df1f67fe4..20abbe66ad 100644
--- a/Makefile
+++ b/Makefile
@@ -425,6 +425,10 @@ dummy := $(call unnest-vars,, \
io-obj-y \
common-obj-y \
common-obj-m \
+ ui-obj-y \
+ ui-obj-m \
+ audio-obj-y \
+ audio-obj-m \
trace-obj-y)
include $(SRC_PATH)/tests/Makefile.include
diff --git a/Makefile.objs b/Makefile.objs
index 69413d33b1..ffae665ea9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -104,6 +104,7 @@ common-obj-$(CONFIG_LINUX) += fsdev/
common-obj-y += migration/
common-obj-y += audio/
+common-obj-m += audio/
common-obj-y += hw/
common-obj-y += replay/
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 4/7] audio/alsa: build as module
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
` (2 preceding siblings ...)
2018-03-06 7:40 ` [Qemu-devel] [PATCH 3/7] build: enable audio modules Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 5/7] audio/oss: " Gerd Hoffmann
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
configure | 7 ++++++-
audio/Makefile.objs | 7 +++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 27d3f66bd5..46274301bd 100755
--- a/configure
+++ b/configure
@@ -5982,7 +5982,12 @@ fi
echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
for drv in $audio_drv_list; do
def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
- echo "$def=y" >> $config_host_mak
+ case "$drv" in
+ alsa)
+ echo "$def=m" >> $config_host_mak ;;
+ *)
+ echo "$def=y" >> $config_host_mak ;;
+ esac
done
echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
diff --git a/audio/Makefile.objs b/audio/Makefile.objs
index f6ce5c6744..97f22ec097 100644
--- a/audio/Makefile.objs
+++ b/audio/Makefile.objs
@@ -3,7 +3,6 @@ common-obj-$(CONFIG_AUDIO_SDL) += sdlaudio.o
common-obj-$(CONFIG_AUDIO_OSS) += ossaudio.o
common-obj-$(CONFIG_SPICE) += spiceaudio.o
common-obj-$(CONFIG_AUDIO_COREAUDIO) += coreaudio.o
-common-obj-$(CONFIG_AUDIO_ALSA) += alsaaudio.o
common-obj-$(CONFIG_AUDIO_DSOUND) += dsoundaudio.o
common-obj-$(CONFIG_AUDIO_PA) += paaudio.o
common-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
@@ -12,8 +11,12 @@ common-obj-y += wavcapture.o
sdlaudio.o-cflags := $(SDL_CFLAGS)
sdlaudio.o-libs := $(SDL_LIBS)
-alsaaudio.o-libs := $(ALSA_LIBS)
paaudio.o-libs := $(PULSE_LIBS)
coreaudio.o-libs := $(COREAUDIO_LIBS)
dsoundaudio.o-libs := $(DSOUND_LIBS)
ossaudio.o-libs := $(OSS_LIBS)
+
+# alsa module
+common-obj-$(CONFIG_AUDIO_ALSA) += alsa.mo
+alsa.mo-objs = alsaaudio.o
+alsa.mo-libs := $(ALSA_LIBS)
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 5/7] audio/oss: build as module
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
` (3 preceding siblings ...)
2018-03-06 7:40 ` [Qemu-devel] [PATCH 4/7] audio/alsa: build as module Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 6/7] audio/pulseaudio: " Gerd Hoffmann
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
configure | 2 +-
audio/Makefile.objs | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 46274301bd..5014c900bd 100755
--- a/configure
+++ b/configure
@@ -5983,7 +5983,7 @@ echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
for drv in $audio_drv_list; do
def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
case "$drv" in
- alsa)
+ alsa | oss)
echo "$def=m" >> $config_host_mak ;;
*)
echo "$def=y" >> $config_host_mak ;;
diff --git a/audio/Makefile.objs b/audio/Makefile.objs
index 97f22ec097..9ea19c6a87 100644
--- a/audio/Makefile.objs
+++ b/audio/Makefile.objs
@@ -1,6 +1,5 @@
common-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
common-obj-$(CONFIG_AUDIO_SDL) += sdlaudio.o
-common-obj-$(CONFIG_AUDIO_OSS) += ossaudio.o
common-obj-$(CONFIG_SPICE) += spiceaudio.o
common-obj-$(CONFIG_AUDIO_COREAUDIO) += coreaudio.o
common-obj-$(CONFIG_AUDIO_DSOUND) += dsoundaudio.o
@@ -14,9 +13,13 @@ sdlaudio.o-libs := $(SDL_LIBS)
paaudio.o-libs := $(PULSE_LIBS)
coreaudio.o-libs := $(COREAUDIO_LIBS)
dsoundaudio.o-libs := $(DSOUND_LIBS)
-ossaudio.o-libs := $(OSS_LIBS)
# alsa module
common-obj-$(CONFIG_AUDIO_ALSA) += alsa.mo
alsa.mo-objs = alsaaudio.o
alsa.mo-libs := $(ALSA_LIBS)
+
+# oss module
+common-obj-$(CONFIG_AUDIO_OSS) += oss.mo
+oss.mo-objs = ossaudio.o
+oss.mo-libs := $(OSS_LIBS)
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 6/7] audio/pulseaudio: build as module
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
` (4 preceding siblings ...)
2018-03-06 7:40 ` [Qemu-devel] [PATCH 5/7] audio/oss: " Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 7/7] audio/sdl: " Gerd Hoffmann
2018-03-06 11:22 ` [Qemu-devel] [PATCH 0/7] audio: modularize Marc-André Lureau
7 siblings, 0 replies; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
configure | 2 +-
audio/Makefile.objs | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 5014c900bd..3abee54cfc 100755
--- a/configure
+++ b/configure
@@ -5983,7 +5983,7 @@ echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
for drv in $audio_drv_list; do
def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
case "$drv" in
- alsa | oss)
+ alsa | oss | pa)
echo "$def=m" >> $config_host_mak ;;
*)
echo "$def=y" >> $config_host_mak ;;
diff --git a/audio/Makefile.objs b/audio/Makefile.objs
index 9ea19c6a87..b98835934d 100644
--- a/audio/Makefile.objs
+++ b/audio/Makefile.objs
@@ -3,14 +3,12 @@ common-obj-$(CONFIG_AUDIO_SDL) += sdlaudio.o
common-obj-$(CONFIG_SPICE) += spiceaudio.o
common-obj-$(CONFIG_AUDIO_COREAUDIO) += coreaudio.o
common-obj-$(CONFIG_AUDIO_DSOUND) += dsoundaudio.o
-common-obj-$(CONFIG_AUDIO_PA) += paaudio.o
common-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
common-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
common-obj-y += wavcapture.o
sdlaudio.o-cflags := $(SDL_CFLAGS)
sdlaudio.o-libs := $(SDL_LIBS)
-paaudio.o-libs := $(PULSE_LIBS)
coreaudio.o-libs := $(COREAUDIO_LIBS)
dsoundaudio.o-libs := $(DSOUND_LIBS)
@@ -23,3 +21,8 @@ alsa.mo-libs := $(ALSA_LIBS)
common-obj-$(CONFIG_AUDIO_OSS) += oss.mo
oss.mo-objs = ossaudio.o
oss.mo-libs := $(OSS_LIBS)
+
+# pulseaudio module
+common-obj-$(CONFIG_AUDIO_PA) += pa.mo
+pa.mo-objs = paaudio.o
+pa.mo-libs := $(PULSE_LIBS)
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 7/7] audio/sdl: build as module
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
` (5 preceding siblings ...)
2018-03-06 7:40 ` [Qemu-devel] [PATCH 6/7] audio/pulseaudio: " Gerd Hoffmann
@ 2018-03-06 7:40 ` Gerd Hoffmann
2018-03-06 11:22 ` [Qemu-devel] [PATCH 0/7] audio: modularize Marc-André Lureau
7 siblings, 0 replies; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 7:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
configure | 2 +-
audio/Makefile.objs | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/configure b/configure
index 3abee54cfc..b1930cd828 100755
--- a/configure
+++ b/configure
@@ -5983,7 +5983,7 @@ echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
for drv in $audio_drv_list; do
def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
case "$drv" in
- alsa | oss | pa)
+ alsa | oss | pa | sdl)
echo "$def=m" >> $config_host_mak ;;
*)
echo "$def=y" >> $config_host_mak ;;
diff --git a/audio/Makefile.objs b/audio/Makefile.objs
index b98835934d..db4fa7f18f 100644
--- a/audio/Makefile.objs
+++ b/audio/Makefile.objs
@@ -1,5 +1,4 @@
common-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
-common-obj-$(CONFIG_AUDIO_SDL) += sdlaudio.o
common-obj-$(CONFIG_SPICE) += spiceaudio.o
common-obj-$(CONFIG_AUDIO_COREAUDIO) += coreaudio.o
common-obj-$(CONFIG_AUDIO_DSOUND) += dsoundaudio.o
@@ -7,8 +6,6 @@ common-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
common-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
common-obj-y += wavcapture.o
-sdlaudio.o-cflags := $(SDL_CFLAGS)
-sdlaudio.o-libs := $(SDL_LIBS)
coreaudio.o-libs := $(COREAUDIO_LIBS)
dsoundaudio.o-libs := $(DSOUND_LIBS)
@@ -26,3 +23,9 @@ oss.mo-libs := $(OSS_LIBS)
common-obj-$(CONFIG_AUDIO_PA) += pa.mo
pa.mo-objs = paaudio.o
pa.mo-libs := $(PULSE_LIBS)
+
+# sdl module
+common-obj-$(CONFIG_AUDIO_SDL) += sdl.mo
+sdl.mo-objs = sdlaudio.o
+sdl.mo-cflags := $(SDL_CFLAGS)
+sdl.mo-libs := $(SDL_LIBS)
--
2.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 1/7] audio: add driver registry
2018-03-06 7:40 ` [Qemu-devel] [PATCH 1/7] audio: add driver registry Gerd Hoffmann
@ 2018-03-06 10:58 ` Marc-André Lureau
0 siblings, 0 replies; 15+ messages in thread
From: Marc-André Lureau @ 2018-03-06 10:58 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU
On Tue, Mar 6, 2018 at 8:40 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Add registry for audio drivers, using the existing audio_driver struct.
> Make all drivers register themself. The old list of audio_driver struct
> pointers is now a list of audio driver names, specifying the priority
> (aka probe order) in case no driver is explicitly asked for.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> audio/audio_int.h | 14 ++++--------
> audio/alsaaudio.c | 8 ++++++-
> audio/audio.c | 63 ++++++++++++++++++++++++++++++---------------------
> audio/coreaudio.c | 8 ++++++-
> audio/dsoundaudio.c | 8 ++++++-
> audio/noaudio.c | 8 ++++++-
> audio/ossaudio.c | 8 ++++++-
> audio/paaudio.c | 8 ++++++-
> audio/sdlaudio.c | 8 ++++++-
> audio/spiceaudio.c | 8 ++++++-
> audio/wavaudio.c | 8 ++++++-
> scripts/create_config | 2 +-
> 12 files changed, 106 insertions(+), 45 deletions(-)
>
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index 700bd43143..244b454012 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -141,6 +141,7 @@ struct SWVoiceIn {
> QLIST_ENTRY (SWVoiceIn) entries;
> };
>
> +typedef struct audio_driver audio_driver;
> struct audio_driver {
> const char *name;
> const char *descr;
> @@ -154,6 +155,7 @@ struct audio_driver {
> int voice_size_out;
> int voice_size_in;
> int ctl_caps;
> + QLIST_ENTRY(audio_driver) next;
> };
>
> struct audio_pcm_ops {
> @@ -203,17 +205,11 @@ struct AudioState {
> int vm_running;
> };
>
> -extern struct audio_driver no_audio_driver;
> -extern struct audio_driver oss_audio_driver;
> -extern struct audio_driver sdl_audio_driver;
> -extern struct audio_driver wav_audio_driver;
> -extern struct audio_driver alsa_audio_driver;
> -extern struct audio_driver coreaudio_audio_driver;
> -extern struct audio_driver dsound_audio_driver;
> -extern struct audio_driver pa_audio_driver;
> -extern struct audio_driver spice_audio_driver;
> extern const struct mixeng_volume nominal_volume;
>
> +void audio_driver_register(audio_driver *drv);
> +audio_driver *audio_driver_lookup(const char *name);
> +
> void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
> void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
>
> diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
> index 92a96f8b2b..362a2276fd 100644
> --- a/audio/alsaaudio.c
> +++ b/audio/alsaaudio.c
> @@ -1213,7 +1213,7 @@ static struct audio_pcm_ops alsa_pcm_ops = {
> .ctl_in = alsa_ctl_in,
> };
>
> -struct audio_driver alsa_audio_driver = {
> +static struct audio_driver alsa_audio_driver = {
> .name = "alsa",
> .descr = "ALSA http://www.alsa-project.org",
> .options = alsa_options,
> @@ -1226,3 +1226,9 @@ struct audio_driver alsa_audio_driver = {
> .voice_size_out = sizeof (ALSAVoiceOut),
> .voice_size_in = sizeof (ALSAVoiceIn)
> };
> +
> +static void register_audio_alsa(void)
> +{
> + audio_driver_register(&alsa_audio_driver);
> +}
> +type_init(register_audio_alsa);
> diff --git a/audio/audio.c b/audio/audio.c
> index 7658d2af66..2384612b87 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -45,15 +45,32 @@
> The 1st one is the one used by default, that is the reason
> that we generate the list.
> */
> -static struct audio_driver *drvtab[] = {
> -#ifdef CONFIG_SPICE
> - &spice_audio_driver,
> -#endif
> +static const char *audio_prio_list[] = {
> + "spice",
> CONFIG_AUDIO_DRIVERS
> - &no_audio_driver,
> - &wav_audio_driver
> + "none",
> + "wav",
> };
>
> +static QLIST_HEAD(, audio_driver) audio_drivers;
> +
> +void audio_driver_register(audio_driver *drv)
> +{
> + QLIST_INSERT_HEAD(&audio_drivers, drv, next);
> +}
> +
> +audio_driver *audio_driver_lookup(const char *name)
> +{
> + struct audio_driver *d;
> +
> + QLIST_FOREACH(d, &audio_drivers, next) {
> + if (strcmp(name, d->name) == 0) {
> + return d;
> + }
> + }
> + return NULL;
> +}
> +
> struct fixed_settings {
> int enabled;
> int nb_voices;
> @@ -1656,11 +1673,10 @@ static void audio_pp_nb_voices (const char *typ, int nb)
>
> void AUD_help (void)
> {
> - size_t i;
> + struct audio_driver *d;
>
> audio_process_options ("AUDIO", audio_options);
> - for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
> - struct audio_driver *d = drvtab[i];
> + QLIST_FOREACH(d, &audio_drivers, next) {
> if (d->options) {
> audio_process_options (d->name, d->options);
> }
> @@ -1672,8 +1688,7 @@ void AUD_help (void)
>
> printf ("Available drivers:\n");
>
> - for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
> - struct audio_driver *d = drvtab[i];
> + QLIST_FOREACH(d, &audio_drivers, next) {
>
> printf ("Name: %s\n", d->name);
> printf ("Description: %s\n", d->descr);
> @@ -1807,6 +1822,7 @@ static void audio_init (void)
> const char *drvname;
> VMChangeStateEntry *e;
> AudioState *s = &glob_audio_state;
> + struct audio_driver *driver;
>
> if (s->drv) {
> return;
> @@ -1842,32 +1858,27 @@ static void audio_init (void)
> }
>
> if (drvname) {
> - int found = 0;
> -
> - for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
> - if (!strcmp (drvname, drvtab[i]->name)) {
> - done = !audio_driver_init (s, drvtab[i]);
> - found = 1;
> - break;
> - }
> - }
> -
> - if (!found) {
> + driver = audio_driver_lookup(drvname);
> + if (driver) {
> + done = !audio_driver_init(s, driver);
> + } else {
> dolog ("Unknown audio driver `%s'\n", drvname);
> dolog ("Run with -audio-help to list available drivers\n");
> }
> }
>
> if (!done) {
> - for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) {
> - if (drvtab[i]->can_be_default) {
> - done = !audio_driver_init (s, drvtab[i]);
> + for (i = 0; !done && i < ARRAY_SIZE(audio_prio_list); i++) {
> + driver = audio_driver_lookup(audio_prio_list[i]);
> + if (driver && driver->can_be_default) {
> + done = !audio_driver_init(s, driver);
> }
> }
> }
>
> if (!done) {
> - done = !audio_driver_init (s, &no_audio_driver);
> + driver = audio_driver_lookup("none");
> + done = !audio_driver_init(s, driver);
> assert(done);
> dolog("warning: Using timer based audio emulation\n");
> }
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index c75142084f..638c60b300 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -722,7 +722,7 @@ static struct audio_pcm_ops coreaudio_pcm_ops = {
> .ctl_out = coreaudio_ctl_out
> };
>
> -struct audio_driver coreaudio_audio_driver = {
> +static struct audio_driver coreaudio_audio_driver = {
> .name = "coreaudio",
> .descr = "CoreAudio http://developer.apple.com/audio/coreaudio.html",
> .options = coreaudio_options,
> @@ -735,3 +735,9 @@ struct audio_driver coreaudio_audio_driver = {
> .voice_size_out = sizeof (coreaudioVoiceOut),
> .voice_size_in = 0
> };
> +
> +static void register_audio_coreaudio(void)
> +{
> + audio_driver_register(&coreaudio_audio_driver);
> +}
> +type_init(register_audio_coreaudio);
> diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
> index bc39cb9b4d..3ed73a30d1 100644
> --- a/audio/dsoundaudio.c
> +++ b/audio/dsoundaudio.c
> @@ -890,7 +890,7 @@ static struct audio_pcm_ops dsound_pcm_ops = {
> .ctl_in = dsound_ctl_in
> };
>
> -struct audio_driver dsound_audio_driver = {
> +static struct audio_driver dsound_audio_driver = {
> .name = "dsound",
> .descr = "DirectSound http://wikipedia.org/wiki/DirectSound",
> .options = dsound_options,
> @@ -903,3 +903,9 @@ struct audio_driver dsound_audio_driver = {
> .voice_size_out = sizeof (DSoundVoiceOut),
> .voice_size_in = sizeof (DSoundVoiceIn)
> };
> +
> +static void register_audio_dsound(void)
> +{
> + audio_driver_register(&dsound_audio_driver);
> +}
> +type_init(register_audio_dsound);
> diff --git a/audio/noaudio.c b/audio/noaudio.c
> index 9ca9eaf01f..1bfebeca7d 100644
> --- a/audio/noaudio.c
> +++ b/audio/noaudio.c
> @@ -160,7 +160,7 @@ static struct audio_pcm_ops no_pcm_ops = {
> .ctl_in = no_ctl_in
> };
>
> -struct audio_driver no_audio_driver = {
> +static struct audio_driver no_audio_driver = {
> .name = "none",
> .descr = "Timer based audio emulation",
> .options = NULL,
> @@ -173,3 +173,9 @@ struct audio_driver no_audio_driver = {
> .voice_size_out = sizeof (NoVoiceOut),
> .voice_size_in = sizeof (NoVoiceIn)
> };
> +
> +static void register_audio_none(void)
> +{
> + audio_driver_register(&no_audio_driver);
> +}
> +type_init(register_audio_none);
> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
> index a0428881c2..6c69622b4c 100644
> --- a/audio/ossaudio.c
> +++ b/audio/ossaudio.c
> @@ -922,7 +922,7 @@ static struct audio_pcm_ops oss_pcm_ops = {
> .ctl_in = oss_ctl_in
> };
>
> -struct audio_driver oss_audio_driver = {
> +static struct audio_driver oss_audio_driver = {
> .name = "oss",
> .descr = "OSS http://www.opensound.com",
> .options = oss_options,
> @@ -935,3 +935,9 @@ struct audio_driver oss_audio_driver = {
> .voice_size_out = sizeof (OSSVoiceOut),
> .voice_size_in = sizeof (OSSVoiceIn)
> };
> +
> +static void register_audio_oss(void)
> +{
> + audio_driver_register(&oss_audio_driver);
> +}
> +type_init(register_audio_oss);
> diff --git a/audio/paaudio.c b/audio/paaudio.c
> index aa0a7477d3..949769774d 100644
> --- a/audio/paaudio.c
> +++ b/audio/paaudio.c
> @@ -937,7 +937,7 @@ static struct audio_pcm_ops qpa_pcm_ops = {
> .ctl_in = qpa_ctl_in
> };
>
> -struct audio_driver pa_audio_driver = {
> +static struct audio_driver pa_audio_driver = {
> .name = "pa",
> .descr = "http://www.pulseaudio.org/",
> .options = qpa_options,
> @@ -951,3 +951,9 @@ struct audio_driver pa_audio_driver = {
> .voice_size_in = sizeof (PAVoiceIn),
> .ctl_caps = VOICE_VOLUME_CAP
> };
> +
> +static void register_audio_pa(void)
> +{
> + audio_driver_register(&pa_audio_driver);
> +}
> +type_init(register_audio_pa);
> diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
> index e92135bd2f..9db5ac92bc 100644
> --- a/audio/sdlaudio.c
> +++ b/audio/sdlaudio.c
> @@ -500,7 +500,7 @@ static struct audio_pcm_ops sdl_pcm_ops = {
> .ctl_out = sdl_ctl_out,
> };
>
> -struct audio_driver sdl_audio_driver = {
> +static struct audio_driver sdl_audio_driver = {
> .name = "sdl",
> .descr = "SDL http://www.libsdl.org",
> .options = sdl_options,
> @@ -513,3 +513,9 @@ struct audio_driver sdl_audio_driver = {
> .voice_size_out = sizeof (SDLVoiceOut),
> .voice_size_in = 0
> };
> +
> +static void register_audio_sdl(void)
> +{
> + audio_driver_register(&sdl_audio_driver);
> +}
> +type_init(register_audio_sdl);
> diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
> index 5580e76307..6ad0eafbc6 100644
> --- a/audio/spiceaudio.c
> +++ b/audio/spiceaudio.c
> @@ -391,7 +391,7 @@ static struct audio_pcm_ops audio_callbacks = {
> .ctl_in = line_in_ctl,
> };
>
> -struct audio_driver spice_audio_driver = {
> +static struct audio_driver spice_audio_driver = {
> .name = "spice",
> .descr = "spice audio driver",
> .options = audio_options,
> @@ -411,3 +411,9 @@ void qemu_spice_audio_init (void)
> {
> spice_audio_driver.can_be_default = 1;
> }
> +
> +static void register_audio_spice(void)
> +{
> + audio_driver_register(&spice_audio_driver);
> +}
> +type_init(register_audio_spice);
> diff --git a/audio/wavaudio.c b/audio/wavaudio.c
> index 068a595732..40adfa30c3 100644
> --- a/audio/wavaudio.c
> +++ b/audio/wavaudio.c
> @@ -278,7 +278,7 @@ static struct audio_pcm_ops wav_pcm_ops = {
> .ctl_out = wav_ctl_out,
> };
>
> -struct audio_driver wav_audio_driver = {
> +static struct audio_driver wav_audio_driver = {
> .name = "wav",
> .descr = "WAV renderer http://wikipedia.org/wiki/WAV",
> .options = wav_options,
> @@ -291,3 +291,9 @@ struct audio_driver wav_audio_driver = {
> .voice_size_out = sizeof (WAVVoiceOut),
> .voice_size_in = 0
> };
> +
> +static void register_audio_wav(void)
> +{
> + audio_driver_register(&wav_audio_driver);
> +}
> +type_init(register_audio_wav);
> diff --git a/scripts/create_config b/scripts/create_config
> index 603b826886..d727e5e36e 100755
> --- a/scripts/create_config
> +++ b/scripts/create_config
> @@ -36,7 +36,7 @@ case $line in
> drivers=${line#*=}
> echo "#define CONFIG_AUDIO_DRIVERS \\"
> for drv in $drivers; do
> - echo " &${drv}_audio_driver,\\"
> + echo " \"${drv}\",\\"
> done
> echo ""
> ;;
> --
> 2.9.3
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] audio: add module loading support
2018-03-06 7:40 ` [Qemu-devel] [PATCH 2/7] audio: add module loading support Gerd Hoffmann
@ 2018-03-06 10:59 ` Marc-André Lureau
0 siblings, 0 replies; 15+ messages in thread
From: Marc-André Lureau @ 2018-03-06 10:59 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU
On Tue, Mar 6, 2018 at 8:40 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Make audio_driver_lookup() try load the module in case it doesn't find
> the driver in the registry. Also load all modules for -audio-help, so
> the help output includes the help text for modular audio drivers.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/qemu/module.h | 1 +
> audio/audio.c | 20 ++++++++++++++++++++
> 2 files changed, 21 insertions(+)
>
> diff --git a/include/qemu/module.h b/include/qemu/module.h
> index 9fea75aaeb..54300ab6e5 100644
> --- a/include/qemu/module.h
> +++ b/include/qemu/module.h
> @@ -54,6 +54,7 @@ typedef enum {
>
> #define block_module_load_one(lib) module_load_one("block-", lib)
> #define ui_module_load_one(lib) module_load_one("ui-", lib)
> +#define audio_module_load_one(lib) module_load_one("audio-", lib)
>
> void register_module_init(void (*fn)(void), module_init_type type);
> void register_dso_module_init(void (*fn)(void), module_init_type type);
> diff --git a/audio/audio.c b/audio/audio.c
> index 2384612b87..6eccdb17ee 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -68,9 +68,26 @@ audio_driver *audio_driver_lookup(const char *name)
> return d;
> }
> }
> +
> + audio_module_load_one(name);
> + QLIST_FOREACH(d, &audio_drivers, next) {
> + if (strcmp(name, d->name) == 0) {
> + return d;
> + }
> + }
> +
> return NULL;
> }
>
> +static void audio_module_load_all(void)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(audio_prio_list); i++) {
> + audio_driver_lookup(audio_prio_list[i]);
> + }
> +}
> +
> struct fixed_settings {
> int enabled;
> int nb_voices;
> @@ -1675,6 +1692,9 @@ void AUD_help (void)
> {
> struct audio_driver *d;
>
> + /* make sure we print the help text for modular drivers too */
> + audio_module_load_all();
> +
> audio_process_options ("AUDIO", audio_options);
> QLIST_FOREACH(d, &audio_drivers, next) {
> if (d->options) {
> --
> 2.9.3
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] audio: modularize
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
` (6 preceding siblings ...)
2018-03-06 7:40 ` [Qemu-devel] [PATCH 7/7] audio/sdl: " Gerd Hoffmann
@ 2018-03-06 11:22 ` Marc-André Lureau
2018-03-06 11:42 ` Gerd Hoffmann
7 siblings, 1 reply; 15+ messages in thread
From: Marc-André Lureau @ 2018-03-06 11:22 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU
Hi
On Tue, Mar 6, 2018 at 8:40 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Add audio driver (host backend) registry. Add audio module support.
> Enable module builds for alsa, oss, pulse and sdl.
>
> Gerd Hoffmann (7):
> audio: add driver registry
> audio: add module loading support
> build: enable audio modules
> audio/alsa: build as module
> audio/oss: build as module
> audio/pulseaudio: build as module
> audio/sdl: build as module
>
Is this a problem on my side? (configure
'--audio-drv-list=oss,alsa,pa,sdl' '--enable-modules')
elmarco@boraha:~/src/qemu/build (master %)$
x86_64-softmmu/qemu-system-x86_64 -audio-help
Failed to open module:
/home/elmarco/src/qemu/build/x86_64-softmmu/../audio-oss.so: undefined
symbol: _TRACE_OSS_INVALID_AVAILABLE_SIZE_DSTATE
Failed to open module:
/home/elmarco/src/qemu/build/x86_64-softmmu/../audio-alsa.so:
undefined symbol: _TRACE_ALSA_XRUN_OUT_DSTATE
Failed to open module:
/home/elmarco/src/qemu/build/x86_64-softmmu/../audio-pa.so: undefined
symbol: audio_pt_unlock_and_signal
Failed to open module:
/home/elmarco/src/qemu/build/x86_64-softmmu/../audio-sdl.so: undefined
symbol: audio_pcm_sw_write
> configure | 7 ++++-
> Makefile | 4 +++
> Makefile.objs | 1 +
> audio/audio_int.h | 14 ++++-----
> include/qemu/module.h | 1 +
> audio/alsaaudio.c | 8 ++++-
> audio/audio.c | 83 +++++++++++++++++++++++++++++++++++----------------
> audio/coreaudio.c | 8 ++++-
> audio/dsoundaudio.c | 8 ++++-
> audio/noaudio.c | 8 ++++-
> audio/ossaudio.c | 8 ++++-
> audio/paaudio.c | 8 ++++-
> audio/sdlaudio.c | 8 ++++-
> audio/spiceaudio.c | 8 ++++-
> audio/wavaudio.c | 8 ++++-
> audio/Makefile.objs | 30 +++++++++++++------
> scripts/create_config | 2 +-
> 17 files changed, 159 insertions(+), 55 deletions(-)
>
> --
> 2.9.3
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] audio: modularize
2018-03-06 11:22 ` [Qemu-devel] [PATCH 0/7] audio: modularize Marc-André Lureau
@ 2018-03-06 11:42 ` Gerd Hoffmann
2018-03-06 12:43 ` Marc-André Lureau
0 siblings, 1 reply; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 11:42 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: QEMU
On Tue, Mar 06, 2018 at 12:22:49PM +0100, Marc-André Lureau wrote:
> Hi
>
> On Tue, Mar 6, 2018 at 8:40 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> > Add audio driver (host backend) registry. Add audio module support.
> > Enable module builds for alsa, oss, pulse and sdl.
> >
> > Gerd Hoffmann (7):
> > audio: add driver registry
> > audio: add module loading support
> > build: enable audio modules
> > audio/alsa: build as module
> > audio/oss: build as module
> > audio/pulseaudio: build as module
> > audio/sdl: build as module
> >
>
> Is this a problem on my side? (configure
> '--audio-drv-list=oss,alsa,pa,sdl' '--enable-modules')
>
> elmarco@boraha:~/src/qemu/build (master %)$
> x86_64-softmmu/qemu-system-x86_64 -audio-help
> Failed to open module:
> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-oss.so: undefined
> symbol: _TRACE_OSS_INVALID_AVAILABLE_SIZE_DSTATE
> Failed to open module:
> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-alsa.so:
> undefined symbol: _TRACE_ALSA_XRUN_OUT_DSTATE
> Failed to open module:
> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-pa.so: undefined
> symbol: audio_pt_unlock_and_signal
> Failed to open module:
> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-sdl.so: undefined
> symbol: audio_pcm_sw_write
Works fine here. Tried "make clean && make"?
Qemu build system seems to not rebuild object files when the compiler
flags change. So you can't switch between --enable-modules and
--disable-modules without "make clean" inbetween. Same issue when
patches switch code from compiled-in to modular and you try an
incremental build.
I've seen only build failues due to this, not module load errors. But
possibly only because I stopped doing incremental builds when working on
module patches ...
cheers,
Gerd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] audio: modularize
2018-03-06 11:42 ` Gerd Hoffmann
@ 2018-03-06 12:43 ` Marc-André Lureau
2018-03-06 13:27 ` Gerd Hoffmann
0 siblings, 1 reply; 15+ messages in thread
From: Marc-André Lureau @ 2018-03-06 12:43 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU
Hi
On Tue, Mar 6, 2018 at 12:42 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Tue, Mar 06, 2018 at 12:22:49PM +0100, Marc-André Lureau wrote:
>> Hi
>>
>> On Tue, Mar 6, 2018 at 8:40 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
>> > Add audio driver (host backend) registry. Add audio module support.
>> > Enable module builds for alsa, oss, pulse and sdl.
>> >
>> > Gerd Hoffmann (7):
>> > audio: add driver registry
>> > audio: add module loading support
>> > build: enable audio modules
>> > audio/alsa: build as module
>> > audio/oss: build as module
>> > audio/pulseaudio: build as module
>> > audio/sdl: build as module
>> >
>>
>> Is this a problem on my side? (configure
>> '--audio-drv-list=oss,alsa,pa,sdl' '--enable-modules')
>>
>> elmarco@boraha:~/src/qemu/build (master %)$
>> x86_64-softmmu/qemu-system-x86_64 -audio-help
>> Failed to open module:
>> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-oss.so: undefined
>> symbol: _TRACE_OSS_INVALID_AVAILABLE_SIZE_DSTATE
>> Failed to open module:
>> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-alsa.so:
>> undefined symbol: _TRACE_ALSA_XRUN_OUT_DSTATE
>> Failed to open module:
>> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-pa.so: undefined
>> symbol: audio_pt_unlock_and_signal
>> Failed to open module:
>> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-sdl.so: undefined
>> symbol: audio_pcm_sw_write
>
> Works fine here. Tried "make clean && make"?
>
> Qemu build system seems to not rebuild object files when the compiler
> flags change. So you can't switch between --enable-modules and
> --disable-modules without "make clean" inbetween. Same issue when
> patches switch code from compiled-in to modular and you try an
> incremental build.
Fresh directory, cleaned ccache. That didn't help. fwiw, I am
compiling on f27, gcc (GCC) 7.3.1 20180130. I'll investigate further
if you can't reproduce.
> I've seen only build failues due to this, not module load errors. But
> possibly only because I stopped doing incremental builds when working on
> module patches ...
>
> cheers,
> Gerd
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] audio: modularize
2018-03-06 12:43 ` Marc-André Lureau
@ 2018-03-06 13:27 ` Gerd Hoffmann
2018-03-06 15:28 ` Marc-André Lureau
0 siblings, 1 reply; 15+ messages in thread
From: Gerd Hoffmann @ 2018-03-06 13:27 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: QEMU
> >> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-pa.so: undefined
> >> symbol: audio_pt_unlock_and_signal
> Fresh directory, cleaned ccache. That didn't help. fwiw, I am
> compiling on f27, gcc (GCC) 7.3.1 20180130. I'll investigate further
> if you can't reproduce.
Hmm, working fine here (both rhel-7 and fedora-27 testbuild container, default
build flags).
The symbol in question should be provided by qemu:
kraxel@fedora-64bit ~/projects/qemu/build/fedora# objdump -x audio-pa.so | grep audio_pt_unlock_and_signal
0000000000000000 *UND* 0000000000000000 audio_pt_unlock_and_signal
kraxel@fedora-64bit ~/projects/qemu/build/fedora# objdump -x x86_64-softmmu/qemu-system-x86_64 | grep audio_pt_unlock_and_signal
00000000004735f0 g F .text 0000000000000067 audio_pt_unlock_and_signal
Possibly your linker throws it away, thinking there is no user because of the
modular drivers?
cheers,
Gerd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] audio: modularize
2018-03-06 13:27 ` Gerd Hoffmann
@ 2018-03-06 15:28 ` Marc-André Lureau
0 siblings, 0 replies; 15+ messages in thread
From: Marc-André Lureau @ 2018-03-06 15:28 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU
Hi
On Tue, Mar 6, 2018 at 2:27 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
>> >> /home/elmarco/src/qemu/build/x86_64-softmmu/../audio-pa.so: undefined
>> >> symbol: audio_pt_unlock_and_signal
>
>> Fresh directory, cleaned ccache. That didn't help. fwiw, I am
>> compiling on f27, gcc (GCC) 7.3.1 20180130. I'll investigate further
>> if you can't reproduce.
>
> Hmm, working fine here (both rhel-7 and fedora-27 testbuild container, default
> build flags).
>
> The symbol in question should be provided by qemu:
>
> kraxel@fedora-64bit ~/projects/qemu/build/fedora# objdump -x audio-pa.so | grep audio_pt_unlock_and_signal
> 0000000000000000 *UND* 0000000000000000 audio_pt_unlock_and_signal
> kraxel@fedora-64bit ~/projects/qemu/build/fedora# objdump -x x86_64-softmmu/qemu-system-x86_64 | grep audio_pt_unlock_and_signal
> 00000000004735f0 g F .text 0000000000000067 audio_pt_unlock_and_signal
>
> Possibly your linker throws it away, thinking there is no user because of the
> modular drivers?
It's not that, but it works if I build qemu with -rdynamic. dlopen(3):
External references in the shared object are resolved using the
shared objects in that object's dependency list and any other objects
previously opened with the RTLD_GLOBAL flag. If the executable
was linked with the flag "-rdynamic" (or, synonymously,
"--export-dynamic"), then the global symbols in the executable will
also be used to resolve references in a dynamically loaded shared
object.
(If I understand right, there is some magic rules.mk
process-archive-undefs to make sure the used symbols from modules are
always linked in)
Could it be that -rdynamic / --export-dynamic is assumed in our build
system since modules have been added?
yes, it's pulled from /usr/lib64/pkgconfig/gmodule-2.0.pc, but glib
upstream built with meson doesn't have the flag anymore. That's
probably worth fixing in glib:
https://bugzilla.gnome.org/show_bug.cgi?id=794123
We should switch to using gmodule-export-2.0.pc (since 2.6), which is
also broken in meson build. I'll send a patch for that.
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2018-03-06 15:29 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-06 7:40 [Qemu-devel] [PATCH 0/7] audio: modularize Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 1/7] audio: add driver registry Gerd Hoffmann
2018-03-06 10:58 ` Marc-André Lureau
2018-03-06 7:40 ` [Qemu-devel] [PATCH 2/7] audio: add module loading support Gerd Hoffmann
2018-03-06 10:59 ` Marc-André Lureau
2018-03-06 7:40 ` [Qemu-devel] [PATCH 3/7] build: enable audio modules Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 4/7] audio/alsa: build as module Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 5/7] audio/oss: " Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 6/7] audio/pulseaudio: " Gerd Hoffmann
2018-03-06 7:40 ` [Qemu-devel] [PATCH 7/7] audio/sdl: " Gerd Hoffmann
2018-03-06 11:22 ` [Qemu-devel] [PATCH 0/7] audio: modularize Marc-André Lureau
2018-03-06 11:42 ` Gerd Hoffmann
2018-03-06 12:43 ` Marc-André Lureau
2018-03-06 13:27 ` Gerd Hoffmann
2018-03-06 15:28 ` Marc-André Lureau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).