From: Sebastian Dröge Date: Fri, 14 May 2010 15:24:14 +0000 (+0200) Subject: appsrc: Always take the object lock when accessing the caps X-Git-Tag: RELEASE-0.10.30~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f43216b9d7327ddb3c6fd9d19f9ee1a005b966d6;p=platform%2Fupstream%2Fgst-plugins-base.git appsrc: Always take the object lock when accessing the caps Fixes bug #618625. --- 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;