Commit 55a7fb85 authored by Thiago Sousa Santos's avatar Thiago Sousa Santos Committed by Edward Hervey
Browse files

adaptivedemux: do not erase data while updates-loop is running

Make sure the manifest update loop is stopped before proceeding with the
resetting of the manifest data. Otherwise, the updates loop will try to
use it and it leads to a segfault

https://bugzilla.gnome.org/show_bug.cgi?id=783028
parent 65f8a8e4
...@@ -283,7 +283,8 @@ static void gst_adaptive_demux_start_manifest_update_task (GstAdaptiveDemux * ...@@ -283,7 +283,8 @@ static void gst_adaptive_demux_start_manifest_update_task (GstAdaptiveDemux *
static void gst_adaptive_demux_start_tasks (GstAdaptiveDemux * demux, static void gst_adaptive_demux_start_tasks (GstAdaptiveDemux * demux,
gboolean start_preroll_streams); gboolean start_preroll_streams);
static void gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux); static void gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux,
gboolean stop_updates);
static GstFlowReturn gst_adaptive_demux_combine_flows (GstAdaptiveDemux * static GstFlowReturn gst_adaptive_demux_combine_flows (GstAdaptiveDemux *
demux); demux);
static void static void
...@@ -561,13 +562,7 @@ gst_adaptive_demux_change_state (GstElement * element, ...@@ -561,13 +562,7 @@ gst_adaptive_demux_change_state (GstElement * element,
GST_MANIFEST_LOCK (demux); GST_MANIFEST_LOCK (demux);
demux->running = FALSE; demux->running = FALSE;
gst_adaptive_demux_reset (demux); gst_adaptive_demux_reset (demux);
gst_adaptive_demux_stop_manifest_update_task (demux);
GST_MANIFEST_UNLOCK (demux); GST_MANIFEST_UNLOCK (demux);
/* demux->priv->updates_task value never changes, so it is safe to read it
* outside critical section
*/
gst_task_join (demux->priv->updates_task);
break; break;
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_MANIFEST_LOCK (demux); GST_MANIFEST_LOCK (demux);
...@@ -774,7 +769,7 @@ gst_adaptive_demux_reset (GstAdaptiveDemux * demux) ...@@ -774,7 +769,7 @@ gst_adaptive_demux_reset (GstAdaptiveDemux * demux)
old_streams = demux->priv->old_streams; old_streams = demux->priv->old_streams;
demux->priv->old_streams = NULL; demux->priv->old_streams = NULL;
gst_adaptive_demux_stop_tasks (demux); gst_adaptive_demux_stop_tasks (demux, TRUE);
if (klass->reset) if (klass->reset)
klass->reset (demux); klass->reset (demux);
...@@ -1577,11 +1572,11 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux, GstPad * pad, ...@@ -1577,11 +1572,11 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux, GstPad * pad,
gst_adaptive_demux_push_src_event (demux, fevent); gst_adaptive_demux_push_src_event (demux, fevent);
GST_MANIFEST_LOCK (demux); GST_MANIFEST_LOCK (demux);
gst_adaptive_demux_stop_tasks (demux); gst_adaptive_demux_stop_tasks (demux, FALSE);
} else if ((rate > 0 && start_type != GST_SEEK_TYPE_NONE) || } else if ((rate > 0 && start_type != GST_SEEK_TYPE_NONE) ||
(rate < 0 && stop_type != GST_SEEK_TYPE_NONE)) { (rate < 0 && stop_type != GST_SEEK_TYPE_NONE)) {
gst_adaptive_demux_stop_tasks (demux); gst_adaptive_demux_stop_tasks (demux, FALSE);
} }
GST_ADAPTIVE_DEMUX_SEGMENT_LOCK (demux); GST_ADAPTIVE_DEMUX_SEGMENT_LOCK (demux);
...@@ -1961,12 +1956,14 @@ gst_adaptive_demux_start_manifest_update_task (GstAdaptiveDemux * demux) ...@@ -1961,12 +1956,14 @@ gst_adaptive_demux_start_manifest_update_task (GstAdaptiveDemux * demux)
* the demux element. * the demux element.
*/ */
static void static void
gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux) gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux, gboolean stop_updates)
{ {
GList *iter; GList *iter;
GST_LOG_OBJECT (demux, "Stopping tasks"); GST_LOG_OBJECT (demux, "Stopping tasks");
if (stop_updates)
gst_adaptive_demux_stop_manifest_update_task (demux);
for (iter = demux->streams; iter; iter = g_list_next (iter)) { for (iter = demux->streams; iter; iter = g_list_next (iter)) {
GstAdaptiveDemuxStream *stream = iter->data; GstAdaptiveDemuxStream *stream = iter->data;
...@@ -2010,6 +2007,8 @@ gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux) ...@@ -2010,6 +2007,8 @@ gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux)
} }
GST_MANIFEST_UNLOCK (demux); GST_MANIFEST_UNLOCK (demux);
if (stop_updates)
gst_task_join (demux->priv->updates_task);
GST_MANIFEST_LOCK (demux); GST_MANIFEST_LOCK (demux);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment