[gst-cvs] gst-plugins-good: rtpbin: Handle rysnc of iterator when looking for free pad name
Wim Taymans
wtay at kemper.freedesktop.org
Fri Sep 24 05:11:09 PDT 2010
Module: gst-plugins-good
Branch: master
Commit: bd8d80a8e4df1da1f9acd6b4d1e32fdc18f7218b
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=bd8d80a8e4df1da1f9acd6b4d1e32fdc18f7218b
Author: Pascal Buhler <pascal.buhler at tandberg.com>
Date: Mon Apr 12 09:49:14 2010 +0200
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
---
gst/rtpmanager/gstrtpbin.c | 42 ++++++++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index 085fe8b..88965f6 100644
--- a/gst/rtpmanager/gstrtpbin.c
+++ b/gst/rtpmanager/gstrtpbin.c
@@ -2768,25 +2768,47 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
{
gboolean name_found = FALSE;
gint session = 0;
- GstPad *pad = NULL;
GstIterator *pad_it = NULL;
gchar *pad_name = NULL;
GST_DEBUG_OBJECT (element, "find a free pad name for template");
while (!name_found) {
+ gboolean done = FALSE;
g_free (pad_name);
pad_name = g_strdup_printf (templ->name_template, session++);
pad_it = gst_element_iterate_pads (GST_ELEMENT (element));
name_found = TRUE;
- while (name_found &&
- gst_iterator_next (pad_it, (gpointer) & pad) == GST_ITERATOR_OK) {
- gchar *name;
-
- name = gst_pad_get_name (pad);
- if (strcmp (name, pad_name) == 0)
- name_found = FALSE;
- g_free (name);
- gst_object_unref (pad);
+ while (!done) {
+ gpointer data;
+
+ switch (gst_iterator_next (pad_it, &data)) {
+ case GST_ITERATOR_OK:
+ {
+ GstPad *pad;
+ gchar *name;
+
+ pad = GST_PAD_CAST (data);
+ name = gst_pad_get_name (pad);
+
+ if (strcmp (name, pad_name) == 0) {
+ done = TRUE;
+ name_found = FALSE;
+ }
+ g_free (name);
+ 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);
}
More information about the Gstreamer-commits
mailing list