Commit 86135253 authored by Sebastian Dröge's avatar Sebastian Dröge

appsrc: Always take the mutex before flushing the queue

Otherwise the application might push new buffers into the queue while we're
flushing, potentially causing the GQueue data structure to become inconsistent
and causing crashes soon after.

https://bugzilla.gnome.org/show_bug.cgi?id=754597
parent bbe967a2
......@@ -561,6 +561,7 @@ gst_app_src_init (GstAppSrc * appsrc)
gst_base_src_set_live (GST_BASE_SRC (appsrc), DEFAULT_PROP_IS_LIVE);
}
/* Must be called with priv->mutex */
static void
gst_app_src_flush_queued (GstAppSrc * src, gboolean retain_last_caps)
{
......@@ -607,7 +608,10 @@ gst_app_src_dispose (GObject * obj)
priv->notify = NULL;
GST_OBJECT_UNLOCK (appsrc);
g_mutex_lock (&priv->mutex);
gst_app_src_flush_queued (appsrc, FALSE);
g_mutex_unlock (&priv->mutex);
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
......@@ -767,10 +771,13 @@ static gboolean
gst_app_src_send_event (GstElement * element, GstEvent * event)
{
GstAppSrc *appsrc = GST_APP_SRC_CAST (element);
GstAppSrcPrivate *priv = appsrc->priv;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
g_mutex_lock (&priv->mutex);
gst_app_src_flush_queued (appsrc, TRUE);
g_mutex_unlock (&priv->mutex);
break;
default:
break;
......@@ -961,7 +968,9 @@ gst_app_src_do_seek (GstBaseSrc * src, GstSegment * segment)
if (res) {
GST_DEBUG_OBJECT (appsrc, "flushing queue");
g_mutex_lock (&priv->mutex);
gst_app_src_flush_queued (appsrc, TRUE);
g_mutex_unlock (&priv->mutex);
priv->is_eos = FALSE;
} else {
GST_WARNING_OBJECT (appsrc, "seek failed");
......
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