audio: add module loading support
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 6 Mar 2018 07:40:48 +0000 (08:40 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 12 Mar 2018 10:18:26 +0000 (11:18 +0100)
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>
Message-id: 20180306074053.22856-3-kraxel@redhat.com

audio/audio.c
include/qemu/module.h

index 2384612b8793a4d5a7dd632eb24936d770831062..6eccdb17eebbc10531907b00d4e3fd61faf20504 100644 (file)
@@ -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) {
index 9fea75aaebdec98e15ea16d8a84cb5a25e4682c9..54300ab6e56e1593843c03f2bfcec882e0059c59 100644 (file)
@@ -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);