diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2023-10-09 10:11:17 -0400 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2023-10-09 10:11:18 -0400 |
commit | 1527c6b6fa6c6775523287e33f78b41afc7ba46c (patch) | |
tree | e245ed1f0f1856b800b391e22da9d09b21950540 /audio | |
parent | f7294103560260ff09ffdf316cf6ba6d4e368d85 (diff) | |
parent | 912eef205ae9ccfd477c343a51a7c2dcfae2ba43 (diff) |
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* util/log: re-allow switching away from stderr log file
* finish audio configuration rework
* cleanup HVF stubs
* remove more mentions of softmmu
# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmUi/kIUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroOXWwf/YW16QMzqdAPVHYRf9NcCneRF16El
# t3lEod0q0sHhchPbh9e04aKbh+oBNeWu9sFyTl11Fwsi+DGmp/b28ziva75/4rfd
# h5N9aX/z2jwPqy93IwPDu3soKXCCgTK+ywtD/5GLQwBGqxs7W2xUEEb7eCnVefHa
# zwL3MOUqPICeqOnR1TNw9k3N3veF04D+rmchTwbAjAmx1f8EI+mK9VlGK9V8TUjP
# 3HjpZYJluc0a92lR5VONJ7V25QfttsjLysTgpFwVAQPS6Frzatc/hWclfLYgw9vl
# 2Irk83FV8gXPRl0XKNcqSDsv6h/yGP6TDFIB8QwRSRGBqIQi5aOlfBJzsQ==
# =qbm7
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 08 Oct 2023 15:08:50 EDT
# gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg: issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1
# Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83
* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (25 commits)
audio, qtest: get rid of QEMU_AUDIO_DRV
audio: reintroduce default audio backend for VNC
audio: do not use first -audiodev as default audio device
audio: extend -audio to allow creating a default backend
audio: extract audio_define_default
audio: disable default backends if -audio/-audiodev is used
audio: error hints need a trailing \n
cutils: squelch compiler warnings with custom paths
configure: change $softmmu to $system
system: Rename softmmu/ directory as system/
meson: Rename target_softmmu_arch -> target_system_arch
meson: Rename softmmu_mods -> system_mods
target/i386: Rename i386_softmmu_kvm_ss -> i386_kvm_ss
semihosting: Rename softmmu_FOO_user() -> uaccess_FOO_user()
gdbstub: Rename 'softmmu' -> 'system'
accel: Rename accel_softmmu* -> accel_system*
tcg: Correct invalid mentions of 'softmmu' by 'system-mode'
fuzz: Correct invalid mentions of 'softmmu' by 'system'
cpu: Correct invalid mentions of 'softmmu' by 'system-mode'
travis-ci: Correct invalid mentions of 'softmmu' by 'system'
...
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audio.c | 85 | ||||
-rw-r--r-- | audio/audio.h | 3 |
2 files changed, 37 insertions, 51 deletions
diff --git a/audio/audio.c b/audio/audio.c index 730bf2498d..e9815d6812 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -104,6 +104,7 @@ static audio_driver *audio_driver_lookup(const char *name) static QTAILQ_HEAD(AudioStateHead, AudioState) audio_states = QTAILQ_HEAD_INITIALIZER(audio_states); +static AudioState *default_audio_state; const struct mixeng_volume nominal_volume = { .mute = 0, @@ -1660,6 +1661,7 @@ static void free_audio_state(AudioState *s) void audio_cleanup(void) { + default_audio_state = NULL; while (!QTAILQ_EMPTY(&audio_states)) { AudioState *s = QTAILQ_FIRST(&audio_states); QTAILQ_REMOVE(&audio_states, s, list); @@ -1686,31 +1688,12 @@ static const VMStateDescription vmstate_audio = { } }; -static void audio_validate_opts(Audiodev *dev, Error **errp); - -static void audio_create_default_audiodevs(void) +void audio_create_default_audiodevs(void) { - const char *drvname = getenv("QEMU_AUDIO_DRV"); - - if (!defaults_enabled()) { - return; - } - - /* QEMU_AUDIO_DRV=none is used by libqtest. */ - if (drvname && !g_str_equal(drvname, "none")) { - error_report("Please use -audiodev instead of QEMU_AUDIO_*"); - exit(1); - } - for (int i = 0; audio_prio_list[i]; i++) { - if (drvname && !g_str_equal(drvname, audio_prio_list[i])) { - continue; - } - if (audio_driver_lookup(audio_prio_list[i])) { QDict *dict = qdict_new(); Audiodev *dev = NULL; - AudiodevListEntry *e; Visitor *v; qdict_put_str(dict, "driver", audio_prio_list[i]); @@ -1721,10 +1704,7 @@ static void audio_create_default_audiodevs(void) visit_type_Audiodev(v, NULL, &dev, &error_fatal); visit_free(v); - audio_validate_opts(dev, &error_abort); - e = g_new0(AudiodevListEntry, 1); - e->dev = dev; - QSIMPLEQ_INSERT_TAIL(&default_audiodevs, e, next); + audio_define_default(dev, &error_abort); } } } @@ -1770,6 +1750,7 @@ static AudioState *audio_init(Audiodev *dev, Error **errp) goto out; } } else { + assert(!default_audio_state); for (;;) { AudiodevListEntry *e = QSIMPLEQ_FIRST(&default_audiodevs); if (!e) { @@ -1808,36 +1789,27 @@ out: return NULL; } +AudioState *audio_get_default_audio_state(Error **errp) +{ + if (!default_audio_state) { + default_audio_state = audio_init(NULL, errp); + if (!default_audio_state) { + if (!QSIMPLEQ_EMPTY(&audiodevs)) { + error_append_hint(errp, "Perhaps you wanted to use -audio or set audiodev=%s?\n", + QSIMPLEQ_FIRST(&audiodevs)->dev->id); + } + } + } + + return default_audio_state; +} + bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp) { if (!card->state) { - if (!QTAILQ_EMPTY(&audio_states)) { - /* - * FIXME: once it is possible to create an arbitrary - * default device via -audio DRIVER,OPT=VALUE (no "model"), - * replace this special case with the default AudioState*, - * storing it in a separate global. For now, keep the - * warning to encourage moving off magic use of the first - * -audiodev. - */ - if (QSIMPLEQ_EMPTY(&default_audiodevs)) { - dolog("Device %s: audiodev default parameter is deprecated, please " - "specify audiodev=%s\n", name, - QTAILQ_FIRST(&audio_states)->dev->id); - } - card->state = QTAILQ_FIRST(&audio_states); - } else { - if (QSIMPLEQ_EMPTY(&default_audiodevs)) { - audio_create_default_audiodevs(); - } - card->state = audio_init(NULL, errp); - if (!card->state) { - if (!QSIMPLEQ_EMPTY(&audiodevs)) { - error_append_hint(errp, "Perhaps you wanted to set audiodev=%s?", - QSIMPLEQ_FIRST(&audiodevs)->dev->id); - } - return false; - } + card->state = audio_get_default_audio_state(errp); + if (!card->state) { + return false; } } @@ -2172,6 +2144,17 @@ void audio_define(Audiodev *dev) QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); } +void audio_define_default(Audiodev *dev, Error **errp) +{ + AudiodevListEntry *e; + + audio_validate_opts(dev, errp); + + e = g_new0(AudiodevListEntry, 1); + e->dev = dev; + QSIMPLEQ_INSERT_TAIL(&default_audiodevs, e, next); +} + void audio_init_audiodevs(void) { AudiodevListEntry *e; diff --git a/audio/audio.h b/audio/audio.h index 80f3f92124..fcc22307be 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -169,11 +169,14 @@ void audio_sample_from_uint64(void *samples, int pos, uint64_t left, uint64_t right); void audio_define(Audiodev *audio); +void audio_define_default(Audiodev *dev, Error **errp); void audio_parse_option(const char *opt); +void audio_create_default_audiodevs(void); void audio_init_audiodevs(void); void audio_help(void); AudioState *audio_state_by_name(const char *name, Error **errp); +AudioState *audio_get_default_audio_state(Error **errp); const char *audio_get_id(QEMUSoundCard *card); #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ |