qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	Kővágó@redhat.com, "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Michael Walle" <michael@walle.cc>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
	Zoltán <DirtY.iCE.hu@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 08/15] paaudio: properly disconnect streams in fini_*
Date: Tue, 13 Aug 2019 13:18:02 +0200	[thread overview]
Message-ID: <20190813111809.3141-9-kraxel@redhat.com> (raw)
In-Reply-To: <20190813111809.3141-1-kraxel@redhat.com>

From: Kővágó, Zoltán <dirty.ice.hu@gmail.com>

Currently this needs a workaround due to bug #247 in pulseaudio.

Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: d1085ec6129416705b2cb65737e510ec9ffec508.1564925486.git.DirtY.iCE.hu@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/paaudio.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/audio/paaudio.c b/audio/paaudio.c
index 24d98b344a37..1d68173636ed 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -685,6 +685,27 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
     return -1;
 }
 
+static void qpa_simple_disconnect(PAConnection *c, pa_stream *stream)
+{
+    int err;
+
+    pa_threaded_mainloop_lock(c->mainloop);
+    /*
+     * wait until actually connects. workaround pa bug #247
+     * https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/247
+     */
+    while (pa_stream_get_state(stream) == PA_STREAM_CREATING) {
+        pa_threaded_mainloop_wait(c->mainloop);
+    }
+
+    err = pa_stream_disconnect(stream);
+    if (err != 0) {
+        dolog("Failed to disconnect! err=%d\n", err);
+    }
+    pa_stream_unref(stream);
+    pa_threaded_mainloop_unlock(c->mainloop);
+}
+
 static void qpa_fini_out (HWVoiceOut *hw)
 {
     void *ret;
@@ -696,7 +717,7 @@ static void qpa_fini_out (HWVoiceOut *hw)
     audio_pt_join(&pa->pt, &ret, __func__);
 
     if (pa->stream) {
-        pa_stream_unref (pa->stream);
+        qpa_simple_disconnect(pa->g->conn, pa->stream);
         pa->stream = NULL;
     }
 
@@ -716,7 +737,7 @@ static void qpa_fini_in (HWVoiceIn *hw)
     audio_pt_join(&pa->pt, &ret, __func__);
 
     if (pa->stream) {
-        pa_stream_unref (pa->stream);
+        qpa_simple_disconnect(pa->g->conn, pa->stream);
         pa->stream = NULL;
     }
 
-- 
2.18.1



  parent reply	other threads:[~2019-08-13 11:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 11:17 [Qemu-devel] [PULL 00/15] Audio 20190813 patches Gerd Hoffmann
2019-08-13 11:17 ` [Qemu-devel] [PULL 01/15] audio: reduce glob_audio_state usage Gerd Hoffmann
2019-08-13 11:17 ` [Qemu-devel] [PULL 02/15] audio: basic support for multi backend audio Gerd Hoffmann
2019-08-13 11:17 ` [Qemu-devel] [PULL 03/15] audio: add audiodev property to vnc and wav_capture Gerd Hoffmann
2019-08-13 11:17 ` [Qemu-devel] [PULL 04/15] audio: add audiodev properties to frontends Gerd Hoffmann
2019-08-13 11:17 ` [Qemu-devel] [PULL 05/15] paaudio: prepare for multiple audiodev Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 06/15] audio: audiodev= parameters no longer optional when -audiodev present Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 07/15] paaudio: do not move stream when sink/source name is specified Gerd Hoffmann
2019-08-13 11:18 ` Gerd Hoffmann [this message]
2019-08-13 11:18 ` [Qemu-devel] [PULL 09/15] audio: remove audio_MIN, audio_MAX Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 10/15] audio: do not run each backend in audio_run Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 11/15] paaudio: fix playback glitches Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 12/15] audio: remove read and write pcm_ops Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 13/15] audio: use size_t where makes sense Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 14/15] audio: fix memory leak reported by ASAN Gerd Hoffmann
2019-08-13 11:18 ` [Qemu-devel] [PULL 15/15] audio: Add missing fall through comments Gerd Hoffmann
2019-08-13 11:22 ` [Qemu-devel] [PULL 00/15] Audio 20190813 patches Peter Maydell
2019-08-13 11:53   ` Gerd Hoffmann
2019-08-16 10:10 ` Peter Maydell

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=20190813111809.3141-9-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=DirtY.iCE.hu@gmail.com \
    --cc=Kővágó@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=michael@walle.cc \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=pbonzini@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).