diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-02 16:48:28 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-03 10:29:40 +0200 |
commit | 9f8cf356723702272af124e621e4c0e9805c8e22 (patch) | |
tree | a5eeadabd775256b3d9dae43ed3b155f4b970a51 /audio/audio.c | |
parent | cb94ff5f80c537e43c04fa4f071f1df784255310 (diff) |
audio: forbid default audiodev backend with -nodefaults
Now that all callers support setting an audiodev, forbid using the default
audiodev if -nodefaults is provided on the command line.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'audio/audio.c')
-rw-r--r-- | audio/audio.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/audio/audio.c b/audio/audio.c index 4289b7bf02..730bf2498d 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1692,6 +1692,10 @@ static 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_*"); @@ -1808,6 +1812,14 @@ 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, @@ -1820,6 +1832,10 @@ bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp) } 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; } } |