From 26acbbcca96e000ada75671bec866c96b47a6ad3 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Tue, 17 Dec 2013 16:31:52 -0300 Subject: [PATCH] mssdemux: make sure streams stop properly on cancelled specially when the gst_task_join is waiting for the task to go stop and the task itself sets its back to paused, causing a deadlock on exit. --- ext/smoothstreaming/gstmssdemux.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/ext/smoothstreaming/gstmssdemux.c b/ext/smoothstreaming/gstmssdemux.c index df0187f..393c254 100644 --- a/ext/smoothstreaming/gstmssdemux.c +++ b/ext/smoothstreaming/gstmssdemux.c @@ -140,6 +140,8 @@ static GstFlowReturn gst_mss_demux_stream_push_event (GstMssDemuxStream * static GstFlowReturn gst_mss_demux_combine_flows (GstMssDemux * mssdemux); static gboolean gst_mss_demux_process_manifest (GstMssDemux * mssdemux); +static void +gst_mss_demux_stop_tasks (GstMssDemux * mssdemux, gboolean immediate); static void gst_mss_demux_class_init (GstMssDemuxClass * klass) @@ -278,13 +280,7 @@ gst_mss_demux_reset (GstMssDemux * mssdemux) { GSList *iter; - for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) { - GstMssDemuxStream *stream = iter->data; - - if (stream->downloader) - gst_uri_downloader_cancel (stream->downloader); - - } + gst_mss_demux_stop_tasks (mssdemux, TRUE); if (mssdemux->manifest_buffer) { gst_buffer_unref (mssdemux->manifest_buffer); @@ -481,16 +477,16 @@ gst_mss_demux_stop_tasks (GstMssDemux * mssdemux, gboolean immediate) for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) { GstMssDemuxStream *stream = iter->data; + gst_task_stop (stream->download_task); stream->cancelled = TRUE; if (immediate) gst_uri_downloader_cancel (stream->downloader); - gst_task_pause (stream->download_task); } for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) { GstMssDemuxStream *stream = iter->data; - g_rec_mutex_lock (&stream->download_lock); - stream->cancelled = FALSE; + + gst_task_join (stream->download_task); stream->download_error_count = 0; } } @@ -502,11 +498,7 @@ gst_mss_demux_restart_tasks (GstMssDemux * mssdemux) for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) { GstMssDemuxStream *stream = iter->data; gst_uri_downloader_reset (stream->downloader); - g_rec_mutex_unlock (&stream->download_lock); - } - for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) { - GstMssDemuxStream *stream = iter->data; - + stream->cancelled = FALSE; gst_task_start (stream->download_task); } } @@ -1232,7 +1224,6 @@ gst_mss_demux_download_loop (GstMssDemuxStream * stream) cancelled: { GST_DEBUG_OBJECT (mssdemux, "Stream %p has been cancelled", stream); - gst_task_pause (stream->download_task); return; } } -- 2.7.4