From 84decd731f0f188ae688fc7a98abe1d564de94b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Sat, 12 Mar 2011 00:44:31 +0530 Subject: [PATCH] pulsesink: Better fix for deadlock on failed connect This reverts the previous fix that would cause a double-unlock when the stream connect failed. https://bugzilla.gnome.org/show_bug.cgi?id=644510 --- ext/pulse/pulsesink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 110adde3da..5a60cda0e6 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -442,6 +442,7 @@ gst_pulseringbuffer_open_device (GstRingBuffer * buf) GstPulseRingBuffer *pbuf; GstPulseContext *pctx; pa_mainloop_api *api; + gboolean need_unlock_shared; psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (buf)); pbuf = GST_PULSERING_BUFFER_CAST (buf); @@ -458,6 +459,7 @@ gst_pulseringbuffer_open_device (GstRingBuffer * buf) pa_threaded_mainloop_lock (mainloop); g_mutex_lock (pa_shared_resource_mutex); + need_unlock_shared = TRUE; pctx = g_hash_table_lookup (gst_pulse_shared_contexts, pbuf->context_name); if (pctx == NULL) { @@ -481,7 +483,7 @@ gst_pulseringbuffer_open_device (GstRingBuffer * buf) gst_pulsering_context_subscribe_cb, pctx); #endif - /* try to connect to the server and wait for completioni, we don't want to + /* try to connect to the server and wait for completion, we don't want to * autospawn a deamon */ GST_LOG_OBJECT (psink, "connect to server %s", GST_STR_NULL (psink->server)); @@ -496,6 +498,7 @@ gst_pulseringbuffer_open_device (GstRingBuffer * buf) } g_mutex_unlock (pa_shared_resource_mutex); + need_unlock_shared = FALSE; /* context created or shared okay */ pbuf->context = pa_context_ref (pctx->context); @@ -527,7 +530,8 @@ gst_pulseringbuffer_open_device (GstRingBuffer * buf) /* ERRORS */ unlock_and_fail: { - g_mutex_unlock (pa_shared_resource_mutex); + if (need_unlock_shared) + g_mutex_unlock (pa_shared_resource_mutex); gst_pulsering_destroy_context (pbuf); pa_threaded_mainloop_unlock (mainloop); return FALSE;