From: Louis-Francis Ratté-Boulianne Date: Tue, 19 Feb 2013 18:01:37 +0000 (-0500) Subject: uridownloader: unlock mutex when switching urisrc state to NULL to avoid deadlock X-Git-Tag: 1.19.3~507^2~13749 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0211e5b7b55d607086bbdb7458981f9a551c661;p=platform%2Fupstream%2Fgstreamer.git uridownloader: unlock mutex when switching urisrc state to NULL to avoid deadlock When chain method was called after gst_uri_downloader_stop and before state has been changed to NULL, execution was blocking on g_mutex_lock. Conflicts: gst-libs/gst/uridownloader/gsturidownloader.c --- diff --git a/gst-libs/gst/uridownloader/gsturidownloader.c b/gst-libs/gst/uridownloader/gsturidownloader.c index 142bb2a563..15af6a4983 100644 --- a/gst-libs/gst/uridownloader/gsturidownloader.c +++ b/gst-libs/gst/uridownloader/gsturidownloader.c @@ -243,10 +243,15 @@ done: } } +/* Must be called with mutex locked. */ static void gst_uri_downloader_stop (GstUriDownloader * downloader) { GstPad *pad; + GstElement *urisrc; + + if (!downloader->priv->urisrc) + return; GST_DEBUG_OBJECT (downloader, "Stopping source element %s", GST_ELEMENT_NAME (downloader->priv->urisrc)); @@ -259,14 +264,23 @@ gst_uri_downloader_stop (GstUriDownloader * downloader) gst_pad_unlink (pad, downloader->priv->pad); gst_object_unref (pad); } - /* set the element state to NULL */ - gst_element_set_state (downloader->priv->urisrc, GST_STATE_NULL); - gst_element_get_state (downloader->priv->urisrc, NULL, NULL, - GST_CLOCK_TIME_NONE); - gst_element_set_bus (downloader->priv->urisrc, NULL); - gst_object_unref (downloader->priv->urisrc); + urisrc = downloader->priv->urisrc; downloader->priv->urisrc = NULL; + /* unlock so it doesn't block on chain function while changing state */ + g_mutex_unlock (&downloader->priv->lock); + + GST_DEBUG_OBJECT (downloader, "Stopping source element %s", + GST_ELEMENT_NAME (urisrc)); + + /* set the element state to NULL */ + gst_element_set_state (urisrc, GST_STATE_NULL); + gst_element_get_state (urisrc, NULL, NULL, GST_CLOCK_TIME_NONE); + gst_element_set_bus (urisrc, NULL); + gst_object_unref (urisrc); + + /* caller expects the mutex to be locked */ + g_mutex_lock (&downloader->priv->lock); gst_bus_set_flushing (downloader->priv->bus, TRUE); }