From ed95eff8a1cf986e9a2c58119f8a4b30627cb2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 8 Apr 2006 18:11:56 +0000 Subject: [PATCH] gst/gstpad.c: Must set peer pads before calling the link function, otherwise a task started from a link function migh... Original commit message from CVS: * gst/gstpad.c: (gst_pad_link): Must set peer pads before calling the link function, otherwise a task started from a link function might get a flow-not-linked result when trying to push because the other thread where the linking happens hasn't had a chance to set the peers yet. This might happen for example when a queue gets linked to a downstream element, as queue starts a streaming task when its source pad gets linked. Happens in real life when playing back flac/musepack files in playbin (#332390). --- ChangeLog | 12 ++++++++++++ gst/gstpad.c | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 830fd03d1b..aafedb9951 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-04-08 Tim-Philipp Müller + + * gst/gstpad.c: (gst_pad_link): + Must set peer pads before calling the link function, otherwise + a task started from a link function might get a flow-not-linked + result when trying to push because the other thread where the + linking happens hasn't had a chance to set the peers yet. This + might happen for example when a queue gets linked to a downstream + element, as queue starts a streaming task when its source pad + gets linked. Happens in real life when playing back flac/musepack + files in playbin (#332390). + 2006-04-08 Stefan Kost * gst/gstindex.h: diff --git a/gst/gstpad.c b/gst/gstpad.c index 4788b06313..96a7dd46a9 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1730,6 +1730,10 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad) if (result != GST_PAD_LINK_OK) goto prepare_failed; + /* must set peers before calling the link function */ + GST_PAD_PEER (srcpad) = sinkpad; + GST_PAD_PEER (sinkpad) = srcpad; + GST_OBJECT_UNLOCK (sinkpad); GST_OBJECT_UNLOCK (srcpad); @@ -1750,9 +1754,6 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad) GST_OBJECT_LOCK (sinkpad); if (result == GST_PAD_LINK_OK) { - GST_PAD_PEER (srcpad) = sinkpad; - GST_PAD_PEER (sinkpad) = srcpad; - GST_OBJECT_UNLOCK (sinkpad); GST_OBJECT_UNLOCK (srcpad); @@ -1767,6 +1768,9 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad) GST_CAT_INFO (GST_CAT_PADS, "link between %s:%s and %s:%s failed", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_PAD_PEER (srcpad) = NULL; + GST_PAD_PEER (sinkpad) = NULL; + GST_OBJECT_UNLOCK (sinkpad); GST_OBJECT_UNLOCK (srcpad); }