aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-01-25 10:38:03 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-01-25 10:38:03 +0000
commit87f6a866f12b8ca037b0a5cfc2dc9b8db9e67696 (patch)
tree7764c24d029debcf6522c78d46ad6dca06eeb9cc
parent7d8df3272dfb2021380c5f1392c7508a111318d3 (diff)
parent6a48541873f14b597630283f8f5397674ad82ea9 (diff)
downloadqemu-87f6a866f12b8ca037b0a5cfc2dc9b8db9e67696.zip
qemu-87f6a866f12b8ca037b0a5cfc2dc9b8db9e67696.tar.gz
qemu-87f6a866f12b8ca037b0a5cfc2dc9b8db9e67696.tar.bz2
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20190124-pull-request' into staging
audio: pc speaker init fix, rework driver probing # gpg: Signature made Thu 24 Jan 2019 13:19:52 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-20190124-pull-request: audio: probe audio drivers by default audio: error message tweak audio: check for pulseaudio daemon pidfile audio: use try-sdl for openbsd audio: allow optional audio drivers. audio: use pkg-config audio: fix pc speaker init Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--audio/audio.c12
-rw-r--r--audio/paaudio.c15
-rwxr-xr-xconfigure81
-rw-r--r--hw/audio/pcspk.c35
4 files changed, 82 insertions, 61 deletions
diff --git a/audio/audio.c b/audio/audio.c
index 1ace47f..d163ffb 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1762,7 +1762,7 @@ void AUD_help (void)
);
}
-static int audio_driver_init (AudioState *s, struct audio_driver *drv)
+static int audio_driver_init(AudioState *s, struct audio_driver *drv, bool msg)
{
if (drv->options) {
audio_process_options (drv->name, drv->options);
@@ -1776,7 +1776,9 @@ static int audio_driver_init (AudioState *s, struct audio_driver *drv)
return 0;
}
else {
- dolog ("Could not init `%s' audio driver\n", drv->name);
+ if (msg) {
+ dolog("Could not init `%s' audio driver\n", drv->name);
+ }
return -1;
}
}
@@ -1901,7 +1903,7 @@ static void audio_init (void)
if (drvname) {
driver = audio_driver_lookup(drvname);
if (driver) {
- done = !audio_driver_init(s, driver);
+ done = !audio_driver_init(s, driver, true);
} else {
dolog ("Unknown audio driver `%s'\n", drvname);
dolog ("Run with -audio-help to list available drivers\n");
@@ -1912,14 +1914,14 @@ static void audio_init (void)
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);
+ done = !audio_driver_init(s, driver, false);
}
}
}
if (!done) {
driver = audio_driver_lookup("none");
- done = !audio_driver_init(s, driver);
+ done = !audio_driver_init(s, driver, false);
assert(done);
dolog("warning: Using timer based audio emulation\n");
}
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 4c100bc..6153b90 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -814,6 +814,21 @@ static PAConf glob_conf = {
static void *qpa_audio_init (void)
{
+ if (glob_conf.server == NULL) {
+ char pidfile[64];
+ char *runtime;
+ struct stat st;
+
+ runtime = getenv("XDG_RUNTIME_DIR");
+ if (!runtime) {
+ return NULL;
+ }
+ snprintf(pidfile, sizeof(pidfile), "%s/pulse/pid", runtime);
+ if (stat(pidfile, &st) != 0) {
+ return NULL;
+ }
+ }
+
paaudio *g = g_malloc(sizeof(paaudio));
g->conf = glob_conf;
g->mainloop = NULL;
diff --git a/configure b/configure
index 8f312ac..b18281c 100755
--- a/configure
+++ b/configure
@@ -794,13 +794,13 @@ MINGW32*)
;;
GNU/kFreeBSD)
bsd="yes"
- audio_drv_list="oss"
+ audio_drv_list="oss try-sdl"
audio_possible_drivers="oss sdl pa"
;;
FreeBSD)
bsd="yes"
make="${MAKE-gmake}"
- audio_drv_list="oss"
+ audio_drv_list="oss try-sdl"
audio_possible_drivers="oss sdl pa"
# needed for kinfo_getvmmap(3) in libutil.h
LIBS="-lutil $LIBS"
@@ -813,14 +813,14 @@ FreeBSD)
DragonFly)
bsd="yes"
make="${MAKE-gmake}"
- audio_drv_list="oss"
+ audio_drv_list="oss try-sdl"
audio_possible_drivers="oss sdl pa"
HOST_VARIANT_DIR="dragonfly"
;;
NetBSD)
bsd="yes"
make="${MAKE-gmake}"
- audio_drv_list="oss"
+ audio_drv_list="oss try-sdl"
audio_possible_drivers="oss sdl"
oss_lib="-lossaudio"
HOST_VARIANT_DIR="netbsd"
@@ -829,7 +829,7 @@ NetBSD)
OpenBSD)
bsd="yes"
make="${MAKE-gmake}"
- audio_drv_list="sdl"
+ audio_drv_list="try-sdl"
audio_possible_drivers="sdl"
HOST_VARIANT_DIR="openbsd"
supported_os="yes"
@@ -845,7 +845,7 @@ Darwin)
LDFLAGS="-arch x86_64 $LDFLAGS"
fi
cocoa="yes"
- audio_drv_list="coreaudio"
+ audio_drv_list="coreaudio try-sdl"
audio_possible_drivers="coreaudio sdl"
LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
@@ -861,7 +861,7 @@ SunOS)
install="${INSTALL-ginstall}"
smbd="${SMBD-/usr/sfw/sbin/smbd}"
if test -f /usr/include/sys/soundcard.h ; then
- audio_drv_list="oss"
+ audio_drv_list="oss try-sdl"
fi
audio_possible_drivers="oss sdl"
# needed for CMSG_ macros in sys/socket.h
@@ -879,7 +879,7 @@ Haiku)
LIBS="-lposix_error_mapper -lnetwork $LIBS"
;;
Linux)
- audio_drv_list="oss"
+ audio_drv_list="try-pa try-alsa try-sdl oss"
audio_possible_drivers="oss alsa sdl pa"
linux="yes"
linux_user="yes"
@@ -3342,39 +3342,40 @@ fi
##########################################
# Sound support libraries probe
-audio_drv_probe()
-{
- drv=$1
- hdr=$2
- lib=$3
- exp=$4
- cfl=$5
- cat > $TMPC << EOF
-#include <$hdr>
-int main(void) { $exp }
-EOF
- if compile_prog "$cfl" "$lib" ; then
- :
- else
- error_exit "$drv check failed" \
- "Make sure to have the $drv libs and headers installed."
- fi
-}
-
audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
for drv in $audio_drv_list; do
case $drv in
- alsa)
- audio_drv_probe $drv alsa/asoundlib.h -lasound \
- "return snd_pcm_close((snd_pcm_t *)0);"
- alsa_libs="-lasound"
+ alsa | try-alsa)
+ if $pkg_config alsa --exists; then
+ alsa_libs=$($pkg_config alsa --libs)
+ if test "$drv" = "try-alsa"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
+ fi
+ else
+ if test "$drv" = "try-alsa"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
+ else
+ error_exit "$drv check failed" \
+ "Make sure to have the $drv libs and headers installed."
+ fi
+ fi
;;
- pa)
- audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
- "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
- pulse_libs="-lpulse"
- audio_pt_int="yes"
+ pa | try-pa)
+ if $pkg_config libpulse --exists; then
+ pulse_libs=$($pkg_config libpulse --libs)
+ audio_pt_int="yes"
+ if test "$drv" = "try-pa"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
+ fi
+ else
+ if test "$drv" = "try-pa"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
+ else
+ error_exit "$drv check failed" \
+ "Make sure to have the $drv libs and headers installed."
+ fi
+ fi
;;
sdl)
@@ -3383,6 +3384,14 @@ for drv in $audio_drv_list; do
fi
;;
+ try-sdl)
+ if test "$sdl" = "no"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
+ else
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
+ fi
+ ;;
+
coreaudio)
coreaudio_libs="-framework CoreAudio"
;;
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 908696d..b80a62c 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -57,7 +57,6 @@ typedef struct {
} PCSpkState;
static const char *s_spk = "pcspk";
-static PCSpkState *pcspk_state;
static inline void generate_samples(PCSpkState *s)
{
@@ -111,22 +110,6 @@ static void pcspk_callback(void *opaque, int free)
}
}
-static int pcspk_audio_init(ISABus *bus)
-{
- PCSpkState *s = pcspk_state;
- struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
-
- AUD_register_card(s_spk, &s->card);
-
- s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
- if (!s->voice) {
- AUD_log(s_spk, "Could not open voice\n");
- return -1;
- }
-
- return 0;
-}
-
static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
unsigned size)
{
@@ -179,12 +162,20 @@ static void pcspk_initfn(Object *obj)
static void pcspk_realizefn(DeviceState *dev, Error **errp)
{
+ struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
ISADevice *isadev = ISA_DEVICE(dev);
PCSpkState *s = PC_SPEAKER(dev);
isa_register_ioport(isadev, &s->ioport, s->iobase);
- pcspk_state = s;
+ AUD_register_card(s_spk, &s->card);
+
+ s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
+ if (!s->voice) {
+ error_setg(errp, "Initializing audio voice failed");
+ AUD_remove_card(&s->card);
+ return;
+ }
}
static bool migrate_needed(void *opaque)
@@ -221,8 +212,6 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
dc->vmsd = &vmstate_spk;
dc->props = pcspk_properties;
- /* Reason: realize sets global pcspk_state */
- dc->user_creatable = false;
}
static const TypeInfo pcspk_info = {
@@ -233,6 +222,12 @@ static const TypeInfo pcspk_info = {
.class_init = pcspk_class_initfn,
};
+static int pcspk_audio_init(ISABus *bus)
+{
+ isa_create_simple(bus, TYPE_PC_SPEAKER);
+ return 0;
+}
+
static void pcspk_register(void)
{
type_register_static(&pcspk_info);