hlsdemux: make sure we don't stop the fetcher twice from different threads
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Tue, 15 Feb 2011 02:41:01 +0000 (03:41 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 30 Mar 2011 07:19:21 +0000 (09:19 +0200)
gst/hls/gsthlsdemux.c
gst/hls/gsthlsdemux.h

index ec0f3a1ac9cefdcbbe6506282ebe3a8d5bf08027..4dc5cd363479d90ac4c9f85a5ffe3accab3f5907 100644 (file)
@@ -418,10 +418,11 @@ gst_hls_demux_stop_fetcher (GstHLSDemux * demux, gboolean cancelled)
 {
   GstPad *pad;
 
-  if (demux->fetcher == NULL)
+  if (demux->fetcher == NULL || demux->stopping_fetcher)
     return;
 
   GST_DEBUG_OBJECT (demux, "Stopping fetcher.");
+  demux->stopping_fetcher = TRUE;
   gst_element_set_state (demux->fetcher, GST_STATE_NULL);
   pad = gst_pad_get_peer (demux->fetcherpad);
   if (pad) {
@@ -534,6 +535,7 @@ gst_hls_demux_make_fetcher (GstHLSDemux * demux, const gchar * uri)
     return FALSE;
 
   demux->fetcher_error = FALSE;
+  demux->stopping_fetcher = FALSE;
   gst_element_set_bus (GST_ELEMENT (demux->fetcher), demux->fetcher_bus);
 
   g_object_set (G_OBJECT (demux->fetcher), "location", uri, NULL);
@@ -718,6 +720,11 @@ gst_hls_demux_fetch_location (GstHLSDemux * demux, const gchar * uri)
   GST_DEBUG_OBJECT (demux, "Waiting to fetch the URI");
   g_cond_wait (demux->fetcher_cond, demux->fetcher_lock);
 
+  if (demux->stopping_fetcher) {
+    ret = FALSE;
+    goto quit;
+  }
+
   gst_hls_demux_stop_fetcher (demux, FALSE);
 
   if (demux->downloaded_uri != NULL) {
index 04c6b6985b6f2c129c9b972ab7d1a3518ee07ed4..d9b30075fa0d24f72cb54981dd78f37e6e9692ed 100644 (file)
@@ -81,6 +81,7 @@ struct _GstHLSDemux
   GCond *fetcher_cond;
   GTimeVal *timeout;
   gboolean fetcher_error;
+  gboolean stopping_fetcher;
   GstBuffer *downloaded_uri;
 
 };