mssdemux: avoid streaming to fail when download is cancelled
authorLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>
Tue, 19 Feb 2013 18:17:53 +0000 (13:17 -0500)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 8 May 2013 00:09:48 +0000 (21:09 -0300)
When download was failing repeatedly, it was causing streaming to fail even though it was cancelled on purpose (stopping tasks).

ext/smoothstreaming/gstmssdemux.c
ext/smoothstreaming/gstmssdemux.h

index bc6ad70..41ab253 100644 (file)
@@ -520,6 +520,7 @@ gst_mss_demux_stop_tasks (GstMssDemux * mssdemux, gboolean immediate)
 
     gst_data_queue_set_flushing (stream->dataqueue, TRUE);
 
+    stream->cancelled = TRUE;
     if (immediate)
       gst_uri_downloader_cancel (stream->downloader);
     gst_task_pause (stream->download_task);
@@ -529,6 +530,8 @@ gst_mss_demux_stop_tasks (GstMssDemux * mssdemux, gboolean immediate)
   for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) {
     GstMssDemuxStream *stream = iter->data;
     g_static_rec_mutex_lock (&stream->download_lock);
+    stream->cancelled = FALSE;
+    stream->download_error_count = 0;
   }
   g_static_rec_mutex_lock (&mssdemux->stream_lock);
 }
@@ -1110,6 +1113,10 @@ gst_mss_demux_download_loop (GstMssDemuxStream * stream)
   GST_OBJECT_UNLOCK (mssdemux);
 
   ret = gst_mss_demux_stream_download_fragment (stream, &buffer);
+
+  if (stream->cancelled)
+    goto cancelled;
+
   switch (ret) {
     case GST_FLOW_OK:
       break;                    /* all is good, let's go */
@@ -1148,6 +1155,12 @@ error:
     }
     return;
   }
+cancelled:
+  {
+    GST_DEBUG_OBJECT (mssdemux, "Stream %p has been cancelled", stream);
+    gst_task_pause (stream->download_task);
+    return;
+  }
 }
 
 static GstFlowReturn
index 0b8eec8..061f1d1 100644 (file)
@@ -74,6 +74,7 @@ struct _GstMssDemuxStream {
 
   gboolean eos;
   gboolean have_data;
+  gboolean cancelled;
 
   GstDownloadRate download_rate;