diff mbox

[16/25] paaudio: properly disconnect streams in fini_*

Message ID ebc2c4e411932ac37ece158d3a30ede4a8c490bd.1438884611.git.DirtY.iCE.hu@gmail.com
State New
Headers show

Commit Message

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

Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
---
 audio/paaudio.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau Aug. 20, 2015, 8:29 p.m. UTC | #1
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

On Thu, Aug 6, 2015 at 8:28 PM, Kővágó, Zoltán <dirty.ice.hu@gmail.com> wrote:
> Currently this needs a workaround due to bug #74624 in pulseaudio.
>
> 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 --git a/audio/paaudio.c b/audio/paaudio.c
> index e3b8207..2aee22f 100644
> --- a/audio/paaudio.c
> +++ b/audio/paaudio.c
> @@ -678,6 +678,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;
> @@ -689,7 +708,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;
>      }
>
> @@ -709,7 +728,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;
>      }
>
> --
> 2.4.5
>
>
diff mbox

Patch

diff --git a/audio/paaudio.c b/audio/paaudio.c
index e3b8207..2aee22f 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -678,6 +678,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;
@@ -689,7 +708,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;
     }
 
@@ -709,7 +728,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;
     }