diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-05 18:42:54 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-08 21:08:27 +0200 |
commit | 63a13c08055072e92129a1d0ffeeecdcac6ad3d4 (patch) | |
tree | 720dd36f44f0b236fa9198ee8cbcbfb7e6418ed3 /audio | |
parent | 22f84d4f7882d881a5f8574430da62c7ce5a0731 (diff) |
audio: reintroduce default audio backend for VNC
Make VNC use the default backend again if one is defined.
The recently introduced support for disabling the VNC audio
extension is still used, in case no default backend exists.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audio.c | 28 | ||||
-rw-r--r-- | audio/audio.h | 1 |
2 files changed, 19 insertions, 10 deletions
diff --git a/audio/audio.c b/audio/audio.c index bd4bcabcca..73b65dc3b9 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1801,20 +1801,28 @@ out: return NULL; } -bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp) +AudioState *audio_get_default_audio_state(Error **errp) { - if (!card->state) { + if (!default_audio_state) { + default_audio_state = audio_init(NULL, errp); if (!default_audio_state) { - default_audio_state = audio_init(NULL, errp); - if (!default_audio_state) { - if (!QSIMPLEQ_EMPTY(&audiodevs)) { - error_append_hint(errp, "Perhaps you wanted to use -audio or set audiodev=%s?\n", - QSIMPLEQ_FIRST(&audiodevs)->dev->id); - } - return false; + if (!QSIMPLEQ_EMPTY(&audiodevs)) { + error_append_hint(errp, "Perhaps you wanted to use -audio or set audiodev=%s?\n", + QSIMPLEQ_FIRST(&audiodevs)->dev->id); } } - card->state = default_audio_state; + } + + return default_audio_state; +} + +bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp) +{ + if (!card->state) { + card->state = audio_get_default_audio_state(errp); + if (!card->state) { + return false; + } } card->name = g_strdup (name); diff --git a/audio/audio.h b/audio/audio.h index 6da5e8f6f0..fcc22307be 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -176,6 +176,7 @@ void audio_init_audiodevs(void); void audio_help(void); AudioState *audio_state_by_name(const char *name, Error **errp); +AudioState *audio_get_default_audio_state(Error **errp); const char *audio_get_id(QEMUSoundCard *card); #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ |