mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-16 17:10:35 +00:00
rtpbin: Handle rysnc of iterator when looking for free pad name
If a new pad was added while iterating then a pad could be returned that was already in use. Fixes #630451
This commit is contained in:
parent
8337c89c74
commit
bd8d80a8e4
1 changed files with 31 additions and 9 deletions
|
@ -2768,25 +2768,47 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
|
||||||
{
|
{
|
||||||
gboolean name_found = FALSE;
|
gboolean name_found = FALSE;
|
||||||
gint session = 0;
|
gint session = 0;
|
||||||
GstPad *pad = NULL;
|
|
||||||
GstIterator *pad_it = NULL;
|
GstIterator *pad_it = NULL;
|
||||||
gchar *pad_name = NULL;
|
gchar *pad_name = NULL;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (element, "find a free pad name for template");
|
GST_DEBUG_OBJECT (element, "find a free pad name for template");
|
||||||
while (!name_found) {
|
while (!name_found) {
|
||||||
|
gboolean done = FALSE;
|
||||||
g_free (pad_name);
|
g_free (pad_name);
|
||||||
pad_name = g_strdup_printf (templ->name_template, session++);
|
pad_name = g_strdup_printf (templ->name_template, session++);
|
||||||
pad_it = gst_element_iterate_pads (GST_ELEMENT (element));
|
pad_it = gst_element_iterate_pads (GST_ELEMENT (element));
|
||||||
name_found = TRUE;
|
name_found = TRUE;
|
||||||
while (name_found &&
|
while (!done) {
|
||||||
gst_iterator_next (pad_it, (gpointer) & pad) == GST_ITERATOR_OK) {
|
gpointer data;
|
||||||
|
|
||||||
|
switch (gst_iterator_next (pad_it, &data)) {
|
||||||
|
case GST_ITERATOR_OK:
|
||||||
|
{
|
||||||
|
GstPad *pad;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
|
||||||
|
pad = GST_PAD_CAST (data);
|
||||||
name = gst_pad_get_name (pad);
|
name = gst_pad_get_name (pad);
|
||||||
if (strcmp (name, pad_name) == 0)
|
|
||||||
|
if (strcmp (name, pad_name) == 0) {
|
||||||
|
done = TRUE;
|
||||||
name_found = FALSE;
|
name_found = FALSE;
|
||||||
|
}
|
||||||
g_free (name);
|
g_free (name);
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GST_ITERATOR_ERROR:
|
||||||
|
case GST_ITERATOR_RESYNC:
|
||||||
|
/* restart iteration */
|
||||||
|
done = TRUE;
|
||||||
|
name_found = FALSE;
|
||||||
|
session = 0;
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_DONE:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gst_iterator_free (pad_it);
|
gst_iterator_free (pad_it);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue