appsrc: Always take the object lock when accessing the caps

Fixes bug #618625.
This commit is contained in:
Sebastian Dröge 2010-05-14 17:24:14 +02:00
parent 0c85f2c890
commit f43216b9d7

View File

@ -939,8 +939,10 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc); GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
GstAppSrcPrivate *priv = appsrc->priv; GstAppSrcPrivate *priv = appsrc->priv;
GstFlowReturn ret; GstFlowReturn ret;
GstCaps *caps;
GST_OBJECT_LOCK (appsrc); GST_OBJECT_LOCK (appsrc);
caps = priv->caps ? gst_caps_ref (priv->caps) : NULL;
if (G_UNLIKELY (priv->size != bsrc->segment.duration && if (G_UNLIKELY (priv->size != bsrc->segment.duration &&
bsrc->segment.format == GST_FORMAT_BYTES)) { bsrc->segment.format == GST_FORMAT_BYTES)) {
GST_DEBUG_OBJECT (appsrc, 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) if (priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS)
priv->offset += buf_size; priv->offset += buf_size;
*buf = gst_buffer_make_metadata_writable (*buf); *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 */ /* signal that we removed an item */
g_cond_broadcast (priv->cond); 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_cond_wait (priv->cond, priv->mutex);
} }
g_mutex_unlock (priv->mutex); g_mutex_unlock (priv->mutex);
if (caps)
gst_caps_unref (caps);
return ret; return ret;
/* ERRORS */ /* ERRORS */
@ -1042,17 +1045,23 @@ flushing:
{ {
GST_DEBUG_OBJECT (appsrc, "we are flushing"); GST_DEBUG_OBJECT (appsrc, "we are flushing");
g_mutex_unlock (priv->mutex); g_mutex_unlock (priv->mutex);
if (caps)
gst_caps_unref (caps);
return GST_FLOW_WRONG_STATE; return GST_FLOW_WRONG_STATE;
} }
eos: eos:
{ {
GST_DEBUG_OBJECT (appsrc, "we are EOS"); GST_DEBUG_OBJECT (appsrc, "we are EOS");
g_mutex_unlock (priv->mutex); g_mutex_unlock (priv->mutex);
if (caps)
gst_caps_unref (caps);
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
} }
seek_error: seek_error:
{ {
g_mutex_unlock (priv->mutex); g_mutex_unlock (priv->mutex);
if (caps)
gst_caps_unref (caps);
GST_ELEMENT_ERROR (appsrc, RESOURCE, READ, ("failed to seek"), GST_ELEMENT_ERROR (appsrc, RESOURCE, READ, ("failed to seek"),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;