All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kővágó, Zoltán" <dirty.ice.hu@gmail.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 06/11] paaudio: properly disconnect streams in fini_*
Date: Tue,  9 Jul 2019 20:35:46 +0200	[thread overview]
Message-ID: <02a720bfd7c6bb09c9cedb505516f07f0b395838.1562695780.git.DirtY.iCE.hu@gmail.com> (raw)
In-Reply-To: <cover.1562695780.git.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>
---
 audio/paaudio.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/audio/paaudio.c b/audio/paaudio.c
index 24d98b344a..490bcd770e 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 dissconnect! 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.22.0



  parent reply	other threads:[~2019-07-09 18:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 18:35 [Qemu-devel] [PATCH 00/11] Multiple simultaneous audio backends Kővágó, Zoltán
2019-07-09 18:35 ` [Qemu-devel] [PATCH 01/11] audio: reduce glob_audio_state usage Kővágó, Zoltán
2019-07-10 19:59   ` Marc-André Lureau
2019-07-09 18:35 ` [Qemu-devel] [PATCH 02/11] audio: basic support for multi backend audio Kővágó, Zoltán
2019-07-10  4:06   ` Markus Armbruster
2019-07-10 19:37     ` Zoltán Kővágó
2019-07-11  8:58       ` Dr. David Alan Gilbert
2019-07-11 14:37       ` Markus Armbruster
2019-07-11 19:07         ` Zoltán Kővágó
2019-07-10 19:58   ` Marc-André Lureau
2019-07-09 18:35 ` [Qemu-devel] [PATCH 03/11] audio: add audiodev properties to frontends Kővágó, Zoltán
2019-07-10 19:58   ` Marc-André Lureau
2019-07-09 18:35 ` [Qemu-devel] [PATCH 04/11] audio: audiodev= parameters no longer optional when -audiodev present Kővágó, Zoltán
2019-07-10 19:30   ` Marc-André Lureau
2019-07-11 19:09     ` Zoltán Kővágó
2019-07-09 18:35 ` [Qemu-devel] [PATCH 05/11] paaudio: do not move stream when sink/source name is specified Kővágó, Zoltán
2019-07-10 19:58   ` Marc-André Lureau
2019-07-09 18:35 ` Kővágó, Zoltán [this message]
2019-07-10 19:58   ` [Qemu-devel] [PATCH 06/11] paaudio: properly disconnect streams in fini_* Marc-André Lureau
2019-07-09 18:35 ` [Qemu-devel] [PATCH 07/11] audio: remove audio_MIN, audio_MAX Kővágó, Zoltán
2019-07-10 19:58   ` Marc-André Lureau
2019-07-09 18:35 ` [Qemu-devel] [PATCH 08/11] audio: do not run each backend in audio_run Kővágó, Zoltán
2019-07-10 19:58   ` Marc-André Lureau
2019-07-09 18:35 ` [Qemu-devel] [PATCH 09/11] paaudio: fix playback glitches Kővágó, Zoltán
2019-07-10 19:58   ` Marc-André Lureau
2019-07-14 15:21     ` Zoltán Kővágó
2019-07-09 18:35 ` [Qemu-devel] [PATCH 10/11] audio: remove read and write pcm_ops Kővágó, Zoltán
2019-07-10 19:57   ` Marc-André Lureau
2019-07-11 19:20     ` Zoltán Kővágó
2019-07-09 18:35 ` [Qemu-devel] [PATCH 11/11] audio: use size_t where makes sense Kővágó, Zoltán
2019-07-09 22:04 ` [Qemu-devel] [PATCH 00/11] Multiple simultaneous audio backends no-reply
2019-07-09 22:44 ` no-reply

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=02a720bfd7c6bb09c9cedb505516f07f0b395838.1562695780.git.DirtY.iCE.hu@gmail.com \
    --to=dirty.ice.hu@gmail.com \
    --cc=kraxel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.