mirror of
https://github.com/qemu/qemu.git
synced 2024-11-25 11:53:39 +08:00
audio: pc speaker init fix, rework driver probing
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJcSbt4AAoJEEy22O7T6HE4sQcQAI9luAsbiv9IVEjZwCMd/j0U 4ekmDZVZ7WJhVSYtHNwMtccxADzlTpCEJi9+sPuYg20guzT5gGBwxCYTpQFgx3ta g5g3gF+OXJdCG8E9Nu3N/wloYKLreB1nESk2IWC3hpzsfFW0BCMYQ44EoJ+CPJoV sTyNj7/krCZZU1E7BGv4A74u2l2vUQFXZMADLnrhtvu8ZtXahhI3B+wbD5swYjGK flibJTyak/msqv0xDgwRJmudO2l1reGYyf6y/d/IQRFhoV/RmxRu7P0WAwOkDkYY cG89NdjIyq0pltLGpyWedlUqZvvJty3hQYvP6rQXcZLAj6UXz9EVwSYlW+Cd1ybg Qqw3gJY+6EraFksddbe10fvj1IZWZ/5hHWRfQZHSZjKN3Ex9sR9EjKfMVUBk7/6A ewkxMRO6J2qwtBQvB8Al9ISa/vkLQlZ02Hjg4VWX3SH3hrclDQtOmYio7wSa0UZ2 qatTUrmxOmAiODxyHE3DEoZbsHI7hxpboONHR8uyvvk/mwnmhaEgxZxRxhnyQcEP PBDALkvYzwLCtMUZwbKynebruZ8+mFVqhccyt3wkWu6FyPv8r6ZCPjXoprvy5jAy rkiYL0nCjDU0tW+2RsNLmwiv+b8gPyZJwctsdTJRwcN0MqtFYUGbWoqy8E9ALVjk M6AlVTjnORmX3c4SGGF5 =EUbq -----END PGP SIGNATURE----- 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>
This commit is contained in:
commit
87f6a866f1
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
81
configure
vendored
81
configure
vendored
@ -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"
|
||||
;;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user