From 25686e5bcee030a1e17f797f75258f26594bab39 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Tue, 23 Aug 2011 22:44:43 +0200
Subject: [PATCH] pulse/output: fix deadlock when resuming the stream

Unlock the mainloop in all code paths.
---
 NEWS                             | 1 +
 src/output/pulse_output_plugin.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 201b5b678..eaa8d194e 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ ver 0.16.4 (2011/??/??)
 * output:
   - alsa: fix SIGFPE when alsa announces a period size of 0
   - httpd: don't warn on client disconnect
+  - pulse: fix deadlock when resuming the stream
 
 
 ver 0.16.3 (2011/06/04)
diff --git a/src/output/pulse_output_plugin.c b/src/output/pulse_output_plugin.c
index d29fbd705..2635ed149 100644
--- a/src/output/pulse_output_plugin.c
+++ b/src/output/pulse_output_plugin.c
@@ -683,8 +683,10 @@ pulse_output_play(void *data, const void *chunk, size_t size, GError **error_r)
 	/* unpause if previously paused */
 
 	if (pulse_output_stream_is_paused(po) &&
-	    !pulse_output_stream_pause(po, false, error_r))
+	    !pulse_output_stream_pause(po, false, error_r)) {
+		pa_threaded_mainloop_unlock(po->mainloop);
 		return 0;
+	}
 
 	/* wait until the server allows us to write */