Commit 6ceb1b51 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/kraxel/tags/audio-20180312-pull-request' into staging



modules: use gmodule-export.
audio: add driver registry, enable module builds.

# gpg: Signature made Mon 12 Mar 2018 10:42:19 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/audio-20180312-pull-request:
  audio/sdl: build as module
  audio/pulseaudio: build as module
  audio/oss: build as module
  audio/alsa: build as module
  build: enable audio modules
  audio: add module loading support
  audio: add driver registry
  modules: use gmodule-export

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents b16a54da 051c7d5c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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/
+21 −9
Original line number Diff line number Diff line
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_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
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)
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)

# oss module
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)

# sdl module
common-obj-$(CONFIG_AUDIO_SDL) += sdl.mo
sdl.mo-objs = sdlaudio.o
sdl.mo-cflags := $(SDL_CFLAGS)
sdl.mo-libs := $(SDL_LIBS)
+7 −1
Original line number Diff line number Diff line
@@ -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);
+57 −26
Original line number Diff line number Diff line
@@ -45,15 +45,49 @@
   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;
        }
    }

    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;
@@ -1656,11 +1690,13 @@ static void audio_pp_nb_voices (const char *typ, int nb)

void AUD_help (void)
{
    size_t i;
    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);
    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 +1708,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 +1842,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 +1878,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");
    }
Loading