qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: balaton@eik.bme.hu, berrange@redhat.com
Subject: [PATCH 6/7] audio: reintroduce default audio backend for VNC
Date: Thu,  5 Oct 2023 14:58:14 +0200	[thread overview]
Message-ID: <20231005125815.66082-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20231005125815.66082-1-pbonzini@redhat.com>

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>
---
 audio/audio.c                   | 28 ++++++++++++++++++----------
 audio/audio.h                   |  1 +
 docs/about/removed-features.rst | 10 ++--------
 ui/vnc.c                        |  2 ++
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index de37ad7c074..ca0df29555a 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1801,20 +1801,28 @@ out:
     return NULL;
 }
 
+AudioState *audio_get_default_audio_state(Error **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 set audiodev=%s?\n",
+                                  QSIMPLEQ_FIRST(&audiodevs)->dev->id);
+            }
+        }
+    }
+
+    return default_audio_state;
+}
+
 bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **errp)
 {
     if (!card->state) {
-        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 set audiodev=%s?\n",
-                                      QSIMPLEQ_FIRST(&audiodevs)->dev->id);
-                }
-                return false;
-            }
+        card->state = audio_get_default_audio_state(errp);
+        if (!card->state) {
+            return false;
         }
-        card->state = default_audio_state;
     }
 
     card->name = g_strdup (name);
diff --git a/audio/audio.h b/audio/audio.h
index 6da5e8f6f0f..fcc22307bee 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)         \
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index 27639370f96..a5e5a1ba1a5 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -449,17 +449,11 @@ QEMU does not create default audio backends anymore if any of the
 ``-audiodev``, ``-audio`` or ``-nodefaults`` options are used on the
 command line.
 
-If an audio backend is created with ``-audiodev``, each sound card
-that wants to use it should specify an ``audiodev=``
+If an audio backend is created with ``-audiodev``, each audio client
+(a sound card or VNC) that wants to use it should specify an ``audiodev=``
 property.  Previously, the first audiodev command line option would be
 used as a fallback.
 
-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
 ------------------------------------
 
diff --git a/ui/vnc.c b/ui/vnc.c
index acbb88c4ca0..7f4c471503a 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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");
-- 
2.41.0



  parent reply	other threads:[~2023-10-05 13:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05 12:58 [PATCH 0/7] audio: redo default audio backend creation Paolo Bonzini
2023-10-05 12:58 ` [PATCH 1/7] audio: error hints need a trailing \n Paolo Bonzini
2023-10-05 12:58 ` [PATCH 2/7] audio: disable default backends if -audio/-audiodev is used Paolo Bonzini
2023-10-05 12:58 ` [PATCH 3/7] audio: extract audio_define_default Paolo Bonzini
2023-10-05 12:58 ` [PATCH 4/7] audio: extend -audio to allow creating a default backend Paolo Bonzini
2023-10-05 12:58 ` [PATCH 5/7] audio: do not use first -audiodev as default audio device Paolo Bonzini
2023-10-05 13:33   ` BALATON Zoltan
2023-10-05 13:38     ` BALATON Zoltan
2023-10-05 15:09       ` Paolo Bonzini
2023-10-05 15:40         ` BALATON Zoltan
2023-10-05 16:41           ` Paolo Bonzini
2023-10-05 18:20             ` BALATON Zoltan
2023-10-05 12:58 ` Paolo Bonzini [this message]
2023-10-05 12:58 ` [PATCH 7/7] audio, qtest: get rid of QEMU_AUDIO_DRV Paolo Bonzini
2023-10-09 10:46 ` [PATCH 0/7] audio: redo default audio backend creation Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231005125815.66082-7-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=balaton@eik.bme.hu \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).