adder: fix deadly setcaps recursion

Use a flag to avoid calling setcaps until our stack is exhausted. I don't see how this would be useful.
This commit is contained in:
Stefan Sauer 2011-11-29 10:40:40 +01:00
parent 0d87fd7146
commit 9debd13665
2 changed files with 12 additions and 0 deletions

View file

@ -263,6 +263,11 @@ gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * caps)
IterData idata; IterData idata;
gboolean done; gboolean done;
/* this get called recursively due to gst_iterator_foreach calling
* gst_pad_set_caps() */
if (adder->in_setcaps)
return TRUE;
GST_LOG_OBJECT (adder, "setting caps pad %p,%s to %" GST_PTR_FORMAT, pad, GST_LOG_OBJECT (adder, "setting caps pad %p,%s to %" GST_PTR_FORMAT, pad,
GST_PAD_NAME (pad), caps); GST_PAD_NAME (pad), caps);
@ -273,6 +278,7 @@ gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * caps)
idata.caps = caps; idata.caps = caps;
idata.pad = pad; idata.pad = pad;
adder->in_setcaps = TRUE;
done = FALSE; done = FALSE;
while (!done) { while (!done) {
ires = gst_iterator_foreach (it, (GstIteratorForeachFunction) setcapsfunc, ires = gst_iterator_foreach (it, (GstIteratorForeachFunction) setcapsfunc,
@ -287,6 +293,10 @@ gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * caps)
break; break;
} }
} }
adder->in_setcaps = FALSE;
GST_LOG_OBJECT (adder, "handle caps changes on pad %p,%s to %" GST_PTR_FORMAT,
pad, GST_PAD_NAME (pad), caps);
if (!gst_audio_info_from_caps (&info, caps)) if (!gst_audio_info_from_caps (&info, caps))
goto invalid_format; goto invalid_format;

View file

@ -77,6 +77,8 @@ struct _GstAdder {
/* Pending inline events */ /* Pending inline events */
GList *pending_events; GList *pending_events;
gboolean in_setcaps;
}; };
struct _GstAdderClass { struct _GstAdderClass {