audio: add help option for -audio and -audiodev

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>
Message-Id: <20220908081441.7111-1-cfontana@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Claudio Fontana 2022-09-08 10:14:41 +02:00 committed by Paolo Bonzini
parent e121d7606b
commit 5e03b6daf6
4 changed files with 33 additions and 6 deletions

View file

@ -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"
@ -2101,10 +2102,28 @@ static void audio_validate_opts(Audiodev *dev, Error **errp)
}
}
void audio_help(void)
{
int i;
printf("Available audio drivers:\n");
for (i = 0; i < AUDIODEV_DRIVER__MAX; i++) {
audio_driver *driver = audio_driver_lookup(AudiodevDriver_str(i));
if (driver) {
printf("%s\n", driver->name);
}
}
}
void audio_parse_option(const char *opt)
{
Audiodev *dev = NULL;
if (is_help_option(opt)) {
audio_help();
exit(EXIT_SUCCESS);
}
Visitor *v = qobject_input_visitor_new_str(opt, "driver", &error_fatal);
visit_type_Audiodev(v, NULL, &dev, &error_fatal);
visit_free(v);