discoverer: Drop new stream tags once preroll is done

This makes sure we do not touch the stream taglist once the pipeline has
been prerolled. Adding of stream tags happens in the pad event probe
which runs in a different thread from discoverer stream processing, so
modifying the tag list while discoverer might be processing it can
sometimes cause a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=639778
This commit is contained in:
Arun Raghavan 2011-01-18 01:09:53 +05:30 committed by Tim-Philipp Müller
parent 65a298fdee
commit 6ac2e5d384

View file

@ -393,10 +393,15 @@ _event_probe (GstPad * pad, GstEvent * event, PrivateStream * ps)
gst_event_parse_tag (event, &tl);
GST_DEBUG_OBJECT (pad, "tags %" GST_PTR_FORMAT, tl);
DISCO_LOCK (ps->dc);
tmp = gst_tag_list_merge (ps->tags, tl, GST_TAG_MERGE_APPEND);
if (ps->tags)
gst_tag_list_free (ps->tags);
ps->tags = tmp;
/* If preroll is complete, drop these tags - the collected information is
* possibly already being processed and adding more tags would be racy */
if (G_LIKELY (ps->dc->priv->processing)) {
tmp = gst_tag_list_merge (ps->tags, tl, GST_TAG_MERGE_APPEND);
if (ps->tags)
gst_tag_list_free (ps->tags);
ps->tags = tmp;
} else
GST_DEBUG_OBJECT (ps->dc, "Dropping tags since preroll is done");
DISCO_UNLOCK (ps->dc);
}
@ -1143,7 +1148,10 @@ discoverer_bus_cb (GstBus * bus, GstMessage * msg, GstDiscoverer * dc)
if (dc->priv->processing) {
if (handle_message (dc, msg)) {
GST_DEBUG ("Stopping asynchronously");
/* Serialise with _event_probe() */
DISCO_LOCK (dc);
dc->priv->processing = FALSE;
DISCO_UNLOCK (dc);
discoverer_collect (dc);
discoverer_cleanup (dc);
}