diff mbox series

[13/13] audio: forbid default audiodev backend with -nodefaults

Message ID 20230928073705.871327-14-pbonzini@redhat.com
State New
Headers show
Series Cleanup deprecated audio features, take 2 | expand

Commit Message

Paolo Bonzini Sept. 28, 2023, 7:36 a.m. UTC
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>
---
 audio/audio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/audio/audio.c b/audio/audio.c
index bc837cb2ff2..868164373e1 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1806,10 +1806,12 @@  static AudioState *audio_init(Audiodev *dev)
 bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp)
 {
     if (!card->state) {
-        if (!QSIMPLEQ_EMPTY(&audiodevs)) {
+        if (!QSIMPLEQ_EMPTY(&audiodevs) || !defaults_enabled()) {
             error_setg(errp, "No audiodev specified for %s", name);
-            error_append_hint(errp, "Perhaps you wanted to set audiodev=%s?",
-                              QSIMPLEQ_FIRST(&audiodevs)->dev->id);
+            if (!QSIMPLEQ_EMPTY(&audiodevs)) {
+                error_append_hint(errp, "Perhaps you wanted to set audiodev=%s?",
+                                  QSIMPLEQ_FIRST(&audiodevs)->dev->id);
+            }
             return false;
         }