Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> Signed-off-by: Kővágó, Zoltán <dirty.ice...@gmail.com>
--- Changes from v1: * (probably) more clear error messages audio/audio.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 88e04bf..d7e0533 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -69,6 +69,8 @@ const struct mixeng_volume nominal_volume = { #endif }; +static bool legacy_config; + #ifdef AUDIO_IS_FLAWLESS_AND_NO_CHECKS_ARE_REQURIED #error No its not #else @@ -1318,7 +1320,7 @@ static Audiodev *parse_option(QemuOpts *opts, Error **errp); * initialize a new state with it * if dev == NULL => legacy implicit initialization, return the already created * state or create a new one */ -static AudioState *audio_init(Audiodev *dev) +static AudioState *audio_init(Audiodev *dev, const char *name) { static bool atexit_registered; size_t i; @@ -1332,9 +1334,13 @@ static AudioState *audio_init(Audiodev *dev) if (dev) { drvname = AudiodevDriver_lookup[dev->kind]; } else if (!QTAILQ_EMPTY(&audio_states)) { - /* todo: chack for -audiodev we have normal audiodev selection support */ + if (!legacy_config) { + dolog("You must specify an audiodev= for the device %s\n", name); + exit(1); + } return QTAILQ_FIRST(&audio_states); } else { + legacy_config = true; audio_handle_legacy_opts(); list = qemu_find_opts("audiodev"); dev = parse_option(QTAILQ_FIRST(&list->head), &error_abort); @@ -1440,7 +1446,7 @@ static AudioState *audio_init(Audiodev *dev) void AUD_register_card (const char *name, QEMUSoundCard *card) { if (!card->state) { - card->state = audio_init(NULL); + card->state = audio_init(NULL, name); } card->name = g_strdup (name); @@ -1466,7 +1472,10 @@ CaptureVoiceOut *AUD_add_capture( struct capture_callback *cb; if (!s) { - /* todo: remove when we have normal audiodev selection support */ + if (!legacy_config) { + dolog("You must specify audiodev when trying to capture\n"); + goto err0; + } s = QTAILQ_FIRST(&audio_states); } @@ -1705,7 +1714,7 @@ static int each_option(void *opaque, QemuOpts *opts, Error **errp) if (!dev) { return -1; } - return audio_init(dev) ? 0 : -1; + return audio_init(dev, NULL) ? 0 : -1; } void audio_set_options(void) -- 2.5.0