From f43216b9d7327ddb3c6fd9d19f9ee1a005b966d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 14 May 2010 17:24:14 +0200 Subject: [PATCH] appsrc: Always take the object lock when accessing the caps Fixes bug #618625. --- gst-libs/gst/app/gstappsrc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index 25cf39f..74e8bee 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -939,8 +939,10 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size, GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc); GstAppSrcPrivate *priv = appsrc->priv; GstFlowReturn ret; + GstCaps *caps; GST_OBJECT_LOCK (appsrc); + caps = priv->caps ? gst_caps_ref (priv->caps) : NULL; if (G_UNLIKELY (priv->size != bsrc->segment.duration && bsrc->segment.format == GST_FORMAT_BYTES)) { GST_DEBUG_OBJECT (appsrc, @@ -994,7 +996,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size, if (priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) priv->offset += buf_size; *buf = gst_buffer_make_metadata_writable (*buf); - gst_buffer_set_caps (*buf, priv->caps); + gst_buffer_set_caps (*buf, caps); /* signal that we removed an item */ g_cond_broadcast (priv->cond); @@ -1034,7 +1036,8 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size, g_cond_wait (priv->cond, priv->mutex); } g_mutex_unlock (priv->mutex); - + if (caps) + gst_caps_unref (caps); return ret; /* ERRORS */ @@ -1042,17 +1045,23 @@ flushing: { GST_DEBUG_OBJECT (appsrc, "we are flushing"); g_mutex_unlock (priv->mutex); + if (caps) + gst_caps_unref (caps); return GST_FLOW_WRONG_STATE; } eos: { GST_DEBUG_OBJECT (appsrc, "we are EOS"); g_mutex_unlock (priv->mutex); + if (caps) + gst_caps_unref (caps); return GST_FLOW_UNEXPECTED; } seek_error: { g_mutex_unlock (priv->mutex); + if (caps) + gst_caps_unref (caps); GST_ELEMENT_ERROR (appsrc, RESOURCE, READ, ("failed to seek"), GST_ERROR_SYSTEM); return GST_FLOW_ERROR; -- 2.7.4