From 00400a838ba82533310a2ad9744c7f61072f297b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Tue, 19 Feb 2013 13:17:53 -0500 Subject: [PATCH] mssdemux: avoid streaming to fail when download is cancelled When download was failing repeatedly, it was causing streaming to fail even though it was cancelled on purpose (stopping tasks). --- ext/smoothstreaming/gstmssdemux.c | 13 +++++++++++++ ext/smoothstreaming/gstmssdemux.h | 1 + 2 files changed, 14 insertions(+) diff --git a/ext/smoothstreaming/gstmssdemux.c b/ext/smoothstreaming/gstmssdemux.c index bc6ad7025e..41ab253aa2 100644 --- a/ext/smoothstreaming/gstmssdemux.c +++ b/ext/smoothstreaming/gstmssdemux.c @@ -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 diff --git a/ext/smoothstreaming/gstmssdemux.h b/ext/smoothstreaming/gstmssdemux.h index 0b8eec8045..061f1d1601 100644 --- a/ext/smoothstreaming/gstmssdemux.h +++ b/ext/smoothstreaming/gstmssdemux.h @@ -74,6 +74,7 @@ struct _GstMssDemuxStream { gboolean eos; gboolean have_data; + gboolean cancelled; GstDownloadRate download_rate;