From cbf4a44426ca98df8337768ed7bb8a87b5c169a3 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 14 Aug 2017 21:33:51 +1000 Subject: [PATCH] adaptivedemux: start/stop the manifest update loop on liveness or periodic update changes Scenario: A manifest starts out in live mode but then the recording is finalized and a subsequent update changes the state to a non-live manifest when the server has finished recording/transcoding/whatever with the full list of fragments. Without this patch, the manifest update task is never stopped on the live->non-live transition and will busy loop, burning through one CPU core. https://bugzilla.gnome.org/show_bug.cgi?id=786275 --- gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 9ee1a76409..32d565d971 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -2027,6 +2027,7 @@ gst_adaptive_demux_stop_manifest_update_task (GstAdaptiveDemux * demux) gst_task_stop (demux->priv->updates_task); g_mutex_lock (&demux->priv->updates_timed_lock); + GST_DEBUG_OBJECT (demux, "requesting stop of the manifest update task"); demux->priv->stop_updates_task = TRUE; g_cond_signal (&demux->priv->updates_timed_cond); g_mutex_unlock (&demux->priv->updates_timed_lock); @@ -2045,6 +2046,7 @@ gst_adaptive_demux_start_manifest_update_task (GstAdaptiveDemux * demux) g_mutex_unlock (&demux->priv->updates_timed_lock); /* Task to periodically update the manifest */ if (demux_class->requires_periodical_playlist_update (demux)) { + GST_DEBUG_OBJECT (demux, "requesting start of the manifest update task"); gst_task_start (demux->priv->updates_task); } } @@ -4361,6 +4363,18 @@ gst_adaptive_demux_update_manifest (GstAdaptiveDemux * demux) GST_DEBUG_OBJECT (demux, "Duration unknown, can not send the duration message"); } + + /* If a manifest changes it's liveness or periodic updateness, we need + * to start/stop the manifest update task appropriately */ + /* Keep this condition in sync with the one in + * gst_adaptive_demux_start_manifest_update_task() + */ + if (gst_adaptive_demux_is_live (demux) && + klass->requires_periodical_playlist_update (demux)) { + gst_adaptive_demux_start_manifest_update_task (demux); + } else { + gst_adaptive_demux_stop_manifest_update_task (demux); + } } return ret;