hlsdemux: make sure to stop fragments cache if something cancelled it
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Tue, 15 Feb 2011 21:40:21 +0000 (22:40 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 30 Mar 2011 07:19:22 +0000 (09:19 +0200)
gst/hls/gsthlsdemux.c
gst/hls/gsthlsdemux.h

index c155013179d1834adb8527de522e3149e752a51a..c3687850bee67b23281700a74cd011e46f208cae 100644 (file)
@@ -287,6 +287,7 @@ gst_hls_demux_change_state (GstElement * element, GstStateChange transition)
 
   switch (transition) {
     case GST_STATE_CHANGE_PAUSED_TO_READY:
+      demux->cancelled = TRUE;
       gst_hls_demux_stop_fetcher (demux, TRUE);
       break;
     default:
@@ -361,7 +362,8 @@ gst_hls_demux_fetcher_sink_event (GstPad * pad, GstEvent * event)
     case GST_EVENT_EOS:{
       GST_DEBUG_OBJECT (demux, "Got EOS on the fetcher pad");
       /* signal we have fetched the URI */
-      g_cond_signal (demux->fetcher_cond);
+      if (!demux->cancelled)
+        g_cond_signal (demux->fetcher_cond);
     }
     default:
       break;
@@ -572,6 +574,7 @@ gst_hls_demux_reset (GstHLSDemux * demux, gboolean dispose)
   demux->thread_return = FALSE;
   demux->accumulated_delay = 0;
   demux->end_of_playlist = FALSE;
+  demux->cancelled = FALSE;
 
   if (demux->input_caps) {
     gst_caps_unref (demux->input_caps);
@@ -721,9 +724,13 @@ gst_hls_demux_cache_fragments (GstHLSDemux * demux)
   /* Cache the first fragments */
   for (i = 0; i < demux->fragments_cache - 1; i++) {
     if (!gst_hls_demux_get_next_fragment (demux, FALSE)) {
-      GST_ERROR_OBJECT (demux, "Error caching the first fragments");
+      if (!demux->cancelled)
+        GST_ERROR_OBJECT (demux, "Error caching the first fragments");
       return FALSE;
     }
+    /* make sure we stop caching fragments if something cancelled it */
+    if (demux->cancelled)
+      return FALSE;
   }
 
   g_get_current_time (&demux->next_update);
index a486b910d1c3816940a3ab523d2e2aebe5cd1b04..396f2cb5514ca3eacd879290a5174c74032fb316 100644 (file)
@@ -83,6 +83,7 @@ struct _GstHLSDemux
   GTimeVal *timeout;
   gboolean fetcher_error;
   gboolean stopping_fetcher;
+  gboolean cancelled;
   GstBuffer *downloaded_uri;
 
 };