diff mbox

[v2,29/49] paaudio: properly disconnect streams in fini_*

Message ID fc4e69e2aa013c65550fd3e535dc056f40b64baa.1440171025.git.DirtY.iCE.hu@gmail.com
State New
Headers show

Commit Message

=?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Aug. 21, 2015, 3:37 p.m. UTC
Currently this needs a workaround due to bug #74624 in pulseaudio.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
---
 audio/paaudio.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/audio/paaudio.c b/audio/paaudio.c
index 17e8992..3e5612b 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -679,6 +679,25 @@  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 #74624
+     * https://bugs.freedesktop.org/show_bug.cgi?id=74624 */
+    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;
@@ -690,7 +709,7 @@  static void qpa_fini_out (HWVoiceOut *hw)
     audio_pt_join (&pa->pt, &ret, AUDIO_FUNC);
 
     if (pa->stream) {
-        pa_stream_unref (pa->stream);
+        qpa_simple_disconnect(pa->g->conn, pa->stream);
         pa->stream = NULL;
     }
 
@@ -710,7 +729,7 @@  static void qpa_fini_in (HWVoiceIn *hw)
     audio_pt_join (&pa->pt, &ret, AUDIO_FUNC);
 
     if (pa->stream) {
-        pa_stream_unref (pa->stream);
+        qpa_simple_disconnect(pa->g->conn, pa->stream);
         pa->stream = NULL;
     }