basesrc: make tag queuing threadsafe

See #588745
This commit is contained in:
Wim Taymans 2009-07-20 13:26:51 +02:00
parent dcdc73d182
commit 141e2af580

View file

@ -1453,8 +1453,10 @@ gst_base_src_send_event (GstElement * element, GstEvent * event)
break; break;
case GST_EVENT_TAG: case GST_EVENT_TAG:
/* Insert tag in the dataflow */ /* Insert tag in the dataflow */
src->priv->pending_tags = GST_OBJECT_LOCK (src);
g_list_append (src->priv->pending_tags, gst_event_ref (event)); src->priv->pending_tags = g_list_append (src->priv->pending_tags, event);
GST_OBJECT_UNLOCK (src);
event = NULL;
result = TRUE; result = TRUE;
break; break;
case GST_EVENT_BUFFERSIZE: case GST_EVENT_BUFFERSIZE:
@ -2171,6 +2173,7 @@ gst_base_src_loop (GstPad * pad)
gint64 position; gint64 position;
gboolean eos; gboolean eos;
gulong blocksize; gulong blocksize;
GList *tags, *tmp;
eos = FALSE; eos = FALSE;
@ -2226,18 +2229,19 @@ gst_base_src_loop (GstPad * pad)
src->priv->start_segment = NULL; src->priv->start_segment = NULL;
} }
/* Push out pending tags if any */ GST_OBJECT_LOCK (src);
if (G_UNLIKELY (src->priv->pending_tags)) { /* take the tags */
GList *tmp = src->priv->pending_tags; tags = src->priv->pending_tags;
src->priv->pending_tags = NULL;
GST_OBJECT_UNLOCK (src);
while (tmp) { /* Push out pending tags if any */
if (G_UNLIKELY (tags != NULL)) {
for (tmp = tags; tmp; tmp = g_list_next (tmp)) {
GstEvent *ev = (GstEvent *) tmp->data; GstEvent *ev = (GstEvent *) tmp->data;
gst_pad_push_event (pad, ev); gst_pad_push_event (pad, ev);
tmp = g_list_next (tmp);
} }
g_list_free (tags);
g_list_free (src->priv->pending_tags);
src->priv->pending_tags = NULL;
} }
/* figure out the new position */ /* figure out the new position */