qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] audio: add help option for -audio and -audiodev


From: Volker Rümelin
Subject: Re: [PATCH v2] audio: add help option for -audio and -audiodev
Date: Thu, 8 Sep 2022 07:55:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

Am 07.09.22 um 19:30 schrieb Claudio Fontana:

add a simple help option for -audio and -audiodev
to show the list of available drivers, and document them.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
  audio/audio.c   | 20 ++++++++++++++++++++
  audio/audio.h   |  1 +
  qemu-options.hx | 10 ++++++----
  softmmu/vl.c    |  9 +++++++--
  4 files changed, 34 insertions(+), 6 deletions(-)

v1 -> v2: also extend the help to -audio.

  -audio help
  -audio driver=help
  -audiodev help

will all show the same results.

diff --git a/audio/audio.c b/audio/audio.c
index 4f4bb10cce..ffb09ec825 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -32,6 +32,7 @@
  #include "qapi/qapi-visit-audio.h"
  #include "qemu/cutils.h"
  #include "qemu/module.h"
+#include "qemu/help_option.h"
  #include "sysemu/sysemu.h"
  #include "sysemu/replay.h"
  #include "sysemu/runstate.h"
@@ -2105,10 +2106,29 @@ static void audio_validate_opts(Audiodev *dev, Error 
**errp)
      }
  }
+void audio_help(void)
+{
+    int i;
+
+    printf("Available audio drivers:\n");
+    printf("none\n");
+
+    for (i = 0; audio_prio_list[i]; i++) {
+        audio_driver *driver = audio_driver_lookup(audio_prio_list[i]);

Hi Claudio,

there is no guarantee that the audio_prio_list contains all audio backend drivers. I would use this

+    for (i = 0; i < AUDIODEV_DRIVER__MAX; i++) {
+        const char *name = AudiodevDriver_str(i);
+        audio_driver *driver = audio_driver_lookup(name);

to enumerate all audio backend drivers.

With best regards,
Volker

+        if (driver) {
+            printf("%s\n", driver->name);
+        }
+    }
+}
+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]