diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-08-22 17:10:21 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-09-02 15:54:47 +0400 |
commit | 0f957c53c84d655f2e99677d407cf2bbe1832de4 (patch) | |
tree | 644d6e9bd8e40a4a2a345245ff1bdc17c0e3681e /audio/audio.c | |
parent | 0370f239ad14aeacc496775e241b9ef041df4374 (diff) | |
download | qemu-0f957c53c84d655f2e99677d407cf2bbe1832de4.zip qemu-0f957c53c84d655f2e99677d407cf2bbe1832de4.tar.gz qemu-0f957c53c84d655f2e99677d407cf2bbe1832de4.tar.bz2 |
audio: exit(1) if audio backend failed to be found or initialized
If you specify a known backend but it isn't compiled in, or failed to
initialize, you get a simple warning and the "none" backend as a
fallback, and QEMU runs happily:
$ qemu-system-x86_64 -audiodev id=audio,driver=dsound
audio: Unknown audio driver `dsound'
audio: warning: Using timer based audio emulation
...
Instead, QEMU should fail to start:
$ qemu-system-x86_64 -audiodev id=audio,driver=dsound
audio: Unknown audio driver `dsound'
$
Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1983493
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20220822131021.975656-1-marcandre.lureau@redhat.com>
Diffstat (limited to 'audio/audio.c')
-rw-r--r-- | audio/audio.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/audio/audio.c b/audio/audio.c index a02f3ce..76b8735 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1743,7 +1743,6 @@ static AudioState *audio_init(Audiodev *dev, const char *name) atexit(audio_cleanup); atexit_registered = true; } - QTAILQ_INSERT_TAIL(&audio_states, s, list); s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); @@ -1769,6 +1768,10 @@ static AudioState *audio_init(Audiodev *dev, const char *name) } else { dolog ("Unknown audio driver `%s'\n", drvname); } + if (!done) { + free_audio_state(s); + return NULL; + } } else { for (i = 0; audio_prio_list[i]; i++) { AudiodevListEntry *e = audiodev_find(&head, audio_prio_list[i]); @@ -1806,6 +1809,7 @@ static AudioState *audio_init(Audiodev *dev, const char *name) "(Audio can continue looping even after stopping the VM)\n"); } + QTAILQ_INSERT_TAIL(&audio_states, s, list); QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); return s; @@ -2119,13 +2123,17 @@ void audio_define(Audiodev *dev) QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); } -void audio_init_audiodevs(void) +bool audio_init_audiodevs(void) { AudiodevListEntry *e; QSIMPLEQ_FOREACH(e, &audiodevs, next) { - audio_init(e->dev, NULL); + if (!audio_init(e->dev, NULL)) { + return false; + } } + + return true; } audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) |