Skip to content

Commit

Permalink
audio: reintroduce default audio backend for VNC
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bonzini committed Oct 8, 2023
1 parent 22f84d4 commit 63a13c0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
28 changes: 18 additions & 10 deletions audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1801,20 +1801,28 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)
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);
Expand Down
1 change: 1 addition & 0 deletions audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
6 changes: 0 additions & 6 deletions docs/about/removed-features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,6 @@ in this case.
Note that the default audio backend must be configured on the command
line if the ``-nodefaults`` options is used.

Creating vnc without ``audiodev=`` property (removed in 8.2)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

When using vnc, you should specify an ``audiodev=`` property if
you plan to transmit audio through the VNC protocol.

QEMU Machine Protocol (QMP) commands
------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions ui/vnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4185,6 +4185,8 @@ void vnc_display_open(const char *id, Error **errp)
if (!vd->audio_state) {
goto fail;
}
} else {
vd->audio_state = audio_get_default_audio_state(NULL);
}

device_id = qemu_opt_get(opts, "display");
Expand Down

0 comments on commit 63a13c0

Please sign in to comment.